這篇文章給大家分享的是有關(guān)Mysql中Anemometer怎么用的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),新興企業(yè)網(wǎng)站建設(shè),新興品牌網(wǎng)站建設(shè),網(wǎng)站定制,新興網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,新興網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。準(zhǔn)備條件:
1.MySQL開啟慢查詢
2.安裝Percona Toolkit
rpm -qa|grep percona
percona-toolkit-2.2.7-1
3.下載Anemometer
官網(wǎng):https://github.com/box/Anemometer
4.準(zhǔn)備好php相關(guān)模塊(或者yum)
5.啟動(dòng)apache服務(wù)
rpm -qa|grep http
httpd-2.2.3-45.el5
安裝:
1.安裝Percona Toolkit:
rpm -ivh percona-toolkit-2.2.7-1.noarch.rpm
2.將Anemometer文件包解壓,重命名為anemometer,并移動(dòng)到/var/www/html 下(apache默認(rèn)路徑)
pwd
/var/www/html/anemometer
3.安裝php相關(guān)模塊:
rpm -qa|grep php
php53-common-5.3.3-1.el5
php53-bcmath-5.3.3-1.el5
php53-mysql-5.3.3-1.el5
php53-dba-5.3.3-1.el5
php53-cli-5.3.3-1.el5
php53-gd-5.3.3-1.el5
php53-5.3.3-1.el5
php53-pdo-5.3.3-1.el5
NOTE:
PHP版本要大于5.3,否則就報(bào)錯(cuò),如:
Anemometer requires PHP 5.3 or newer. You have 5.1.6
除此之外還需要:bcmath
rpm -qa|grep bcmath
php53-bcmath-5.3.3-1.el5
4.執(zhí)行setup 腳本,創(chuàng)建用戶:
[root@/var/www/html/anemometer]mysql -uroot -pxxx < install.sql
[root@/var/www/html/anemometer]mysql -uroot -pxxx
mysql > grant all on slow_query_log.* to 'anemometer'@'%' identified by 'test';
mysql > grant select on *.* to 'anemometer'@'%';
mysql > grant all on slow_query_log.* to 'anemometer'@'localhost';
mysql > grant select on *.* to 'anemometer'@'localhost';
5.將慢查詢?nèi)罩就ㄟ^(guò)pt-query-digest分析后存入數(shù)據(jù)庫(kù)中:
pt 版本小于2.2版本的語(yǔ)句:
pt-query-digest --user=anemometer --password=test \
--review h=db.example.com,D=slow_query_log,t=global_query_review \
--review-history h=db.example.com,D=slow_query_log,t=global_query_review_history \
--no-report --limit=0% \
--filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" \
/root/test/localhost-slow.log
pt 版本大于2.2版本的語(yǔ)句:
pt-query-digest --user=anemometer --password=test --review h=hd-119-186,D=slow_query_log,t=global_query_review --history h=hd-119-186,D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /root/test/localhost-slow.log
執(zhí)行這個(gè)操作后,將會(huì)把慢日志分析后存入mysql的slow_query_log數(shù)據(jù)庫(kù)。
NOTE:
記得保證相應(yīng) '用戶'@'主機(jī)' 的訪問(wèn)權(quán)限
6.修改可視界面的配置信息:
cd /var/www/html/anemometer/conf
cp sample.config.inc.php config.inc.php
vi config.inc.php
以及:
NOTE:
主機(jī)名一定要修改正確,不能保留為localhost,否則會(huì)導(dǎo)致最終界面無(wú)法訪問(wèn)。
7.最終本地通過(guò)IP訪問(wèn):
http://192.168.44.130/anemometer
查詢后可獲得慢查詢?nèi)罩镜慕Y(jié)果:
[root@RZ-SI1-DB-14 conf]# ll
total 40
-rwxr-xr-x 1 root root 15504 Oct 12 14:51 config.inc.php ###新版都不需要修改里面的配置了,只需要修改下面的datasource
-rwxrwxrwx 1 root root 314 Oct 12 14:54 datasource_si1.inc.php
-rwxr-xr-x 1 root root 314 Oct 12 15:05 datasource_st1.inc.php ---配置多個(gè)datasource,si1 st1 機(jī)器上分別導(dǎo)入install.sql 并pt-query-digest 慢日志進(jìn)去
-rwxrwxrwx 1 root root 0 Oct 13 2016 index.html
-rwxrwxrwx 1 root root 15487 Oct 13 2016 sample.config.inc.php
[root@RZ-SI1-DB-14 conf]# more datasource_si1.inc.php
<?php
$conf['datasources']['si1'] = array(
'host' => '10.38.96.132',
'port' => 3306,
'db' => 'slow_query_log',
'user' => 'xxxxxx',
'password' => 'xxxxxx',
'tables' => array(
'global_query_review' => 'fact',
'global_query_review_history' => 'dimension'
),
'source_type' => 'slow_query_log'
);
[root@RZ-SI1-DB-14 conf]# more datasource_st1.inc.php
<?php
$conf['datasources']['st1'] = array(
'host' => '10.38.96.128',
'port' => 3306,
'db' => 'slow_query_log',
'user' => 'xxxxxxx',
'password' => 'xxxxxxxx',
'tables' => array(
'global_query_review' => 'fact',
'global_query_review_history' => 'dimension'
),
'source_type' => 'slow_query_log'
);
感謝各位的閱讀!關(guān)于“Mysql中Anemometer怎么用”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
新聞標(biāo)題:Mysql中Anemometer怎么用-創(chuàng)新互聯(lián)
瀏覽路徑:http://www.rwnh.cn/article40/cejoeo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、軟件開發(fā)、自適應(yīng)網(wǎng)站、微信公眾號(hào)、電子商務(wù)、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容