yun 发表于 2018-3-27 20:05:17

zabbix connection to database 'zabbix' failed

在启动zabbix时启动失败,查看日志:# tailf /tmp/zabbix_server.log  
24661:20180326:203250.916 connection to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
24661:20180326:203250.916 database is down: reconnecting in 10 seconds  
24661:20180326:203300.916 connection to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
24661:20180326:203300.916 database is down: reconnecting in 10 seconds  
24661:20180326:203310.917 connection to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
24661:20180326:203310.917 database is down: reconnecting in 10 seconds  
24661:20180326:203320.918 connection to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
24661:20180326:203320.918 database is down: reconnecting in 10 seconds  
24661:20180326:203330.920 connection to database 'zabbix' failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
24661:20180326:203330.920 database is down: reconnecting in 10 seconds  发现日志链接不上
# ll /var/lib/mysql/mysql.sock  
ls: cannot access /var/lib/mysql/mysql.sock: No such file or directory  
# ll /var/lib/mysql  
ls: cannot access /var/lib/mysql: No such file or directory  

可以知道是/var/lib/mysql/mysql.sock不存在
在系统中查找mysql.sock文件:# find / -name mysql.sock  
/tmp/mysql.sock  可以知道是在/tmp/下,这个时候有两种方式解决这个问题:
1)做mysql.sock的链接# mkdir /var/lib/mysql  
# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock  
# /etc/rc.d/init.d/mysqld restart  
Shutting down MySQL... SUCCESS!   
Starting MySQL SUCCESS!   2)修改zabbix_server.conf中的mysql.sock的配置vim /etc/zabbix/zabbix_server.conf  
DBSocket=/tmp/mysql.sock 再重启zabbix就好
页: [1]
查看完整版本: zabbix connection to database 'zabbix' failed