Zabbix5.0配置ODBC监控oracle数据库

1、安装ODBC
使用yum安装ODBC
yum -y install unixODBC unixODBC-devel
2、安装Oracle-instantclient
先把需要用到的四个rpm离线包下载到本地
mkdir -p oracle
cd oracle
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-sqlplus-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-devel-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-odbc-19.9.0.0.0-1.x86_64.rpm

直接通过下面的命令安装 oracle-instantclient
yum localinstall oracle-instantclient19.9-*
oracle-instantclient的安装位置如下
/usr/lib/oracle/19.9/client64
/usr/share/oracle/19.9/client64
/usr/include/oracle/19.9/client64
3、创建oracle用户
登录oracle服务器并连接oracle
sqlplus /nolog
conn / as sysdba

创建ZABBIX用户
create user ZABBIX identified by zabbix;
grant create session to ZABBIX;

为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;
GRANT SELECT ON V_SYSTEM_EVENT TO ZABBIX;
GRANT SELECT ON V_RECOVERY_FILE_DEST TO ZABBIX;

4、配置SQLPlus连接
在设置环境变量之前,我们需要在/usr/lib/oracle/19.9/client64下创建 network/admin 文件夹,用来配置 tnsnames.ora
创建 network/admin 文件夹
mkdir /usr/lib/oracle/19.9/client64/network/admin -p
配置 tnsnames.ora 文件
Oracle=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = 数据库SID)
)
)
注:HOST处填写oracle数据库服务器IP,SERVICE_NAME处填写数据库的SID
环境变量配置
vi /etc/profile添加以下内容
export ORACLE_HOME=/usr/lib/oracle/18.5/client64
export LD_LIBRARY_PATH=LD_LIBRARY_PATH
export TNS_ADMIN=PATH:HOME/binsource /etc/profile
source /etc/profile加载环境变量
配置需要的类库
chmod +x /usr/lib/oracle/19.9/client64/lib/libsqora.so.19.1
cd /usr/lib64/
ln -s libodbcinst.so.2.0.0 libodbcinst.so.1
添加Oracle驱动
vi /etc/odbcinst.ini添加以下内容
[Oracle]
Description = Oracle ODBC driver for Oracle 11g
Driver = /usr/lib/oracle/19.9/client64/lib/libsqora.so.19.1
添加Oracle数据源
vi /etc/odbc.ini添加以下内容
[Oracle] #DSN名称
Driver = Oracle #驱动名称
ServerName = xxx.xxx.xxx.xxx:1521/数据库SID #IP:端口/SID
UserID = XXX #用户名
Password = XXX #密码

ISQL测试
isql -v Oracle


图片1.png

SQLPlus测试连接
sqlplus 用户名/用户密码@DSN名称


image.png

5、配置zabbix监控
配置——主机——创建主机


image.png
image.png
image.png

配置完成后检查无误,点添加按钮完成主机创建

查看最新数据
点击检测——主机——最新数据


image.png

查看最新数据


image.png

你可能感兴趣的:(Zabbix5.0配置ODBC监控oracle数据库)