1.1排查问题所在
首先看zabbix网页端的状态在,发现:“zabbix server is running”的值是不,但是通过如下指令在服务器端查看zabbixserver是正常运行。
[root@Teledb zabbix]# systemctl status zabbix-server
通过看日志文件继续排查,通过如下指令找到安装zabbix时的日志文件所在。
[root@Teledb zabbix]# find / -name zabbix_server.log
/var/log/zabbix/zabbix_server.log
查看一下
101570:20230913:170354.772 Cannot connect to the database. Exiting...
101853:20230913:170354.794 Starting Zabbix Server. Zabbix 4.0.48 (revision 832b83c76af).
101853:20230913:170354.794 ****** Enabled features ******
101853:20230913:170354.794 SNMP monitoring: YES
101853:20230913:170354.794 IPMI monitoring: YES
101853:20230913:170354.794 Web monitoring: YES
101853:20230913:170354.794 VMware monitoring: YES
101853:20230913:170354.794 SMTP authentication: YES
101853:20230913:170354.794 Jabber notifications: YES
101853:20230913:170354.794 Ez Texting notifications: YES
101853:20230913:170354.794 ODBC: YES
101853:20230913:170354.794 SSH support: YES
101853:20230913:170354.794 IPv6 support: YES
101853:20230913:170354.794 TLS support: YES
101853:20230913:170354.794 ******************************
101853:20230913:170354.794 using configuration file: /etc/zabbix/zabbix_server.conf
101853:20230913:170354.799 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'Teledb' (using password: YES)
101853:20230913:170354.799 database is down: reconnecting in 10 seconds
101853:20230913:170404.801 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'Teledb' (using password: YES)
101853:20230913:170404.801 database is down: reconnecting in 10 seconds
101853:20230913:170414.806 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'Teledb' (using password: YES)
101853:20230913:170414.807 database is down: reconnecting in 10 seconds
101853:20230913:170424.811 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'Teledb' (using password: YES)
大致意思是连接数据库失败
1.2问题解决
首先先使用账号密码进入mysql,如果可以正常进入,则表示配置文件中的用户名和密码错误,如果不能进入,使用root账号进入mysql后执行如下指令:
mysql> grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix' with grant option;
mysql>flush privileges;
通过上述指令将密码设置为zabbix后,再次进入,如果成功则查看配置文件密码是否一致,然后重启服务,即可,修改配置文件的指令:
vim /etc/zabbix/zabbix_server.conf
[root@Teledb zabbix]# systemctl restart zabbix-server
[root@Teledb zabbix]# systemctl status zabbix-server
重启服务即可
1.3可能遇到的问题
如果重启服务后,查看zabbix-server的状态是正常运行,但是在网页端登录ip地址/zabbix发现报错Error connecting to database: Access denied for user ‘zabbix’ @ ‘localhost’ to database ‘zabbix’(PASSWORD:YES)
由于上文刚配置过zabbix_server.conf文件,因为大概率应该不是此配置文件的问题,于是通过find / -name指令先查找到zabbix.conf.php文件,将此文件中的网页端登录密码设置为上述设置的zabbix(根据自己设置的来)。:wq保存后重启服务后刷新网页即可。