一台collectdServer:IP:192.168.91.134;一台collectdClient: IP: 192.168.91.133.
首先在collectdServer上本地實驗:
1.安裝mysql:apt-get install mysql-server mysql-client.
2.collectd需要一個串連mysql的使用者,可以不賦予其他許可權。
CREATE USER 'collectd'@'localhost' IDENTIFIED BY 'Fat4ohse'; -- Give appropriate permissions -- ("GRANT USAGE" is synonymous to "no privileges") GRANT USAGE ON *.* TO 'collectd'@'localhost'; -- Permissions for the MasterStats and SlaveStats options GRANT REPLICATION CLIENT ON *.* TO 'collectd'@'localhost';
3.在collectd.conf中進行配置。(配置兩個資料庫:testC和test)
<Plugin mysql>
<Database testC>
Host "localhost"
User "collectd"
Password "Fat4ohse"
Port 3306
# database "testC"
MasterStats true
</Database>
<Database test>
Host "localhost"
User "collectd"
Password "Fat4ohse"
Port 3306
# database "testC"
MasterStats true
</Database>
<Database bar>
Host "localhost"
Socket "/var/run/mysql/mysqld.sock"
SlaveStats true
SlaveNotifications true
</Database>
</Plugin>
4.重啟collectd,出資料。最後產生映像,如資料庫testC的輸入輸出資料流量。
但是
/var/log/syslog一直出現一個問題:
Jan 5 16:59:58 collectdserver-virtual-machine collectd[6355]: mysql plugin: Failed to connect to database <none> at server localhost: Can't connect to local MySQL server through socket '/var/run/mysql/mysqld.sock' (2)
Jan 5 16:59:58 collectdserver-virtual-machine collectd[6355]: read-function of plugin `mysql' failed. Will suspend it for 160 seconds.
Jan 5 16:59:58 collectdserver-virtual-machine collectd[6355]: mysql plugin: Failed to get master statistics: `SHOW MASTER STATUS' did not return any rows.
使用方法:sudo chown-R
mysql /var/run/mysqld/
也沒有解決。。