一、線上系統(tǒng)查看命令
(1)查看系統(tǒng)限制
1 2 3 4 | cat /proc/sys/kernel/pid_max #查看系統(tǒng)支持的最大線程數(shù)(相當于理論值) cat /proc/sys/kernel/thread-max max_user_process(ulimit -u) #系統(tǒng)限制某用戶下最多可以運行多少線程 cat /proc/sys/vm/max_map_count #硬件內(nèi)存大小 |
(2)JVM虛擬機本身限制
1 2 3 | -Xms #Inital java heap size -Xmx #Maximum java heap size -Xss #The stack size for each thread |
(3)查詢當前某程序的線程或者進程數(shù)
1 2 3 | pstree -p `ps -ef|grep XXX |awk '{print $1}' `|wc -l 或 pstree -p PID |wc -l |
示例:
1 2 3 4 | 獲取Tomcat進程PID ps -ef|grep tomcat 統(tǒng)計該tomcat進程內(nèi)的線程個數(shù) ps -Lf PID|wc -l |
(4)查詢當前整個系統(tǒng)已用的線程或者進程數(shù)
1 | pstree -p | wc -l |
參見:http://lisiqi.cc/技術(shù)/2015/12/24/一次線上多線程bug修復.html
(5)內(nèi)存使用情況查詢
1 2 3 4 5 | ./jstack pid|grep "on condition" |wc -l A.heap usage jmap -heap pid B.dump文件 jmap -dump:live,format=b,file=XXX.bin pid |
參考:http://www.cnblogs.com/hechao123/p/7251682.html
一次Tomcat hang住問題排查手記:https://www.zybuluo.com/zhanjindong/note/25710
Tomcat性能參數(shù)優(yōu)化:http://blog.csdn.net/fcly2013/article/details/54945591
Java服務(wù)線上系統(tǒng)性故障:http://techblog.youdao.com/?p=961
(6)指定端口的TCP連接數(shù)
1 2 3 4 5 6 | netstat -an|grep 7090|wc -l #查看某個端口TCP連接來源并排序 netstat -antl|grep ^tcp|grep ":2181" |awk '{print $5}' |awk -F ":" '{count[$1]++}; END{for(ip in count) print ip, ":" count[ip]}' |sort -n -k3 -r #找到最多的TCP對應(yīng)的機器,在那臺機器上查看哪個進程占用的最多連接 netstat -anp|grep ":2181" |awk '{print $7}' |awk -F "/" '{print $1}' |sort|uniq -c|sort -nr |
二、線上系統(tǒng)啟動
(1)redis啟動
1 2 3 4 5 6 7 8 9 | src/redis-cli -h 10.2.137.141 -p 6379 Server模塊 nohup /data01/ public /redis/redis_cluster1/src/redis-server /data01/ public /redis/redis_cluster1/redis.conf & nohup /data01/ public /redis/redis_cluster1/src/redis-sentinel /data01/ public /redis/redis_cluster1/sentinel.conf & Master模塊 nohup /data01/ public /redis/redis_cluster2/src/redis-server /data01/ public /redis/redis_cluster2/redis.conf & nohup /data01/ public /redis/redis_cluster2/src/redis-sentinel /data01/ public /redis/redis_cluster2/sentinel.conf & nohup /data01/ public /redis/redis_cluster3/src/redis-server /data01/ public /redis/redis_cluster3/redis.conf & nohup /data01/ public /redis/redis_cluster3/src/redis-sentinel /data01/ public /redis/redis_cluster3/sentinel.conf & |
config set slowlog-log-slower-than 指定執(zhí)行時間超過多少微秒
(2)Flume啟動
1 | nohup /data01/java/flume/bin/flume-ng agent -c conf/ -f /data01/java/flume/conf/xxx.properties -n agent -Dflume.root.logger=INFO,console >/dev/ null 2 & |
(3)ELK啟動
A.Logstash啟動
1 | nohup bin/logstash -f config/translate.beats-es4.conf & |
B.ElasticSearch啟動
1 | nohup ./elasticsearch & |
C.Kibana啟動
1 2 | fuser -n tcp 5601 nohup ./kibana & |