[实战]Zabbix 5.2.2监控Oracle数据库BY ODBC
离Zabbix 5.2.2内置的Oracle by ODBC的模版已经发布已有些许时日,一直忙于各种Template的紧张制作与兼容性适配工作中,周末有点时间,写一下关于Oracle by ODBC适配中遇到的一些坑,总结了以下安装与配置方法,亲自试验有效,如果你对我的文章感兴趣,请加入我们的QQ群:Zabbix研究院(QQ群:1107902496)
注意,ODBC是在zabbix-server端配置的
目录
第一步:安装ODBC
yum -y install unixODBC unixODBC-devel
第二步:安装Oracle Client安装包文件如下:
-
oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm
-
oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm
-
oracle-instantclient18.5-odbc-18.5.0.0.0-3.x86_64.rpm
-
oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm
yum localinstall oracle-instantclient18.5-*
-
/usr/share/oracle/18.5/client64
-
/usr/include/oracle/18.5/client64
-
/usr/lib/oracle/18.5/client64
mkdir /usr/lib/oracle/18.5/client64/network/admin -p
第三步:配置SQLPLUS连接扩展
vi /usr/lib/oracle/18.5/client64/network/admin/tnsnames.ora
-
test_oracle=
-
(DESCRIPTION =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = IP)(PORT = PORT))
-
(CONNECT_DATA =
-
(SERVER = DEDICATED)
-
(SERVICE_NAME = 数据库SID)
-
)
-
)
第四步:环境变量配置
vi /etc/profile
-
export ORACLE_HOME=/usr/lib/oracle/18.5/client64
-
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH
-
export TNS_ADMIN=$ORACLE_HOME/network/admin
-
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/binsource /etc/profile
source /etc/profile
第五步:配置需要的类库
-
chmod +x /usr/lib/oracle/18.5/client64/lib/libsqora.so.18.1
-
cd /usr/lib64/
-
ln -s libodbcinst.so.2.0.0 libodbcinst.so.1
第六步:添加ORACLE驱动
-
# vim /etc/odbcinst.ini
-
-
[oracle]
-
Description = Oracle ODBC driver for Oracle 11g
-
Driver = /usr/lib/oracle/18.5/client64/lib/libsqora.so.18.1
第七步:添加Oracle数据源
-
# vim /etc/odbc.ini
-
[test]
-
Driver= oracle
-
ServerName= ip:port/TESTDB
-
UserID= 用户名
-
Password= 密码
第八步:ISQL测试
-
isql -v test
-
检测是否可连接及中间如遇到报错的错误信息
-
isql test
-
+---------------------------------------+
-
| Connected! |
-
| |
-
| sql-statement |
-
| help [tablename] |
-
| quit |
-
| |
-
+---------------------------------------+
第九步:SQLPLUS测试
-
# sqlplus 用户名/密码@tnsnames.ora中配置的连接名称
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 19 11:39:18 2017
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
-
Connected to:
-
-
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SQL> exit
第十步:Zabbix配置
报错处理:
以nologin用户启动的监控系统,配置上监控项之后,报错
解决方案:
尝试1:
-
echo "/usr/lib/oracle/18.5/client64/lib" | sudo tee/etc/ld.so.conf.d/oracle-client-18.5.conf
-
sudo ldconfig
-
sudu ldconfig -v
尝试2:如果尝试1执行后页面依然提示“......file not found”,可以试试下面的操作,操作完记得重启zabbix server服务。
-
需要查找zabbix服务的环境变量文件 没有则新建 默认情况在 /etc/sysconfig 下 server 新建zabbix-server proxy新建zabbix-proxy
-
ORACLE_HOME=/usr/lib/oracle/18.5/client64
-
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH
-
TNS_ADMIN=$ORACLE_HOME/network/admin
-
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
-
export ORACLE_HOME
-
export LD_LIBRARY_PATH
-
export TNS_ADMIN
-
export PATH