p90
show global status;
mysqladmin ext -i1 -uroot -p | awk '/Queries/{q=$4-qp;qp=$4} /Threads_connected/{tc=$4} /Threads_running/ {printf "%5d %5d %5d\n", q,tc,$4}'
586862 53 36
4167 53 43
4305 53 36
4832 53 14
4462 53 25
4730 53 24
4658 53 51
4228 53 7
4586 53 7
4002 53 41
show processlist\G
mysql -e "show processlist\G" | grep State: | sort | uniq -c | sort -rn
也可以是查询information_schema 中的processlist 表或者innotop工具
使用慢查询日志
slow_query_log=on;
long_query_time=1;
slow_query_log_file=/mysql/slow/slow.log
log_queries_not_using_indexes=on;
在一次重申::: 好的工具可以帮助诊断这类问题,否则要人工在几百G的查询日志找出原因是多么烦心的一件事情。
统计每秒的查询量:
awk '/^# Time:/{print $3,$4,c;c=0} /^# User/{c++}' slow-query.log