One collectdserver: IP: 192.168.91.134; one collectdclient: IP: 192.168.91.133.
First, perform a local experiment on collectdserver:
1. Install MYSQL: APT-Get install mysql-server mysql-client.
2. collectD requires a user to connect to MySQL and does not grant other permissions.
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. Configure in collectD. conf. (Configure two databases: testc and 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. Restart collectD to output data. Finally, an image is generated, such as the input and output traffic of the database testc.
However
/Var/log/syslog has always encountered a problem:
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.
Usage: sudo chown-R
MySQL/var/run/mysqld/
..