标签:socket conf mysql配置 com src www. dev tar select
系统版本: centos6 x86_64
mysql版本: mysql5.6
实施目的: 监控mysql
客户端配置:
1、准备工作:搭建zabbix服务,使服务端客户端连接成功,并有基础监控项
2、使用percona监控服务,因为percona是监控项更全面,原本支持cacti 目前支持zabbix
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm -y
#安装percona源(agent安装)
yum install percona-zabbix-templates php php-mysql
#安装监控脚本,因为要调用php发送给服务器端所以需安装php组件(agent安装)
3、复制配置文件到agent配置目录
[root@fmysql1 ~]# rpm -ql percona-zabbix-templates /var/lib/zabbix/percona /var/lib/zabbix/percona/scripts /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php /var/lib/zabbix/percona/templates /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml [root@fmysql1 ~]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
4、进入mysql配置zabbix专用监控账户
mysql> GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO ‘zabbix‘@‘localhost‘ IDENTIFIED BY "wxgdwxwx2323";
5、配置mysql登录
[root@bmysql1 ~]# cat /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf <?php $mysql_user = ‘zabbix‘; $mysql_pass = ‘wxgdwxwx2323‘;
$mysql_port = 3306;
#后期发现监控无法取值原因.cnf文件没有加入执行权限
[root@bmysql2 dev]# cd /var/lib/zabbix/percona/script
[root@bmysql2 scripts]# chmod +x ss_get_mysql_stats.php.cnf
[root@bmysql2 scripts]# ll
total 68
-rwxr-xr-x 1 root root 1251 Jan 10 2018 get_mysql_stats_wrapper.sh
-rwxr-xr-x 1 root root 60681 Jan 25 11:32 ss_get_mysql_stats.php
-rwxr-xr-x 1 root root 60 Jan 25 14:22 ss_get_mysql_stats.php.cnf
6、测试
[root@fmysql1 ~]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ] #重启服务 [root@fmysql1 ~]# cd /var/lib/zabbix/percona/scripts/ [root@fmysql1 scripts]# /usr/bin/php -q ./ss_get_mysql_stats.php --host ‘localhost‘ --items gg ERROR: Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)[root@fmysql1 scripts]# #提示获取不到无法连接sock接口文件,可能是因为自己编译安装sock文件在其它目录,直接找到现有sock软链接到这个报错目录下就好了 [root@fmysql1 scripts]# mkdir /var/lib/mysql/ [root@fmysql1 scripts]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock [root@fmysql1 scripts]# /usr/bin/php -q ./ss_get_mysql_stats.php --host ‘localhost‘ --items gg gg:157611224525[root@fmysql1 scripts]# #取值成功!客户端配置OVER
zabbix_get -s 172.18.10.120 -p 10050 -k "MySQL.Handler-commit"
#服务端测试
服务端配置:
标签:socket conf mysql配置 com src www. dev tar select
原文地址:https://www.cnblogs.com/Taj-Zhang/p/10319860.html