Zabbix distributed monitoring (four) - Zabbix monitoring Mysql

Article Directory

A, zabbix monitoring mysql

1, a host is added to Zabbix server comes with mysql monitoring template zabbix

  • Configuration -> Host -> Zabbix servers -> Templates -> Select -> Template DB MySQl -> Select -> add (to the top) -> Update

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

2, the configuration mysql, survival detected

[root@server1 ~]# cd /var/lib
[root@server1 lib]# ls
[root@server1 lib]# mysqladmin -uzabbix -predhat -h 127.0.0.1 | grep -c alive 

Here Insert Picture Description

3. Create a zabbix directory, create a .my.cnffile

[root@server1 lib]# mkdir zabbix
[root@server1 lib]# cd zabbix/
[root@server1 zabbix]# vim .my.cnf
[mysql]
host=localhost
user=root
password=redhat
socket=/var/lib/mysql/mysql.sock

[mysqladmin]
host=localhost
user=root
password=redhat
socket=/var/lib/mysql/mysql.sock
[root@server1 zabbix]# systemctl restart zabbix-agent

Here Insert Picture Description
4, server1 access to the database to generate data

[root@server1 zabbix]# mysql -p
Enter password: 
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> USE zabbix;

MariaDB [zabbix]> SELECT * FROM users;

Here Insert Picture Description
5, found that the monitoring items and their flip-flops graphics are very small, which in the enterprise is not enough

Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description

6, import your own template mysql monitoring services, go to the next agent directory, view the configuration file

[root@server1 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@server1 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@server1 zabbix_agentd.d]# cat userparameter_mysql.conf  

Here Insert Picture Description
This file can be seen from the above, we write the new configuration file in two parts mysql and mysqladmin, because the machine default server is localhost, so do not write this in two parts

7, access templates, percona mysql open source analysis tools, installation

[root@server1 ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm

Here Insert Picture Description

8, copy percona monitoring template userparameter_percona_mysql.confto be monitored is the appropriate directory server zabbix-agent on server1

[root@server1 ~]# cd /var/lib/zabbix/templates/
[root@server1 templates]# ls
[root@server1 templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

Here Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture Description
9, because the monitoring is to use php script percona written, it is necessary to be ready to run php environment, database and password will zabbix written php scripts

[root@server1 templates]# cd  ../scripts/
[root@server1 scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php
[root@server1 scripts]# vim ss_get_mysql_stats.php.cnf
 
<?php
$mysql_user = 'root';
$mysql_pass = 'redhat';
?>
[root@server1 scripts]# systemctl restart zabbix-agent

Here Insert Picture Description

10, the detection percona script, filter monitoring items

[root@server1 scripts]# cd /etc/zabbix/zabbix_agentd.d/
[root@server1 zabbix_agentd.d]# ls
userparameter_mysql.conf  userparameter_percona_mysql.conf
 
[root@server1 zabbix_agentd.d]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh  gg

Here Insert Picture Description
11, delete the file monitoring items, the system automatically generates
Here Insert Picture Description

12, the browser import templates, add monitoring items

  • Configuration -> Template -> group -> Templates / Operabing systems -> Import -> Brwose select the template storage location -> Check polymerization Graphics -> Import

Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture Description

13, remove the previous link to the mysql system comes with templates

  • Configuration -> Host -> Templates -> Select percona Templates -> Update
    Here Insert Picture DescriptionHere Insert Picture Description
    Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description
The update is complete, view the monitored item zabbix server, you can see the number of monitored items after importing the template into a 293 percona, monitoring items, graphics, greatly increase the number of flip-flops is more conducive to our comprehensive database monitoring in a production environment

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

Published 125 original articles · won praise 25 · views 10000 +

Guess you like

Origin blog.csdn.net/ranrancc_/article/details/104381567