Zabbix 2.4.5 comes with a configuration tutorial for MySQL monitoring
- 2020-06-15 10:46:09
- OfStack
This paper mainly introduces the use of Zabbix 2.4.5 with MySQL monitoring configuration, and shares it for your reference and study. Here is a detailed introduction:
1. Relevant instructions
zabbix 2.4.5 is used on the production line to monitor all the business and system networks, and of course it also needs to monitor the information related to THE mysql database. The mysql monitoring template built in zabbix can monitor mysql. This paper has passed zabbix 2.4.5, and other versions can be tested by yourself.
2. Configure mysql to monitor
1. First authorize zabbixagent to connect to the database:
Login to mysql as mysql roott
$mysql -uroot -p123456 -e"GRANT USAGE ON *.* TO 'zabbixagent'@'localhost' IDENTIFIED BY 'zbbixagent'";
$GRANT USAGE,PROCESS,SUPER,REPLICATION CLIENT,REPLICATION SLAVE ON *.* TO 'zabbixagent'@'localhost' IDENTIFIED BY 'zabbixagent';
$flush privileges;
Or:
#mysql -uroot -p -e"GRANT USAGE ON *.* TO 'zabbixagent'@'localhost' IDENTIFIED BY 'zabbixagent'"
2. Add mysql profile
vim /etc/zabbix/.my.cnf
#Zabbix Agent
[mysql]
host=localhost
user=zabbixagent
password=zabbixagent
socket=/data1/mysqldb/mysql/mysql.sock
[mysqladmin]
host=localhost
user=zabbixagent
password=zabbixagent
socket=/data1/mysqldb/mysql/mysql.sock
Note: socket is specifically placed there. Please check the path in cat /etc/ my.cnf before modifying
3. Modify/etc/zabbix/zabbix_agent. conf
The modification is as follows:
UnsafeUserParameters=1
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
4. Modify mysql template parameters
zabbix-2.4.4 comes with mysql template, which is placed in /etc/zabbix/ zabbix_agentd.d/userparameter_mysql.conf by default
Need to put
HOME=/var/lib/zabbix
Replaced by:
HOME=/etc/zabbix
.,$s/\/var\/lib/\/etc/g
(vim command line mode all replaced)
Restart zabbix_agent
#service zabbix_agent restart
If you can't figure out or Not supported to tail zabbix server - f/var/log/zabbix/zabbix_server log
27659:20150428:111248.007 error reason for "ydnwy-01:mysql.status[Uptime]" changed: Received value [ERROR 2002 (HY000):
Can't connect to local MySQL server through socket '/data1/mysqldb/mysql/mysql.sock' (13)]
is not suitable for value type [Numeric (unsigned)] and data type [Decimal]
A similar error indicates that the monitoring side ES108en. sock access problem, please check the permissions or
#ln -s /data1/mysqldb/mysql/mysql.sock /var/lib/mysql/mysql.sock
conclusion