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
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
3. Create a zabbix directory, create a .my.cnf
file
[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
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;
5, found that the monitoring items and their flip-flops graphics are very small, which in the enterprise is not enough
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
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
8, copy percona monitoring template userparameter_percona_mysql.conf
to 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/
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
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
11, delete the file monitoring items, the system automatically generates
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
13, remove the previous link to the mysql system comes with templates
- Configuration -> Host -> Templates -> Select percona Templates -> Update
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