zabbix软件的使用排错

1、安装过程过程出现了报错:zabbix红色弹出报错:

      zabbix server is not running: the information displayed may not be current

      解决方法:

      (1)先查看日志   cat /var/log/zabbix/zabbix_server.log    cat /var/log/zabbix/zabbix_agentd.log

      (2)查看selinux是否关闭,查看selinux产生的log,确实有错误提示:

# tail -f /var/log/audit/audit.log
type=AVC msg=audit(1444903828.770:465): avc:  denied  { name_connect } for  pid=2962 comm="httpd" dest=10051 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:zabbix_port_t:s0 tclass=tcp_socket
type=SYSCALL msg=audit(1444903828.770:465): arch=c000003e syscall=42 success=no exit=-13 a0=d a1=7fac4ede9b00 a2=10 a3=7fac4b65414c items=0 ppid=2955 pid=2962 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1444903838.784:466): avc:  denied  { name_connect } for  pid=2964 comm="httpd" dest=10051 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:zabbix_port_t:s0 tclass=tcp_socket
type=SYSCALL msg=audit(1444903838.784:466): arch=c000003e syscall=42 success=no exit=-13 a0=d a1=7fac4ed24180 a2=1c a3=ff00 items=0 ppid=2955 pid=2964 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)

      (3)然后让selinux允许它通过

           setsebool -P httpd_can_network_connect on

      (4)编辑zabbix.conf.php文件,把$ZBX_SERVER的值改为本机的IP地址:

            vim /etc/zabbix/web/zabbix.conf.php  修改为

            $ZBX_SERVER      = '192.168.222.139';

      OK!

 

 

2、

 Get value from agent failed: cannot connect to [[192.168.222.138]:10050]: [111] Connection refused

 

      解决方法:在被监控机器上打开zabbix_agent

 

 

3、

     tail /var/log/zabbix/zabbix_server.log  显示
     50952:20141012:195519.884 One child process died (PID:51233,exitcode/signal:255). Exiting ...
     表示一个子进程死掉,是一个zabbix内存溢出错误 (此错误同样会造成上面红色的闪烁)
     更正:
            1、vim /etc/zabbix/zabbix_server.conf
            2、CacheSize=512M
            3、修改此值后OK

 4、

错误现象

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]

 

分析

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

#vim /etc/my.cnf

 

max_allowed_packet=300M

wait_timeout=200000

interactive_timeout = 200000

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

 

解决办法

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

解决办法如下

 

#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

 

 

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

 

猜你喜欢

转载自u013120869.iteye.com/blog/2249613