collectd plugin:mysql

一臺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/

也沒有解決。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章