MySQL服务器调优思路

1.mysqladmin -uroot ext|awk '/Queries/{q=$4}/Threads_connected/{c=$4}/Threads_running/{r=$4}END{printf("%d %d %d\n",q,c,r)}'

/usr/local/mysql/bin/mysqladmin -uroot -pwangxiaohu ext|awk '/Queries/{printf("%d ",$4)}/Threads_connected/{printf("%d ",$4)}/Threads_running/{printf("%d ",$4)}'

上面2个命令是一个意思

用awk命令不断刷新,查看mysql的Queries(当前已经发生了多少次查询),Threads_connected(有几个线程过来连接),Threads_running(有几个进程正在工作)

 2 tjstatus.sh  (sh tjstatus.sh) 每秒抓取参数

#!/bin/bash

while true
do

/usr/local/mysql/bin/mysqladmin -uroot -pwangxiaohu ext|awk '/Queries/{q=$4}/Threads_connected/{c=$4}/Threads_running/{r=$4}END{printf("%d %d %d\n",q,c,r)}' >> status.txt

sleep 1
done

awk '{q=$1-last;last=$1}{printf("%d %d %d\n",q,$2,$3)}' status.txt  上一次减下一次处理

posted @ 2017-09-04 16:12  Microtiger  阅读(257)  评论(0编辑  收藏  举报