Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using Percona Monitoring Plugins to monitor MySQL in Zabbix

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Using Percona Monitoring Plugins to monitor MySQL in Zabbix

1. Install zabbix agent

[root@szlinux01 ~] # rpm-ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.0-1.el7.x86_64.rpm[root@szlinux01 ~] # yum install zabbix-agent

two。 Modify configuration

[root@szlinux01 ~] # vim / etc/zabbix/zabbix_agentd.conf

Server=192.168.137.3

ServerActive=192.168.137.3

Hostname=szlinux01

3. Start the agent

[root@szlinux01 ~] # systemctl enable zabbix-agent [root@szlinux01 ~] # systemctl start zabbix-agent [root@szlinux01 ~] # netstat-tunpl | grep 10050

4. Test data acquisition on the server side

[root@szzabbix] # zabbix_get-s 192.168.137.3-p 10050-k system.uptime

5. Install php and php-mysql

[root@szlinux01 ~] # yum install epel-release [root@szlinux01 ~] # rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [root@szlinux01 ~] # yum install php php-mysql [root@szlinux01 ~] # rpm- qa zabbix-agent php php-mysql

6. Install and configure percona-zabbix-templates

[root@szlinux01 ~] # 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[root@szlinux01 ~] # cp / var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf / etc/zabbix/zabbix_agentd.d/ [root @ szlinux01 ~] # systemctl restart zabbix-agent

7. First, add permissions to the mysql of the monitored server szlinux01, that is, the local machine uses the zabbix account to connect to the local mysql.

Mysql > grant usage, process, replication client on *. * to 'zabbix'@'localhost' identified by' ABCabcs / boxes / 123 / s / s / MySQL > flush privileges

8. Modify the mysql username and password of the php file

[root@szlinux01 ~] # vim / var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php

$mysql_user = 'zabbix'

$mysql_pass = 'ABCabccountries'

9. Test script

[root@szlinux01 ~] # / var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg

10. Configure ~ zabbix/.my.cnf

[root@szlinux01 ~] # vim ~ zabbix/.my.cnf

[client]

User = zabbix

Password = 'ABCabccountries'

Note: complex passwords require quotation marks.

11.zabbix user test script

[root@szlinux01] # sudo-u zabbix-H / var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave

twelve。 Import template

Download the / var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml on the monitored server szlinux01 locally and import it into the template through the Zabbix page.

Configure-> templates-> Import

Error report:

Solution:

It is troublesome to manually modify the template file to solve the error report. It has been mentioned that this template can be imported into the Zabbix 2.x series and then exported to Zabbix 3.x.

The ready-made Zabbix 3.x percona-zabbix-templates is used directly here.

Zbx_percona_mysql_template.xml template address

13. Add hosts and link templates

Found no up-to-date data. Therefore, the test data acquisition:

[root@szzabbix ~] # zabbix_get-s 192.168.137.3-p 10050-k "MySQL.max-connections"

Error report:

Rm: cannot remove `/ tmp/localhost-mysql_cacti_stats.txt': Operation not permitted

Solution:

You can do the following on the monitored server szlinux01

[root@szlinux01 ~] # rm-rf / tmp/localhost-mysql_cacti_ stats.txt [root @ szlinux01 ~] # touch / tmp/localhost-mysql_cacti_ stats.txt [root @ szlinux01 ~] # chown-R stats / tmp/localhost-mysql_cacti_stats.txt

Then test and get the data on zabbix:

[root@szzabbix] # zabbix_get-s 192.168.137.3-p 10050-k "MySQL.max-connections" [root@szzabbix ~] # zabbix_get-s 192.168.137.3-p 10050-k "MySQL.Threads-connected" [root@szzabbix ~] # zabbix_get-s 192.168.137.3-p 10050-k "MySQL.running-slave"

The data is also available, and after a while, you can see the picture.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report