Zabbix error prompt MySQL server has gone away Solution

Source: Internet
Author: User

Zabbix error prompt MySQL server has gone away Solution

Zabbix error prompt MySQL server has gone away Solution

I believe that when you use Zabbix, you will encounter the error message [Z3005] query failed: [2006] MySQL server has gone away. Even though the error message appears, however, it does not affect the normal use of Zabbix Server. Can this problem be solved? This article will help you solve this problem.

1

Error

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

Analysis

If you haven't encountered this problem before, you should first search for it online. MySQL [2006] MySQL server has gone away appears. Based on the network search results, the following solutions will be obtained:

# Vim/etc/my. cnf

Max_allowed_packet = 300 M

Wait_timeout = 200000

Interactive_timeout = 200000

Then restart MySQL. After testing, this method is fruitless and the problem persists.

3

Solution

Continue to find a solution. In Zabbix's JIRA, we can see that this problem is a Zabbix Server BUG, which has been fixed in 2.5. However, this bug is not fixed for versions earlier than 2.5.

The solution is as follows:

# 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 = warn, 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;

}

Pay attention to the red font code

. /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

After the re-compilation is complete, the whole world is quiet and the problem is solved perfectly!

Original article link

Http://mp.weixin.qq.com? _ Biz = MzA5NjgwNzM0OQ ==& mid = 401336090 & idx = 1 & sn = ef5735cba4fb2ef0a9b8eab92cc473c0 # rd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.