1.GUI interface Add MySQL template
Configuration--Hosts--click the host you want to add--Templates
Add a new template, click Select--Select "Template DB MySQL"
Click on "Add" to add, and finally click Update Updates;
2. Log in to the MySQL service and create a read-only account;
Mysql> Grant SELECT On * * to "Zabbix" @ "localhost" identified by "123456"; #赋权mysql > Flush Privileges; #刷新权限
3. Modify the agent configuration of the MySQL server
# cd /etc/zabbix/zabbix_agentd.d# cp userparameter_mysql.conf{,.bak}# vim userparameter_mysql.conf 5 userparameter=mysql.status[*],echo "show global Status where variable_name= ' $ '; " | HOME=/var/lib/zabbix /data/mysql/bin/mysql -N | awk ' {print $$2} ' 15 UserParameter=mysql.size[*],bash -c ' echo ' Select sum ($ (case "$" In both| "") echo "Data_length+index_length";; data|index) echo "$3_length";; free) echo "Data_free";;  ESAC) from information_schema.tables$ ([[ "$" = "All" | | ! "$ ]] |" | echo " where table_schema=\" $1\ "") $ ([[ "$" = "All" | | ! "$ ]] |" | echo "and table_name=\" $2\ ""); | home=/var/lib/zabbix /data/mysql/bin/mysql -n ' 16 17 userparameter=mysql.ping,home=/var/lib/zabbix /data/mysql/bin/mysqladmin ping | Grep -c alive 18 userparameter=mysql.version,/data/mysql/bin/mysql -v
Note: 1.mysql and mysqladmin with absolute path;
2./var/lib/zabbix to/usr/local/zabbix/etc; as the location for storing the. my.cnf file;
# mkdir-pv/usr/local/zabbix/etc# vim/usr/local/zabbix/etc/.my.cnf\# mysql_agent #文件内容 [mysql]host=localhostuser=z abbixpassword=123456socket=/data/mysql/mysql.sock[mysqladmin]host=localhostuser=zabbixpassword=123456socket=/ data/mysql/mysql.sock# service Zabbix-agent restart# SS-TNL | grep 10050
4.GUI interface
See if MySQL template monitoring is in effect:
Configuration--and Hosts--tap to monitor the server's items options--
Application Select MySQL, click Apply to filter out other monitoring items, check whether the MySQL template monitoring is effective;
Monitoring--Latest data--
The hosts select the MySQL server to monitor; application select MySQL; click allly;
To view the monitoring image:
Monitoring--Graphs--
Host selects the MySQL server to monitor; graph chooses MySQL operations;
Zabbix self-template monitoring MySQL service