实验环境
localhost: zabbix agent
server2: zabbix server
一·安装以及修改配置文件
[root@localhost ~]# ls
percona-zabbix-templates-1.1.8-1.noarch.rpm
[root@localhost ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm
[root@localhost ~]# cd /var/lib/zabbix/percona/scripts/
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh ss_get_mysql_stats.php
[root@localhost scripts]# cd /var/lib/zabbix/percona/templates/
[root@localhost templates]# ls
userparameter_percona_mysql.conf
zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
[root@localhost templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@localhost templates]# cd /etc/zabbix/zabbix_agentd.d/
[root@localhost zabbix_agentd.d]# ls
userparameter_mysql.conf userparameter_percona_mysql.conf
[root@localhost zabbix_agentd.d]# systemctl restart zabbix-agent
[root@localhost templates]# cd /var/lib/zabbix/
[root@localhost zabbix]# ls
percona
[root@localhost zabbix]# cd percona/scripts/
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh ss_get_mysql_stats.php
[root@localhost scripts]# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf # 添加内容
[root@localhost scripts]# cat /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'root';
$mysql_pass = 'westos';
二·登陆mysql是否登陆成功
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh ss_get_mysql_stats.php ss_get_mysql_stats.php.cnf
[root@localhost scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
0
[root@localhost scripts]# cd /tmp/
[root@localhost tmp]# ls
[root@localhost tmp]# cat localhost-mysql_cacti_stats.txt
[root@localhost tmp]# ls
localhost-mysql_cacti_stats.txt
[root@localhost tmp]# rm -fr localhost-mysql_cacti_stats.txt #查看后需要删除
root@localhost ~]# vim ~zabbix/.my.cnf
[root@localhost ~]# cat ~zabbix/.my.cnf
[client]
user = root
password = westos
[root@localhost ~]# systemctl restart zabbix-agent
[root@localhost tmp]# netstat -antlp | grep 10050
[root@localhost ~]# cd /etc/zabbix/
[root@localhost zabbix]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Threads-cached'
三·在网页中添加Mysql
在网页中导入文件
添加Mysql模块
浏览图形
查看监控项