--------------------------
anemometer安装:
访问:
http://mysql1/anemometer
安装lnmp:
http://lnmp.org/changelog.html
wget --no-check-certificate https://api.sinas3.com/v1/SAE_lnmp/soft/lnmp1.2-full.tar.gz
tar zxf lnmp1.2-full.tar.gz && cd lnmp1.2-full && ./install.sh lnmp
添加网站
lnmp vhost add
/home/wwwroot/mysql1
安装anemometer
cd /home/wwwroot/mysql1
git clone https://github.com/box/Anemometer.git anemometer
cd anemometer
mysql < install.sql
mysql -e "grant ALL ON slow_query_log.* to 'anemometer'@'%' IDENTIFIED BY '123456';"
mysql -e "grant SELECT ON *.* to 'anemometer'@'%' IDENTIFIED BY '123456';"
cp conf/sample.config.inc.php conf/config.inc.php
vi config.inc.php
$conf['datasources']['localhost'] = array(
'host' => 'localhost',
'port' => 3306,
'db' => 'slow_query_log',
'user' => 'anemometer',
'password' => '123456',
'tables' => array(
'global_query_review' => 'fact',
'global_query_review_history' => 'dimension'
),
'source_type' => 'slow_query_log'
);
'explain' => function ($sample) {
$conn['user'] = 'anemometer';
$conn['password'] = '123456';
return $conn;
},
把慢日志分析后存入mysql的slow_query_log数据库
For pt-query-digest version >= 2.2
在DB19服务器上定期执行该脚本,将慢查询日志导入到slow_query_log数据库中
vi impslow19.sh
pt-query-digest --user=anemometer --password=xxxx --host=172.28.15.130 --port=3307 --review h=172.28.15.130,D=slow_query_log,t=global_query_review --history h=172.28.15.130,D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /opt/mysql3306/data/server19-slow.log-`date +%Y%m%d`
BOX Anemometer:
时间条件:from to 要调整
显示选项:snippet,query_time_avg,rows_sent_avg
访问测试:
http://mysql1/anemometer