zabbix监控mysql时产生的访问issue

描述:使用zabbix 3.4进行监控MySQL5.7,但是在agent端取值时,一直报warning问题,过程如下

1.在agent编写简单的取值脚本,并测试

[root@test ~]# mysql -utest -ptest-e 'show databases'|grep -v Database|wc -l
5
[root@test ~]# cat /etc/zabbix/zabbix_agentd.d/check_agent_db.conf 
UserParameter=mysql.dbnum,/usr/sbin/mysql -e 'show databases'|grep -v Database|wc -l
[root@test ~]# systemctl restart zabbix-agent

2.在zabbi-server测试就一直报warning的错误

[root@zabbix ~]# zabbix_get -s 11.11.11.101 -p 10050 -k "mysql.dbnum"
Warning: Using a password on the commandline interface can be insecure. ##这句话出现,会导致在zabbix web上报错,产生问题
5

3. search下解决方法是把mysql的账户密码写到文件里

[root@test ~]# cat .my.cnf   #家目录下创建一个隐藏文件
[mysql]
user=zabbix
password=zabbix

本地测试成功,不带账户密码的情况下
[root@test ~]# mysql -e 'show databases'|grep -v Database|wc -l
5

但是在zabbix-server下使用zabbix-get测试,就一直把deny的问题,通过提示在库里给zabbix授权还是不行
[root@zabbix ~]# zabbix_get -s 11.11.11.11.101 -p 10050 -k "mysql.dbnum"
ERROR 1045 (28000): Access denied for user'zabbix'@'localhost' (using password: NO)  

4. 解决方法是写的Mysql配置文件,并重启mysql才生效

[root@web-app ~]# cat /etc/my.cnf  #在配置文件中增加账户密码
[client]
user=zabbix
password=zabbix

Summary:  要解决warning问题需要把密码隐藏起来,按照如下mysql读取配置文件的顺序,按照原理.my.cnf这个文件应该生效,但是没成功解决,但是和放在/etc/my.cnf不同的是在配置到.my.cnf时没有做重启,但是测试通过了

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /home/qicloud-server/mysql/mysql/etc/my.cnf ~/.my.cnf 

  

 

posted @ 2018-02-12 16:46  Reid21  阅读(219)  评论(0)    收藏  举报