MySQL 查询中的 ODBC 项目导致 Zabbix 服务器停止

MySQL 查询中的 ODBC 项目导致 Zabbix 服务器停止

我是 Zabbix 新手。今天我尝试向主机添加 SQL 项(数据库监控),但没有成功。

如果没有此 SQL 项,Zabbix 服务器运行正常。我使用 进行了检查service zabbix-server status

启用 SQL 项后,点击现在检查为此,然后service zabbix-server status再次运行,出现错误:

 zabbix-server.service - Zabbix Server
   Loaded: loaded (/lib/systemd/system/zabbix-server.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-11-09 15:41:10 CET; 1s ago
  Process: 330 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=1/FAILURE)
  Process: 335 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
  ...

您可以看到进程 330 报告状态=1/失败

在我打完之后现在检查Zabbix 前端弹出请求已成功发送。但在“监控”>“最新数据”中查找此项没有值。

该项目配置为:

  • 类型:数据库监视器
  • 键:db.odbc.select[num-of-events,backend]
  • 用户名:(空)
  • 密码: (空)
  • SQL 查询:select 1;
  • 信息类型:数字(无符号)

ODBC 数据源后端似乎工作正常:

$ isql backend
> +---------------------------------------+
> | Connected!                            |
> |                                       |
> | sql-statement                         |
> | help [tablename]                      |
> | quit                                  |
> |                                       |
> +---------------------------------------+
>  SQL> select 1;
> +---------------------+
> | 1                   |
> +---------------------+
> | 1                   |
> +---------------------+
> SQLRowCount returns 1
> 1 rows fetched

这是我的 ODBC 配置:

/etc/odbcinst.ini

[mysql]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8S.so
FileUsage = 1

/etc/odbc.ini

[ODBC Data Sources]
backend  = MySQL unicode backend DSN

[backend]
Driver = mysql
Decription = Connector/ODBC Driver to Backend DB
Server = localhost
Port = 3306
User = ???
Password = ???
Database = backend
OPTION = 3
SOCKET = /var/run/mysqld/mysqld.sock

Zabbix 在 Debian Stretch 上运行。Zabbix 服务器版本为 4.0.1。MySQL 版本为 10.1.26-MariaDB-0+deb9u1

知道服务器崩溃的原因吗?

编辑:使用 ANSI 驱动程序 libmyodbc8a.so 而不是 Unicode 驱动程序 libmyodbc8w.so 时没有区别。

编辑2:也使用 ANSI 和 Unicode 版本 mysql-connector-odbc-5.3.11-linux-debian9-x86-64bit 进行了测试,但没有成功。

zabbix 服务器日志告诉错误

 10002:20181109:170635.268 Got signal [signal:11(SIGSEGV),reason:1,refaddr:0x60]. Crashing ...
 10002:20181109:170635.269 ====== Fatal information: ======
 ...
 10002:20181109:170635.269 === Backtrace: ===
 10002:20181109:170635.270 27: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](zbx_backtrace+0x35) [0x55a008633b24]
 10002:20181109:170635.270 26: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](zbx_log_fatal_info+0x119) [0x55a008633d38]
 10002:20181109:170635.270 25: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](+0xf0060) [0x55a008634060]
 10002:20181109:170635.270 24: /lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0) [0x7f1e2039a0c0]
 10002:20181109:170635.270 23: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(+0x79e4d) [0x7f1e12b3ee4d]
 10002:20181109:170635.270 22: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(_Z22add_compiled_collationP12CHARSET_INFO+0x25) [0x7f1e12b3f995]
 10002:20181109:170635.270 21: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(_Z22init_compiled_charsetsi+0x15) [0x7f1e12b8eda5]
 10002:20181109:170635.270 20: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(+0x7918f) [0x7f1e12b3e18f]
 10002:20181109:170635.270 19: /lib/x86_64-linux-gnu/libpthread.so.0(+0xe739) [0x7f1e20397739]
 10002:20181109:170635.270 18: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(_ZSt9call_onceIRFvvEJEEvRSt9once_flagOT_DpOT0_+0x5a) [0x7f1e12b3dcea]
 10002:20181109:170635.270 17: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(_Z22my_charset_get_by_nameP17MY_CHARSET_LOADERPKcji+0x2a) [0x7f1e12b3e67a]
 10002:20181109:170635.270 16: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(_Z21get_charset_by_csnamePKcji+0x3b) [0x7f1e12b3e70b]
 10002:20181109:170635.270 15: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(myodbc_init+0x156) [0x7f1e12b24951]
 10002:20181109:170635.270 14: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(my_SQLAllocEnv+0x1c) [0x7f1e12b2825b]
 10002:20181109:170635.270 13: /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8w.so(SQLAllocHandle+0x60) [0x7f1e12b29326]
 10002:20181109:170635.271 12: /usr/lib/x86_64-linux-gnu/libodbc.so.2(+0xdbb7) [0x7f1e1f43dbb7]
 10002:20181109:170635.271 11: /usr/lib/x86_64-linux-gnu/libodbc.so.2(SQLConnect+0x217) [0x7f1e1f43fdc7]
 10002:20181109:170635.271 10: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](zbx_odbc_connect+0x1ac) [0x55a0085c697b]
 10002:20181109:170635.271 9: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](get_value_db+0x22a) [0x55a00859d132]
 10002:20181109:170635.271 8: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](+0x4968d) [0x55a00858d68d]
 10002:20181109:170635.271 7: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](+0x4b950) [0x55a00858f950]
 10002:20181109:170635.271 6: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](poller_thread+0x192) [0x55a0085909d4]
 10002:20181109:170635.271 5: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](zbx_thread_start+0x32) [0x55a0086411de]
 10002:20181109:170635.271 4: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](MAIN_ZABBIX_ENTRY+0x9ac) [0x55a00857bcee]
 10002:20181109:170635.271 3: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](daemon_start+0x315) [0x55a008633346]
 10002:20181109:170635.271 2: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](main+0x2f6) [0x55a00857b340]
 10002:20181109:170635.271 1: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7f1e1d1de2e1]
 10002:20181109:170635.271 0: /usr/sbin/zabbix_server: poller #2 [got 1 values in 0.004743 sec, getting values](_start+0x2a) [0x55a00857a51a]
 10002:20181109:170635.271 === Memory map: ===
 ...

编辑3:使用 mysql-connector-odbc-5.1.13-linux-debian6.0-x86-64bit.tar.gz 测试,未成功。此失败似乎与https://support.zabbix.com/browse/ZBX-7665https://bugs.mysql.com/bug.php?id=73709

答案1

我找到了一种使用 MariaDB ODBC 连接器而不是 MySQL 连接器的解决方案。

  1. 下载https://downloads.mariadb.com/Connectors/odbc/connector-odbc-3.0.6/我使用 debian-x86_64.tar.gz
  2. 解开它tar -xvzf mariadb-connector-odbc-3.0.6-ga-debian-x86_64.tar.gz
  3. 复制cp lib/libmaodbc.so /usr/lib/
  4. 将以下行添加到/etc/odbcinst.ini

    [mariadb]
    Description = ODBC for MariaDB
    Driver = /usr/lib/libmaodbc.so
    
  5. 编辑你的 DNS/etc/odbc.ini

    Driver = mariadb
    Socket = /var/run/mysqld/mysqld.sock
    

    最后一行也很重要,否则连接器会寻找 /tmp/mysqld.sock。

这适用于 Debian Jessie (8),但不适用于 Debian Stretch (9)。如果运行,ldd libmaodbc.so您会看到 MariaDB ODBC 连接器依赖于 libssl.so.1.0.0,但 Stretch 仅安装了 libssl.so.1.0.2 和 libssl.so.1.1。

相关内容