授权Zabbix用户,用于发送数据
mysql> grant all on *.* to 'zabbix'@'localhost' identified by 'mhsj.net';
mysql> flush privileges;
Query OK, 0 rows affected (0.11 sec)
测试使用授权的zabbix用户登录数据库
[root@localhost zabbix]# mysql -uroot -pmhsj.net -h 127.0.0.1
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 114356456
Server version: 5.6.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+----------------------------+
| Database |
+----------------------------+
| information_schema |
| health_db |
| hl1w_exch_mp |
| hl1w_fds |
| mmc_doctor |
| mmc_c_eps |
| mmc_imp |
| test |
| zabbix |
+----------------------------+
33 rows in set (0.00 sec)
查找并拷贝Zabbix监控Mysql模板文件
# find / -name user*_mysql.conf
/usr/share/doc/zabbix-agent-5.0.1/userparameter_mysql.conf
[root@localhost ~]#cp /usr/share/doc/zabbix-agent-5.0.1/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@localhost ~]#chown -R zabbix:zabbix /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
由配置文件可以知道,在Linux系统中需要在 /var/lib/zabbix/目录中创建.my.cnf,并且文件必须以下有三个字符串:
[root@localhost zabbix]# cat /var/lib/zabbix/.my.cnf
[mysql]
host=172.16.2.42
user=zabbix
password=mhsj.net
socket=/helowin/mysql/mysql.sock
[mysqladmin]
host=172.16.2.42
user=zabbix
password=mhsj.net
socket=/helowin/mysql/mysql.sock
注意:此处socket位置根据实际情况填写,可以通过ps aux|grep mysql 查看进程看到,也可以查看mysql配置文件,也可以find去查找,一定要写对数据库文件位置。
[root@localhost ~]# systemctl restart zabbix-agent
最后查看图形!
转载请注明:梦绘设计 » 系统监控 » Zabbix-agent 5.0.1监控Mysql数据库
版权声明
本站《作品展示》类文章均为原创,转载必须注明出处,技术分享类文章部分来源于网络,版权归原作者所有,若侵权请留言。