本文适用于5.4以上zabbix,如果使用3.x可使用此文↓↓↓
使用Orabbix在Ubuntu的Zabbix上监控Oracle_凯神做开发-CSDN博客
6.0版本zabbix请使用:
在OracleLinux8.6的Zabbix6.0中监控Oracle11gR2_谷凯Jump的博客-CSDN博客
---------------------在Zabbix Agent服务器操作---------------------
1. 安装Oracle-instantclient
#以下所有操作使用root账号执行
#创建目录
mkdir -p /opt/oracle
cd /opt/oracle
#下载odbc安装包
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-basic-21.3.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-devel-21.3.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-odbc-21.3.0.0.0-1.x86_64.rpm
#安装unixODBC和unixODBC-devel
yum -y install unixODBC unixODBC-devel
#安装oracle-instantclient
yum localinstall oracle-instantclient-*
#oracle-instantclient的安装位置如下
/usr/lib/oracle/21/client64
/usr/share/oracle/21/client64
/usr/include/oracle/21/client64
如果下载失败的话可能是因为Oracle版本变更,到Oracle官网查看下载最新的oracle-instantclient即可
Instant Client for Linux x86-64 (64-bit)
oracle-instantclient-basic
oracle-instantclient-devel
oracle-instantclient-odbc
oracle-instantclient-sqlplus
2. 环境变量配置
vi /etc/profile
#在文本中添加以下代码
----------------
export ORACLE_HOME=/usr/lib/oracle/21/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
----------------
#保存后适用新的环境变量
source /etc/profile
#配置类库
chmod +x /usr/lib/oracle/21/client64/lib/libsqora.so.21.1
cd /usr/lib64
ln -s libodbcinst.so.2.0.0 libodbcinst.so.1
3. 添加Oracle驱动
vi /etc/odbcinst.ini
#在文本中添加以下代码
----------------
[Oracle]
Description = ODBC for Oracle
Driver = /usr/lib/oracle/21/client64/lib/libsqora.so.21.1
----------------
4. 添加ODBC DSN
vi /etc/odbc.ini
# 配置示例
[MESDB01]
Driver = Oracle #刚才添加的驱动名称
ServerName = 10.255.32.93:1521/orcl #ip:port/sid
[MESDB02]
Driver = Oracle
ServerName = 10.255.32.99:1521/orcl
#ServerName = TNS中的TNSNAME 适用这种情况时虽然isql可以连接,但是zabbix agent将无法处理
#TNS 需在$ORACLE_HOME/network/admin目录中创建tnsnames.ora文件
5. 检查数据库连接
必须确保此处连接成功才可进行下一步操作
isql MESDB01 your_username your_password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from dual;
+------+
| DUMMY|
+------+
| X |
+------+
SQLRowCount returns -1
1 rows fetched
SQL> quit
#显示Connected!说明连接成功
---------------------前端配置端---------------------
6. 创建用于监控的专用账号zabbix
CREATE USER ZABBIX IDENTIFIED BY zabbix DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;
GRANT CONNECT TO ZABBIX;
GRANT RESOURCE TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
GRANT SELECT ANY TABLE TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
GRANT UNLIMITED TABLESPACE TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
7. ZabbixServer主机配置
7.1 Interfaces选择客户端,IP地址选择客户端刚才我们配置的那个Agent的IP地址
7.2 模板选择Oracle by ODBC
7.3 宏配置中添加{$ORACLE.DSN} {$ORACLE.USER} {$ORACLE.PASSWORD}三项即可
8. 监控效果
注:
此方法试用 Oracle Database single instance 12c2, 18c, 19c
11g/RAC部分数据可监控.
可参考官网资料: