記得port 3306要開
cd /usr/local/bin //切換到usr/local/bin資料夾
wget http://www.bitbybit.dk/mysql/mrtg-mysql-load/mrtg-mysql-load-1.02.tar.gz //下載
tar zxvf mrtg-mysql-load-1.02.tar.gz //解壓縮
//檔案在原目錄不會產生新目錄
//在/usr/local/bin目錄裡有三個檔案
mrtg-cfg.example
mysql-local-cfg.example
mrtg-mysql-load
*****************************************************************
跟mrtg.cfg在同一目錄下
cp mrtg-cfg.example /etc/mysql-load.cfg //複製並更名
cp mysql-local-cfg.example /etc/mysql-connect-cfg //複製並更名
******************************************************************
find / -name mysqladmin //可先搜尋mysqladmin在哪個目錄下
******************************************************************
vi /usr/local/bin/mrtg-mysql-load //編輯mrtg-mysql-load
$cmd = "mysqladmin " //預設值
$cmd = "/usr/bin/mysqladmin " //修改路徑
********************************************************************
vi /etc/mysql-load.cfg //編輯mysql-load.cfg
// usr/bin/perl perl所在的目錄
// usr/local/bin/mrtg-mysql-load 解壓縮原始檔所在目錄
// etc/mysql-connect-cfg 複製到etc的設定檔
host = localhost //Mysql-IP
http://127.0.0.1/mrtg1 //查看流量圖
排入排程-每五分鐘執行一次vi /etc/crontab //編輯crontab檔
#
* /5 * * * root env LANG=C /usr/bin/mrtg /etc/mysql-load.cfg //寫在#到#符號中間
Options[myserver .MySQL]: growright, perminute, nopercent, integer
MaxBytes[myserver .MySQL]: 200 //流量圖表的最大值
AbsMax[myserver .MySQL]: 2000 //當每分鐘查詢超過 2000 後便忽略
Title[myserver .MySQL]: MySQL Load analysis //網頁的 title
PageTop[myserver .MySQL]: <H1>MySQL Load Analysis</H1> //流量網頁內的標題
YLegend[myserver .MySQL]: Questions //流量圖的 Y 軸顯示
ShortLegend[myserver .MySQL]: q/m
Legend1[myserver .MySQL]: Questions
Legend2[myserver .MySQL]:
Legend3[myserver .MySQL]: Maximal # of questions per min.
Legend4[myserver .MySQL]: Maximal # of slow queries per min.
LegendI[myserver .MySQL]: # of questions:
LegendO[myserver .MySQL]: # of slow queries:
WorkDir: /var/www/mrtg1/ //存放產生流量圖的路徑
********************************************************************
vi /etc/mysql-connect-cfg //編輯mysql-connect-cfg
port = 3306 //Mysql-Port
Number username = root //Mysql-帳號
password = **** //Mysql-密碼
logfile = /var/www/mrtg1/mysql-connect.log //Log檔放置路徑
**********************************************************************
chmod 600 mysql-connect-cfg //變更mysql-connect-cfg目錄權限
mkdir /var/www/mrtg1 //建立網頁目錄
env LANG=C /usr/bin/mrtg /etc/mysql-load.cfg //產生流量圖-多執行幾次-直到無錯誤訊息http://127.0.0.1/mrtg1 //查看流量圖
排入排程-每五分鐘執行一次vi /etc/crontab //編輯crontab檔
#
* /5 * * * root env LANG=C /usr/bin/mrtg /etc/mysql-load.cfg //寫在#到#符號中間
#
參考文件
沒有留言:
張貼留言