目录[-]
一,获取mysql用户下的进程总数ps -ef | awk '{print $1}' | grep "mysql" | grep -v "grep" | wc-1 二,主机性能状态
# uptime 三,CPU使用率
# top 四,磁盘IO量# vmstat 或 # iostat 五,swap进出量[内存]
# free 六,数据库性能状态(1)QPS(每秒Query量)QPS = Questions(or Queries) / seconds mysql > show /*50000 global */ status like 'Question';
(2)TPS(每秒事务量)
(3)key Buffer 命中率 mysql> show status like 'Key%';
(4)InnoDB Buffer命中率 mysql> show status like 'innodb_buffer_pool_read%';
(5)Query Cache命中率
mysql> show status like 'Qcache%';
(7)Thread Cache 命中率 mysql> show status like 'Thread%'; mysql> show status like 'Connections';
(8)锁定状态
(9)复制延时量
(10) Tmp Table 状况(临时表状况)
(12) Innodb_log_waits 量 七、querylogmysql有一个功能就是可以log下来运行的比较慢的sql语句,默认是没有这个log的,为了开启这个功能,要修改my.cnf或者在mysql启动的时候加入一些参数。如果在my.cnf里面修改,需增加如下几行
引用
long_query_time = 1
log-slow-queries = /var/youpath/slow.log log-queries-not-using-indexes[这个在mysql4.10以后才被引入]
引用
-s ORDER what to sort by (t, at, l, al, r, ar etc), ‘at’ is default
-t NUM just show the top n queries -g PATTERN grep: only consider stmts that include this string -s,是order的顺序,说明写的不够详细,俺用下来,包括看了代码,主要有 c,t,l,r和ac,at,al,ar,分别是按照query次数,时间,lock的时间和返回的记录数来排序,前面加了a的时倒叙 -t,是top n的意思,即为返回前面多少条的数据 -g,后边可以写一个正则匹配模式,大小写不敏感的
八、mysqladmin的extended-status指令查看mysql各状态值
/usr/local/mysql/bin/mysqladmin -u User --host=IP --password=Passwd extended-status|grep $VARIABLE|awk '{print $4}' 九、开源监控软件1,RRDTool2,Nagios 3,MRTG 4,Cacti |
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....