zabbix ODBC 驱动监控Oracle
本文档参考位置
Zabbix官网odbc文档 Oracle monitoring and integration with Zabbix
Oracle官网odbc文档 Oracle Instant Client ODBC 安装说明 | Oracle 中国
目标数据库创建用于监视Oracle DB的用户以及赋权
CREATE USER zabbix IDENTIFIED BY password;
-- Grant access to the zabbix user.
GRANT CONNECT, CREATE SESSION TO zabbix;
GRANT SELECT ON v$instance TO zabbix;
GRANT SELECT ON v$database TO zabbix;
GRANT SELECT ON v$sysmetric TO zabbix;
GRANT SELECT ON v$system_parameter TO zabbix;
GRANT SELECT ON v$session TO zabbix;
GRANT SELECT ON v$recovery_file_dest TO zabbix;
GRANT SELECT ON v$active_session_history TO zabbix;
GRANT SELECT ON v$osstat TO zabbix;
GRANT SELECT ON v$restore_point TO zabbix;
GRANT SELECT ON v$process TO zabbix;
GRANT SELECT ON v$datafile TO zabbix;
GRANT SELECT ON v$pgastat TO zabbix;
GRANT SELECT ON v$sgastat TO zabbix;
GRANT SELECT ON v$log TO zabbix;
GRANT SELECT ON v$archive_dest TO zabbix;
GRANT SELECT ON v$asm_diskgroup TO zabbix;
GRANT SELECT ON sys.dba_data_files TO zabbix;
GRANT SELECT ON DBA_TABLESPACES TO zabbix;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO zabbix;
GRANT SELECT ON DBA_USERS TO zabbix;
lynx监控系统安装odbc包
软件包对应选择数据库版本的
yum -y install unixODBC unixODBC-devel
rpm -ivh oracle-instantclient19.14-basic-19.14.0.0.0-1.x86_64.rpm
rpm -ivh oracle-instantclient19.14-devel-19.14.0.0.0-1.x86_64.rpm
rpm -ivh oracle-instantclient19.14-odbc-19.14.0.0.0-1.x86_64.rpm
rpm -ivh oracle-instantclient19.14-sqlplus-19.14.0.0.0-1.x86_64.rpm
修改配置文件
## 修改Oracle tnsname配置文件
## 编辑配置文件,在安装的版本路径下修改以下文件
## vi /usr/lib/oracle/<version>/client64/network/admin/tnsnames.ora
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IPAddress>)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
oracle =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IPAddress>)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracle)
)
)
修改系统环境变量增加以下内容
## vi /etc/profile
export ORACLE_HOME=/usr/lib/oracle/<version>/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/bin
## 修改 libsqora.so.11.1文件权限(若安装的版本存在,本测试使用的 Oralce 11g 版本)
chmod +x /usr/lib/oracle/<version>/client64/lib/libsqora.so.11.1
ln -s /usr/lib/oracle/<version>/client64/lib/libsqora.so.11.1 libodbcinst.so.1
创建文件并写入内容
## vi /etc/odbcinst.ini
[Oracle]
Description = [描述自填]
Driver = /usr/lib/oracle/[version]/client64/lib/libsqora.so.11.1
创建文件并写入内容
##vi /etc/odbc.ini
[orcl]
Description = [描述自填]
Driver = Oracle ##上边odbcinst.ini创建的驱动名称Oracle
ServerName = [Address]:[Port]/[SID]
UserID = zabbix
Password = <password>
[oracle]
Description = [描述自填]
Driver = Oracle ##上边odbcinst.ini创建的驱动名称Oracle
ServerName = [Address]:[Port]/[SID]
UserID = zabbix
Password = <password>
新建文件/etc/sysconfig/zabbix-server
ORACLE_HOME=/usr/lib/oracle/[version]/client64
LD_LIBRARY_PATH=/usr/lib/oracle/[version]/client64/lib:/usr/lib64
TNS_ADMIN=/usr/lib/oracle/[version]/client64/network/admin
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/oracle/[version]/client64/lib
测试
## 检测驱动是否正常
ldd /usr/lib/oracle/[version]/client64/lib/libsqora.so.11.1
## 未出现not found 字样为正常
##测试配置是否成功
isql -v orcl ## 此处的ORCL为odbc.ini中配置的名称
## 返回以下内容为成功
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
评论 (0)