Zabbix监控mysql主从数据库在脚步出现用户名和密码是会出现如下报错“Warning: Using a password on the command line interface can be insecure”,报错原因是mysql 5.6版本增加了密码安全策略,之前版本可以使用的命令行里加上密码就会强制报错,所以使用zabbix监控mysql的时候,就会由于收到zabbix客户端日志报错信息。结合了网友的解决方案,现将整理出来供大家参考。
一,zabbix被监控端的设置:
1,首先配置mysql数据库,配置mysql的--login-pathde 安全登录:
设置--login-path:
[root@mysql conf]# mysql_config_editor set --login-path=local --host=localhost --user=zabbix -p
Enter password:
[root@mysql conf]# mysql_config_editor print --all
[local]
user = zabbix
password = *****
host = localhost
mysql> create user 'zabbix' identified by 'zabbix'; #(已创建会显示为0)
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user;
+------------+--------------+
| user | host |
+------------+--------------+
| databak | % |
| ppt | % |
| root | % |
| slave_user | % |
| zabbix | % |
| slave_user | 192.168.1.49 |
+------------+--------------+
6 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> update user set password=password('zabbix') where user='zabbix';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> commit
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3,测试:mysql --login-path=local
[root@mysql conf]# mysql --login-path=local
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 542
Server version: 5.6.25-log Source distribution
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> quit
三,zabbix服务端web设置:
1,模板导入
把template mysql auto discovery导入到zabbix里,具体:配置-----模板------载入-------选择文件。
2,设置正则表达式:管理-----一般------正则表达式--------新的正则表达式-------输入名称和测试字符串--------测试--------保存。