Zabbix错误提示MySQL server has gone away解决_MySQL

php中文网
发布: 2016-05-27 13:45:31
原创
2743人浏览过

zabbix错误提示mysql server has gone away解决

相信细心的同学在使用Zabbix的过程中,会遇到[Z3005] query failed: [2006] MySQL server has gone away 这个错误提示,虽然出现错误提示,但实际并不会影响Zabbix Server的正常使用。那么,这个问题能不能解决呢?本文将带你彻底解决此问题的出现。

1

错误现象

22773:20160108:172513.801 [Z3005] query failed: [2006] MySQL server has gone away [select hostid,key_,state,filter,error,lifetime from items where itemid=34993]

22968:20160108:172517.815 [Z3005] query failed: [2006] MySQL server has gone away [select hostid,key_,state,filter,error,lifetime from items where itemid=32057]

2

分析

如果你之前没有遇到这个问题,第一想到的应该是去网上搜索,MySQL出现 [2006] MySQL server has gone away,根据网络搜索的结果,会得出以下解决办法:

#vim /etc/my.cnf

max_allowed_packet=300M

wait_timeout=200000

interactive_timeout = 200000

然后重启MySQL,经过测试,该方法无果而终,问题依旧。

3

解决办法

继续寻找解决办法,在Zabbix的JIRA里面看到此问题为Zabbix Server的BUG,已在2.5中解决,但对于2.5以下版本,该bug没有修复。

故事AI绘图神器
故事AI绘图神器

文本生成图文视频的AI工具,无需配音,无需剪辑,快速成片,角色固定。

故事AI绘图神器 77
查看详情 故事AI绘图神器

解决办法如下

#vim src/libs/zbxdb/db.c

int zbx_db_connect(char *host, char *user, char *password, char *dbname, char *dbschema, char *dbsocket, int port)

{ int ret = ZBX_DB_OK, last_txn_error, last_txn_level;#if defined(HAVE_IBM_DB2) char *connect = NULL;#elif defined(HAVE_MYSQL) my_bool mysql_reconnect = 1; #elif defined(HAVE_ORACLE) char *connect = NULL; sword err = OCI_SUCCESS;

#elif defined(HAVE_MYSQL) conn = mysql_init(NULL); if (NULL == mysql_real_connect(conn, host, user, password, dbname, port, dbsocket, CLIENT_MULTI_STATEMENTS)) { zabbix_errlog(ERR_Z3001, dbname, mysql_errno(conn), mysql_error(conn)); ret = ZBX_DB_FAIL;

}

if (0 != mysql_options(conn, MYSQL_OPT_RECONNECT, &mysql_reconnect)) zabbix_log(LOG_LEVEL_WARNING, "Cannot set MySQL reconnect option."); if (ZBX_DB_OK == ret && 0 != mysql_select_db(conn, dbname)) { zabbix_errlog(ERR_Z3001, dbname, mysql_errno(conn), mysql_error(conn)); ret = ZBX_DB_FAIL;

}

注意红色字体的代码

./configure --host=x86_64-redhat-linux-gnu --build=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/sha

re --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-dependency-tracking --enable-server --enable-proxy --enable-java --enable-agent --enable-ipv6 --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --with-libcurl --with-libxml2 --sysconfdir=/etc/zabbix --datadir=/var/lib --enable-server --with-mysql

重新编译完成后,整个世界清静了,问题完美解决!

原文链接

http://mp.weixin.qq.com/s?__biz=MzA5NjgwNzM0OQ==&mid=401336090&idx=1&sn=ef5735cba4fb2ef0a9b8eab92cc473c0#rd

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号