MySQL监控InnoDB Buffer Pool命中率

参加炼数成金的MySQL培训,这是其中的一个作业题.

原来做过类似的监控
http://blog.itpub.net/29254281/viewspace-1222337/

首先,使用脚本进行数据采集
vim /tmp/probe.sh

#!/bin/bash
#采集间隔时间,单位s
asleep=10
user=root
password=root
probe_file=probe.log
while [ 1 ] ; do
    a=$(pt-mysql-summary --user $user --password $password --sleep $asleep | grep -i "Innodb_buffer_pool_read_requests\|Innodb_buffer_pool_reads" | awk '{if(length($3)==0) print 0 ;else print $3}'| tr -t '\n' ' '); 
    Innodb_buffer_pool_read_requests=$(echo $a | awk '{print $1}')
    Innodb_buffer_pool_reads=$(echo $a | awk '{print $2}')
    Innodb_buffer_read_hit_ratio=$(echo "scale=2; ((1 - $Innodb_buffer_pool_reads/$Innodb_buffer_pool_read_requests) * 100)" | bc)

    echo $(date "+%Y-%m-%d_%H:%M:%S") $Innodb_buffer_read_hit_ratio >> $probe_file
done;

然后准备绘制图形的脚本
vim probe.gp

set terminal png size 3000,1000 font '/usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc,14';
set yrange [0:100]
set size ratio 0.9 ; 
set output '/tmp/probe.png' ; 
set xdata time ; 
set grid;
set timefmt '%Y-%m-%d_%H:%M:%S' ; 
set xlabel "时间"
set ylabel "命中率"
plot '/tmp/probe.log' using 1:2 with line title 'InnoDB Buffer Pool命中率'

每次需要查看InnoDB Buffer Pool命中率的时候,执行命令


然后查看绘制的图形


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29254281/viewspace-1278514/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29254281/viewspace-1278514/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值