接上篇:
http://www.javashuo.com/article/p-momwtjhu-kq.htmlphp
http://blog.csdn.net/lishaojun0115/article/details/53152255html
用戶管理包括增長用戶,刪除用戶,查看用戶列表,修改用戶密碼。前端
rabbitmqctl add_user Username Password
rabbitmqctl delete_user Username
rabbitmqctl change_password Username Newpassword
rabbitmqctl list_users
設置用戶角色的命令爲:java
rabbitmqctl set_user_tags User Tag
用戶角色可分爲五類,超級管理員, 監控者, 策略制定者, 普通管理者以及其餘。python
可登錄管理控制檯(啓用management plugin的狀況下),可查看全部的信息,而且能夠對用戶,策略(policy)進行操做。mysql
可登錄管理控制檯(啓用management plugin的狀況下),同時能夠查看rabbitmq節點的相關信息(進程數,內存使用狀況,磁盤使用狀況等)nginx
可登錄管理控制檯(啓用management plugin的狀況下), 同時能夠對policy進行管理。但沒法查看節點的相關信息(上圖紅框標識的部分)。web
僅可登錄管理控制檯(啓用management plugin的狀況下),沒法看到節點信息,也沒法對策略進行管理。redis
沒法登錄管理控制檯,一般就是普通的生產者和消費者。sql
rabbitmqctl set_permissions -p VHostPath User ConfP WriteP ReadP
例如:
rabbitmqctl set_permissions -p / guest 「」 「.」 「.*」
rabbitmqctl list_permissions [-p VHostPath]
rabbitmqctl list_user_permissions User
rabbitmqctl clear_permissions [-p VHostPath] User
CREATE DATABASE yourls; GRANT ALL PRIVILEGES ON yourls.* TO 'yourls'@'%' IDENTIFIED BY 'bobo365'; FLUSH PRIVILEGES; \q
Copy user/config-sample.php to user/config.php define( 'YOURLS_DB_USER', 'yourls' ); define( 'YOURLS_DB_PASS', 'bobo365' ); define( 'YOURLS_DB_NAME', 'yourls' ); define( 'YOURLS_DB_HOST', '10.150.27.51' ); define( 'YOURLS_DB_PREFIX', 'yourls_' ); define( 'YOURLS_SITE', 'http://bobo365.com' ); define( 'YOURLS_HOURS_OFFSET', 0 ); define( 'YOURLS_LANG', '' ); define( 'YOURLS_UNIQUE_URLS', true ); define( 'YOURLS_PRIVATE', true ); define( 'YOURLS_CObobo365IEKEY', 'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm' ); define( 'YOURLS_DEBUG', false ); define( 'YOURLS_URL_CONVERT', 36 );
[root@bobo365 conf.d]# more your.conf
server { listen 80; server_name bobo365.com www.bobo365.com; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 500m; rewrite ^/([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 last; rewrite ^/([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 last; rewrite ^/([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 last; location / { root /data/php; index index.html; } location ~ \.php$ { root /data/php; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
http://bobo365.com/admin/install.php
/usr/local/apache-tomcat-8.0.26
[root@promotion ~]# cd /usr/local/tomcat_instance/
drwxr-xr-x 8 root root 4096 Feb 8 10:06 tomcat1 drwxr-xr-x 8 root root 4096 Feb 8 10:56 tomcat2 drwxr-xr-x 8 root root 4096 Feb 8 10:56 tomcat3 drwxr-xr-x 8 root root 4096 Feb 8 10:15 tomcat4 drwxr-xr-x 8 root root 4096 Feb 8 10:56 tomcat5
[root@promotion tomcat_instance]# cd tomcat1/
drwxr-xr-x 2 root root 4096 Mar 8 16:41 bin drwxr-xr-x 3 root root 4096 Feb 11 17:19 conf drwxr-xr-x 2 root root 4096 Mar 8 11:28 logs drwxr-xr-x 2 root root 4096 Feb 8 10:06 temp drwxr-xr-x 3 root root 4096 Mar 8 13:57 webapps drwxr-xr-x 3 root root 4096 Feb 8 10:06 work
端口:
shutdown 8015 8025 8035 8045 8055 HTTP 8888 8889 8890 8891 8892 AJP 8019 8029 8039 8049 8059
webapps目錄:
/usr/local/tomcat_instance/tomcat1/webapps /usr/local/tomcat_instance/tomcat2/webapps /usr/local/tomcat_instance/tomcat3/webapps /usr/local/tomcat_instance/tomcat4/webapps /usr/local/tomcat_instance/tomcat5/webapps
[root@promotion tomcat1]# tree . ├── bin │?? ├── shutdown.sh │?? ├── startup.sh │?? └── tomcat.pid ├── conf │?? ├── Catalina │?? │?? └── localhost │?? ├── catalina.policy │?? ├── catalina.properties │?? ├── context.xml │?? ├── logging.properties │?? ├── server.xml │?? ├── server.xml_ori │?? ├── tomcat-users.xml │?? ├── tomcat-users.xsd │?? └── web.xml
more conf/server.xml
<Server port="8015" shutdown="SHUTDOWN"> <Connector port="8888" redirectPort="8443" minProcessors="10" maxProcessors="1000" maxThreads="5001" minSpareThreads="1000" maxSpareThreads="2000" acceptCount="31500" connectionTimeout="60000" disableUploadTimeout="true" debug="0" URIEncoding="UTF-8"/> <Connector port="8019" protocol="AJP/1.3" redirectPort="8443" /> <Host name="localhost" appBase="/usr/local/tomcat_instance/tomcat1/webapps" unpackWARs="true" autoDeploy="true">
startup.sh
[root@promotion bin]# vim ../../tomcat1/bin/startup.sh
#!/bin/bash export JRE_HOME=/usr/local/jdk1.8.0_60/jre export CATALINA_HOME=/usr/local/apache-tomcat-8.0.26 export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1" export CATALINA_TMPDIR="$CATALINA_BASE/temp" export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid" export JAVA_OPTS="-Xmx4096m -Xms4096m -Xmn2g -Xss256k -Dtomcat.name=tomcat1"
#建立logs目錄
if [ ! -d "$CATALINA_BASE/logs" ]; then mkdir $CATALINA_BASE/logs fi
#建立temp目錄
if [ ! -d "$CATALINA_BASE/temp" ]; then mkdir $CATALINA_BASE/temp fi
#調用tomcat啓動腳本
bash $CATALINA_HOME/bin/startup.sh "$@"
[root@ext script]# more test.sh
#!/bin/bash USER=bobo365 PASSWORD=bobo365 SRCDIR=/home/bobo365 TODAY=`date +"%Y%m%d"` DESDIR=./upload/${TODAY} IP=192.168.2.133 PORT=20002 cd ${SRCDIR} FILES=`find ${SRCDIR} -name '*.tar.gz'` for FILE in ${FILES} do echo ${FILE} lftp -u ${USER},${PASSWORD} sftp://${IP}:${PORT} <<EOF #mkdir ${DESDIR} cd ${DESDIR}/ lcd ${SRCDIR} put ${FILE} echo "put ${FILE} finished." by EOF done
lftp -u lzdat,lzdat@201711 sftp://192.168.2.23:52000 <<EOF cd upload/20180313/ put /upload/in_sheet_20180313.csv echo "put in_sheet_20180313.csv finished." by EOF
在Nginx中的默認Proxy是隻能對後面Real Server作端口轉發的,而不能作域名轉發。若是想使用Nginx對後端是同一IP、同一端口 轉發不一樣的域名則須要配置Nginx Proxy。
這個是由於默認狀況下:
proxy_set_header Host $proxy_host;
這樣就等於前端輸入域名後到nginx這裏直接轉換成IP進行轉發了。
因而咱們須要修改proxy_set_header的參數。
proxy_set_header Host $http_host;
例:
proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_set_header Host $host; proxy_set_header Referer $http_referer; proxy_set_header Cobobo365ie $http_cobobo365ie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Accept-Encoding ''; proxy_hide_header Vary; proxy_redirect off;
yum -y install epel-release yum install python-pip
[root@bobo365 ~]# more load_test.py
from locust import HttpLocust, TaskSet, task class UserBehavior(TaskSet): @task(1) def baidu(self): self.client.get("/") class WebsiteUser(HttpLocust): task_set = UserBehavior min_wait = 3000 max_wait = 6000
locust -f load_test.py --host=https://www.baidu.com
jps獲取java進程的pid
jstack -F PID >> java.txt 導出cpu佔用高進程的線程棧
top -H -p PID查看對應進程的哪一個線程佔用cpu太高
echo "obase=16; PID" | bc將線程的PID轉化爲16進制
在第二步導出的java.txt中查找轉化爲16進制的線程的pid。找到對應的線程棧。
分析負載高的線程棧都是什麼業務操做。優化程序並處理問題。
https://blog.51cto.com/leesir/2084306
目標一: 全面關閉節能模式,讓MySQL跑在高性能模式下
關閉CPU節能,OPI Link Speed Select 「Max Performance」
關閉內存節能模式,Memory Speed Select 「Max Performance」
Power C-States Select 「Disable」
C1 Enhanced Mode Select "Disable"
目標二:關閉NUMA,讓CPU能始終高效的使用內存
關閉NUMA,Socket Interleave,"Non-NUMA"
目標三:提高IOPS性能
SSD/PCIe-SSD
機械盤搭配陣列卡,cache策略,BBU電池,RAID-10,15KRPM
目標一:提高IOPS性能
配置合理的I/O調度器
機械盤配deadline,執行命令echo deadline >/sys/block/sda/queue/scheduler
固態盤配noop,執行命令echo noop >/sys/block/sda/queue/scheduler
文件系統儘可能使用XFS
mount參數增長noatime,nodiratime,nobarrier
vi /etc/fstab
/dev/sda1 /data xfs defaults,noatime,nodiratime,nobarrier 0 0 /dev/sda2 / xfs defaults,noatime,nodiratime,nobarrier 0 0 /dev/sda3 swap swap defaults,noatime,nodiratime,nobarrier 0 0 mount -o remount /data mount
目標二:減小SWAP使用傾向甚至禁掉,穩定磁盤I/O和網絡減小等待時間
1.vm.swappiness設爲5甚至0,假如不關心發生OOM
echo 'vm.swappiness = 5' >>/etc/sysctl.conf
/sbin/sysctl -p
2.vm.dirty_background_ratio設爲5,vm.dirty_ratio設爲10,讓髒頁持續刷入磁盤,避免磁盤I/O瞬間寫產生TIME_WAIT
echo 'vm.dirty_background_ration = 5' >>/etc/sysctl.conf echo 'vm.dirty_ratio = 10' >>/etc/sysctl.conf /sbin/sysctl -p
3.net.ipv4.tcp_tw_recycle和net.ipv4.tcp_tw_reuse設爲雙1,減小網絡等待時間,提升效率
echo 'net.ipv4.tcp_tw_recycle = 1' >>/etc/sysctl.conf echo 'net.ipv4.tcp_tw_reuse = 1' >>/etc/sysctl.conf /sbin/sysctl -p
略...
set paste
set nopaste
或
set paste!
yum install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm -y yum --enablerepo remi --enablerepo remi-php56 install php …… yum --enablerepo remi --enablerepo remi-php70 install php …… yum --enablerepo remi --enablerepo remi-php71 install php ……
yum -y install epel-release rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y remove php* php-common? yum -y install php70w? php70w-opcache yum -y install php70w-mysql php70w-xml php70w-soap php70w-xmlrpc php70w-mbstring php70w-json php70w-gd php70w-mcrypt yum list | grep php70w* yum -y install php70w-pecl-redis.x86_64 php70w-pecl-memcached.x86_64 systemctl status php-fpm
yum install http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm -y yum install nginx
toolkit:
./pt-query-digest /data/percona-server/logs/mysql-slow.log > query.log
/pt-online-schema-change --user=root --password=bobo365 --host=localhost --alter="ENGINE=Innodb" D=yourls,t=yourls_url --execute
select table_schema,sum(data_length)/1024/1024/1024 as data_length,sum(index_length)/1024/1024/1024 as index_length,sum(data_length+index_length)/1024/1024/1024 as sum_data_index from information_schema.tables where table_schema!='information_schema' and table_schema!='mysql' group by table_schema; +-------------------------+----------------+----------------+----------------+ | table_schema | data_length | index_length | sum_data_index | +-------------------------+----------------+----------------+----------------+ | activemq | 0.000000037253 | 0.000009536743 | 0.000009573996 | | alarms | 0.000045776367 | 0.000061035156 | 0.000106811523 | | ams | 0.000030517578 | 0.000015258789 | 0.000045776367 | | dashboard | 0.000045776367 | 0.000061035156 | 0.000106811523 | | falcon_portal | 0.000183105469 | 0.000183105469 | 0.000366210938 | | graph | 0.000045776367 | 0.000045776367 | 0.000091552734 | | performance_schema | 0.000000000000 | 0.000000000000 | 0.000000000000 | | replication_wwww.ymq.io | 0.000015258789 | 0.000000000000 | 0.000015258789 | | sys | 0.000015258789 | 0.000000000000 | 0.000015258789 | | uic | 0.000061035156 | 0.000091552734 | 0.000152587891 | | yourls | 0.000045776367 | 0.000061035156 | 0.000106811523 | +-------------------------+----------------+----------------+----------------+ 11 rows in set (0.09 sec)
select table_name,data_length,index_length,sum(data_length+index_length) as total_size from information_schema.tables where table_schema='yourls' group by table_name; +----------------+-------------+--------------+------------+ | table_name | data_length | index_length | total_size | +----------------+-------------+--------------+------------+ | yourls_log | 16384 | 16384 | 32768 | | yourls_options | 16384 | 16384 | 32768 | | yourls_url | 16384 | 32768 | 49152 | +----------------+-------------+--------------+------------+ 3 rows in set (0.00 sec)
select sum(data_length+index_length)/1024/124/1024 from information_schema.tables; +---------------------------------------------+ | sum(data_length+index_length)/1024/124/1024 | +---------------------------------------------+ | 18.510122414558 | +---------------------------------------------+ 1 row in set (0.03 sec)
mysql> select * from information_schema.tables where table_name='yourls_url'\G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: yourls TABLE_NAME: yourls_url TABLE_TYPE: BASE TABLE ENGINE: InnoDB VERSION: 10 ROW_FORMAT: Dynamic TABLE_ROWS: 6 AVG_ROW_LENGTH: 2730 DATA_LENGTH: 16384 MAX_DATA_LENGTH: 0 INDEX_LENGTH: 32768 DATA_FREE: 0 AUTO_INCREMENT: NULL CREATE_TIME: 2018-05-25 14:36:30 UPDATE_TIME: 2018-05-25 14:36:30 CHECK_TIME: NULL TABLE_COLLATION: utf8_unicode_ci CHECKSUM: NULL CREATE_OPTIONS: TABLE_COMMENT: 1 row in set (0.00 sec)
99% 365*24*(1-99%)=87.6小時 99.9% 365*24*(1-99.9%)=8.76小時 99.99% 365*24*(1-99.99%)*60=52.56分鐘 99.999% 365*24*(1-99.999%)*60=5.256分鐘```