哈喽!大家好,我是【IT邦德】,江湖人称jeames007,10年DBA工作经验
一位上进心十足的【大数据领域博主】!
中国DBA联盟(ACDU)成员,目前从事DBA及程序编程
擅长主流数据Oracle、MySQL、PG 运维开发,备份恢复,安装迁移,性能优化、故障应急处理等。
✨ 如果有对【数据库】感兴趣的【小可爱】,欢迎关注【IT邦德】
❤️❤️❤️感谢各位大可爱小可爱!❤️❤️❤️
#创建zabbix目录,进入zabbix目录
[root@jeames ~]# mkdir -p /zabbix
[root@jeames ~]# cd /zabbix
以下为官方下载地址
https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-sqlplus-19.9.0.0.0-1.x86_64.rpm
https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-devel-19.9.0.0.0-1.x86_64.rpm
https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-odbc-19.9.0.0.0-1.x86_64.rpm
[root@jeames zabbix]# yum localinstall oracle-instantclient19.9-*
注意:实现配置好本地yum,请参考以下博客
Linux配置本地yum源,高效便捷
https://jeames.blog.csdn.net/article/details/120557997
#oracle-instantclient的安装位置如下
[root@jeames zabbix]# find / -name client64
/usr/lib/oracle/19.9/client64
/usr/share/oracle/19.9/client64
/usr/include/oracle/19.9/client64
## 保证好数据库监听和实例是运行状态
[root@jeames ~]# su - oracle
[oracle@jeames ~]$ lsnrctl status
[oracle@jeames ~]$ lsnrctl start
SQL> show parameter name
SQL> show pdbs
--开PDB库
SQL> alter pluggable database PDB2 open;
SQL> select name,cdb from v$database;
--CDB切到PDB
SQL> alter session set container = PDB2;
SQL> create user zabbix identified by zabbix;
SQL> grant dba to zabbix;
注意:以下均在Zabbix Server做操作
vi /etc/profile
cat >> /etc/profile << "EOF"
export ORACLE_HOME=/usr/lib/oracle/19.9/client64
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:/usr/lib:$ORACLE_HOME/bin
export TNS_ADMIN=$ORACLE_HOME/network/admin
EOF
#环境变量生效
[root@jeames ~]# source /etc/profile
## 驱动
chmod +x /usr/lib/oracle/19.9/client64/lib/libsqora.so.19.1
-- 配置odbcinst.ini文件信息:
[root@jeames ~]# vi /etc/odbcinst.ini
#添加如下内容
[Oracle]
Description = Oracle ODBC driver for Oracle 19c
Driver = /usr/lib/oracle/19.9/client64/lib/libsqora.so.19.1
--配置odbc.ini文件
[root@jeames ~]# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
[root@jeames ~]# rm -rf /root/.odbc.ini
cat >> /etc/odbc.ini << "EOF"
[ora19c]
Driver = Oracle
ServerName = 192.168.1.32:1521/pdb2
UserID = zabbix
Password = zabbix
Port= 1521
EOF
[root@jeames ~]# isql -v ora19c
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
注:sqlplus 用户名/密码@IP/oracle数据库服务名 #如sqlplus zbbix/zbbix@IP:1521/cdb1
1.模板另存
配置-模板-Oracle by ODB-全克隆,此处另存为Oracle by ODBC 19C,点击应用户
2.配置主机
1)配置-主机-创建主机-选择模板Oracle by ODBC 19C
2)宏的地方做如下创建
{$ORACLE.DRIVER} Oracle
{$ORACLE.PASSWORD} zabbix
{$ORACLE.PORT} 1521
{$ORACLE.SERVICE} pdb2
{$ORACLE.USER} zabbix
{$HOST.CONN} 192.168.1.32