黑帽联盟

 找回密码
 会员注册
查看: 2078|回复: 0
打印 上一主题 下一主题

[运维监控] zabbix connection to database 'zabbix' failed

[复制链接]
yun 黑帽联盟官方人员 

920

主题

37

听众

1364

积分

超级版主

Rank: 8Rank: 8

  • TA的每日心情
    奋斗
    2019-10-18 11:20
  • 签到天数: 678 天

    [LV.9]以坛为家II

    在启动zabbix时启动失败,查看日志:
    1. [root@localhost zabbix]# tailf /tmp/zabbix_server.log  
    2. 24661:20180326:203250.916 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
    3. 24661:20180326:203250.916 database is down: reconnecting in 10 seconds  
    4. 24661:20180326:203300.916 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
    5. 24661:20180326:203300.916 database is down: reconnecting in 10 seconds  
    6. 24661:20180326:203310.917 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
    7. 24661:20180326:203310.917 database is down: reconnecting in 10 seconds  
    8. 24661:20180326:203320.918 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
    9. 24661:20180326:203320.918 database is down: reconnecting in 10 seconds  
    10. 24661:20180326:203330.920 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  
    11. 24661:20180326:203330.920 database is down: reconnecting in 10 seconds  
    复制代码
    发现日志链接不上
    [root@localhost zabbix]# ll /var/lib/mysql/mysql.sock  
    ls: cannot access /var/lib/mysql/mysql.sock: No such file or directory  
    [root@localhost zabbix]# ll /var/lib/mysql  
    ls: cannot access /var/lib/mysql: No such file or directory  

    可以知道是/var/lib/mysql/mysql.sock不存在
    在系统中查找mysql.sock文件:
    1. [root@localhost zabbix]# find / -name mysql.sock  
    2. /tmp/mysql.sock  
    复制代码
    可以知道是在/tmp/下,这个时候有两种方式解决这个问题:
    1)做mysql.sock的链接
    1. [root@localhost lib]# mkdir /var/lib/mysql  
    2. [root@localhost lib]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock  
    3. [root@localhost lib]# /etc/rc.d/init.d/mysqld restart  
    4. Shutting down MySQL... SUCCESS!   
    5. Starting MySQL SUCCESS!   
    复制代码
    2)修改zabbix_server.conf中的mysql.sock的配置
    1. vim /etc/zabbix/zabbix_server.conf  
    2. DBSocket=/tmp/mysql.sock
    复制代码
    再重启zabbix就好
    帖子永久地址: 

    黑帽联盟 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
    2、本站所有主题由该帖子作者发表,该帖子作者与黑帽联盟享有帖子相关版权
    3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和黑帽联盟的同意
    4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
    5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
    6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
    7、黑帽联盟管理员和版主有权不事先通知发贴者而删除本文

    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部