CentOS 6.5 zabbix 3.0.4 监控MySQL性能

时间:2023-12-16 19:28:32

安装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
[root@test3 /]# mysql -u root -p
Enter password:

创建一个登陆mysql的用户

mysql> GRANT USAGE ON*.*TO'zabbix'@'localhost'IDENTIFIED BY'zabbix';
Query OK, rows affected (0.00 sec) mysql> FLUSH PRIVILEGES;
Query OK, 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
drwxr-xr-x root root Aug : .
drwxr-xr-x root root Aug : ..
-rw-r--r-- root root Aug : .my.cnf
-rw-r--r-- root root Aug : zabbix_agentd.conf
drwxr-xr-x root root Aug : zabbix_agentd.conf.d

找到userparameter_mysql.conf

[root@test3 etc]# find / -name userparameter_mysql.conf
/zabbix-3.0./conf/zabbix_agentd/userparameter_mysql.conf
root@test3 etc]# cd /zabbix-3.0./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 ]

CentOS 6.5 zabbix 3.0.4 监控MySQL性能

CentOS 6.5 zabbix 3.0.4 监控MySQL性能