一台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/
也没有解决。。