Monitor MySQL using Percona monitoring Plugins in Zabbix
1. Installing the Zabbix Agent
[Email protected] ~]# RPM-IVH http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.0-1.el7.x86_64.rpm [email protected] ~]# Yum install zabbix-agent
2. Modify the configuration
[Email protected] ~]# vim/etc/zabbix/zabbix_agentd.conf
server=192.168.137.3
serveractive=192.168.137.3
hostname=szlinux01
3. Start the agent
[[email protected] ~]# Systemctl enable Zabbix-agent[[email protected] ~]# systemctl start Zabbix-agent[[email protected] ~]# NETSTAT-TUNPL | grep 10050
4. Test data acquisition on the server side
[Email protected] ~]# zabbix_get-s 192.168.137.3-p 10050-k system.uptime
5. Install PHP and Php-mysql
[[email protected] ~]# yum install epel-release[[email protected] ~]# rpm--import/etc/pki/rpm-gpg/rpm-gpg-key-epel-7[[ Email protected] ~]# Yum install php php-mysql[[email protected] ~]# rpm-qa zabbix-agent php php-mysql
6. Installation Configuration Percona-zabbix-templates
[email protected] ~]# Yum install https://www.percona.com/downloads/percona-monitoring-plugins/ Percona-monitoring-plugins-1.1.7/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.7-2.noarch.rpm[[email Protected] ~]# cp/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf/etc/zabbix/zabbix_agentd.d/[ [Email protected] ~]# systemctl restart Zabbix-agent
7. First add permissions to MySQL in the monitored server szlinux01, that is, local MySQL is connected to the computer using the Zabbix account.
Mysql> grant usage, process, replication client on *. * to ' Zabbix ' @ ' localhost ' identified by ' [email protected] #123 '; my sql> flush Privileges;
8. Modify the MySQL user name and password for PHP files
[Email protected] ~]# vim/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
$mysql _user = ' Zabbix ';
$mysql _pass = ' [email protected] #123 ';
9. Test scripts
[Email protected] ~]#/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh GG
10. Configure ~ZABBIX/.MY.CNF
[Email protected] ~]# vim ~zabbix/.my.cnf
[Client]
user = Zabbix
Password = ' [email protected] #123 '
Note: complex passwords require quotation marks.
11.zabbix User test Scripts
[Email protected] ~]# sudo-u zabbix-h/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
12. Import a template
will be monitored by the/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-on the server szlinux01 Sver1.1.7.xml download to the local, through the Zabbix page import into the template.
Import, configuration---templates
650) this.width=650; "title=" clip_image002 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image002 "src=" http://s3.51cto.com/wyfs02/M01/96/09/wKioL1kcKvCRbrxOAACmtpCD8AI314.jpg "border=" 0 "height=" 526 "/ >
Error:
650) this.width=650; "title=" clip_image003 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image003 "src=" http://s3.51cto.com/wyfs02/M02/96/0A/wKiom1kcKvHjFZhYAAAO3QeF2UY125.png "border=" 0 "height=" 95 "/ >
Workaround:
Manually modify the template file to resolve the error is more troublesome, it was mentioned that you can import this template into the Zabbix 2.X series, and then export to Zabbix 3.X.
This is a direct use of ready-made Zabbix 3.X percona-zabbix-templates
Zbx_percona_mysql_template.xml Template Address
650) this.width=650; "title=" clip_image005 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image005 "src=" http://s3.51cto.com/wyfs02/M00/96/0A/wKiom1kcKvKA1RN1AABlfNKFOBQ965.jpg "border=" 0 "height=" 233 "/ >
13. Adding hosts and linking templates
650) this.width=650; "title=" clip_image007 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "alt=" clip_image007 "src=" Http://s3.51cto.com/wyfs02/M01/96/0A/wKiom1kcKvKSUjQrAACB5cqawdc903.jpg "border=" 0 "height=" 317 "/>
No up-to-date data found. So, the test data gets:
[Email protected] ~]# zabbix_get-s 192.168.137.3-p 10050-k "Mysql.max-connections"
Error:
Rm:cannot remove '/tmp/localhost-mysql_cacti_stats.txt ': Operation not permitted
Workaround:
Perform the following actions on the monitored server szlinux01
[Email protected] ~]# rm-rf/tmp/localhost-mysql_cacti_stats.txt[[email protected] ~]# Touch/tmp/localhost-mysql_ Cacti_stats.txt[[email protected] ~]# chown-r zabbix:zabbix/tmp/localhost-mysql_cacti_stats.txt
Then test the fetch data on the Zabbix:
[Email protected] ~]# zabbix_get-s 192.168.137.3-p 10050-k "Mysql.max-connections" [[email protected] ~]# zabbix_get-s 192.168.137.3-p 10050-k "mysql.threads-connected" [[email protected] ~]# zabbix_get-s 192.168.137.3-p 10050-k "MySQL. Running-slave "
The data also has, after a while, you can see the diagram.
This article is from the SQL Server deep Dive blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1926767
Monitor MySQL using Percona monitoring Plugins in Zabbix