CentOS 6.5 zabbix 3.0.4 监控MySQL性能
安装mysql
[root@test3 /]# yum -y install mysql mysql-server
初始化数据库
[root@test3 /]# /etc/init.d/mysqld start
[root@test3 /]# mysqladmin -uroot -h 127.0.0.1 password 123456 [root@test3 /]# mysql -u root -p
Enter password:
创建一个登陆mysql的用户
mysql> GRANT USAGE ON*.*TO'zabbix'@'localhost'IDENTIFIED BY'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
mysql> quit Bye
通过find / -name mysql.sock找出mysql.sock文件路径
[root@test3 /]# find / -name *sock -print /usr/sbin/mksock /var/lib/mysql/mysql.sock
新建文件
[root@test3 /]# vim /usr/local/zabbix/etc/.my.cnf #zabbix Agent [mysql] host=localhost user=zabbix password=zabbix socket=/var/lib/mysql/mysql.sock [mysqladmin] host=localhost user=zabbix password=zabbix socket=/var/lib/mysql/mysql.sock
[root@test3 /]# cd /usr/local/zabbix/etc/ [root@test3 etc]# ll -a total 28 drwxr-xr-x 3 root root 4096 Aug 27 00:18 . drwxr-xr-x 7 root root 4096 Aug 26 19:01 .. -rw-r--r-- 1 root root 187 Aug 27 00:18 .my.cnf -rw-r--r-- 1 root root 10330 Aug 26 19:50 zabbix_agentd.conf drwxr-xr-x 2 root root 4096 Aug 26 19:01 zabbix_agentd.conf.d
找到userparameter_mysql.conf
[root@test3 etc]# find / -name userparameter_mysql.conf /zabbix-3.0.4/conf/zabbix_agentd/userparameter_mysql.conf
root@test3 etc]# cd /zabbix-3.0.4/conf/zabbix_agentd [root@test3 zabbix_agentd]# ls userparameter_examples.conf userparameter_mysql.conf
[root@test3 zabbix_agentd]# cp userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/ [root@test3 zabbix_agentd]# cd /usr/local/zabbix/etc/zabbix_agentd.conf.d/ [root@test3 zabbix_agentd.conf.d]# pwd /usr/local/zabbix/etc/zabbix_agentd.conf.d [root@test3 zabbix_agentd.conf.d]# sed -i 's#/var/lib/zabbix#/usr/loca/zabbix/etc#g' userparameter_mysql.conf
[root@test3 zabbix_agentd.conf.d]# cd /usr/local/zabbix/etc/
修改zabbix_agentd.conf文件,添加下面一行 [root@test3 etc]# vim zabbix_agentd.conf Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/ [root@test3 etc]# /etc/init.d/zabbix_agentd restart Shutting down zabbix_agentd: [ OK ] Starting zabbix_agentd: [ OK ]