当前位置:网站首页>Perfect guide | how to use ODBC for agent free Oracle database monitoring?
Perfect guide | how to use ODBC for agent free Oracle database monitoring?
2022-07-27 13:19:00 【Hua Weiyun】
Zhang Woo |Zabbix Senior Certified Expert ZCP
Zabbix5.0、6.0 The official translator of the Chinese manual
Do you know Zabbix There is one for collecting Oracle Out of the box template for database indicators ?
Use this template , We can use ODBC Collect databases without agents 、 Table space 、ASM And many other indicators . This article will guide you on how to Oracle 11.2、12.1、18.5 or 19.2 Database server settings ODBC monitor , Will be deployment Oracle The perfect guide to database monitoring .
1. download Instant Client and SQLPlus
The commands provided apply to the following operating systems :CentOS 8、Oracle Linux 8 or Rocky Linux.
First we need to download the following package :
oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64.rpm
oracle-instantclient19.12-sqlplus-19.12.0.0.0-1.x86_64.rpm
oracle-instantclient19.12-odbc-19.12.0.0.0-1.x86_64.rpm
We download here
Oracle Instant client —— need , Establishment and Oracle Database connection SQLPlus—— We can use it to test and Oracle Database connection tool Oracle ODBC package —— Include the required ODBC Drivers and configuration scripts , To enable and Oracle Database ODBC Connect
Upload the package to Zabbix The server ( Or agent , If you want to monitor your Oracle DB) And place it in :
/tmp/oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64.rpm/tmp/oracle-instantclient19.12-sqlplus-19.12.0.0.0-1.x86_64.rpm/tmp/oracle-instantclient19.12-odbc-19.12.0.0.0-1.x86_64.rpm2. Solve the operating system dependency
install “libaio” and “libnsl” library :
dnf -y install libaio-devel libnslotherwise , We will receive errors :
# rpm -ivh /tmp/oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64.rpmerror: Failed dependencies: libaio is needed by oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64 libnsl.so.1()(64bit) is needed by oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64# rpm -ivh /tmp/oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64.rpmerror: Failed dependencies: libnsl.so.1()(64bit) is needed by oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64Check whether it has been deployed on the system before Oracle Components . The following command should provide an empty output :
rpm -qa | grep oracleldconfig -p | grep oracle3. install Oracle client
rpm -ivh /tmp/oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64.rpmMake sure the package is installed “oracle-instantclient19.12-basic-19.12.0.0.0-1.x86_64”:
rpm -qa | grep oracle4.LD To configure
git.zabbix.com On the official Oracle The template page discusses configuring for services Oracle ENV Usage Methods . For this instant client version 19.12, This is No REQUIRED Build “ Of / etc / SYSCONFIG / ZABBIX The server ” Content file :
export ORACLE_HOME=/usr/lib/oracle/19.12/client64export PATH=$PATH:$ORACLE_HOME/binexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:/usr/lib:$ORACLE_HOME/binexport TNS_ADMIN=$ORACLE_HOME/network/adminAlthough we did install rpm package , but Oracle 19.12 The client package is indeed automatically configured at the global level LD route —— This means that every user on the system can use Oracle Instant client . We can see LD The path has been configured in :
cat /etc/ld.so.conf.d/oracle-instantclient.confShow results :
/usr/lib/oracle/19.12/client64/libTo ensure that the operating system recognizes Oracle library , We can run :
ldconfig -p | grep oracleCorrect display :
liboramysql19.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/liboramysql19.solibocijdbc19.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libocijdbc19.solibociei.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libociei.solibocci.so.19.1 (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libocci.so.19.1libnnz19.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libnnz19.solibmql1.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libmql1.solibipc1.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libipc1.solibclntshcore.so.19.1 (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libclntshcore.so.19.1libclntshcore.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libclntshcore.solibclntsh.so.19.1 (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libclntsh.so.19.1libclntsh.so (libc6,x86-64) => /usr/lib/oracle/19.12/client64/lib/libclntsh.so** Be careful :** If for some reason ldconfig The command displays links to other dynamic libraries - That's what we may have to do for Zabbix The server / Agents create separate ENV file , It will Zabbix The application links to the correct dynamic library , As the example shows, the beginning of this section .
5. Check Oracle Whether the service port can reach
Save us some trouble in the future , First check and Oracle Network connection of database host . Check whether the default... Can be accessed at the network level Oracle port . In this case , We will try to connect to the default Oracle Database port 1521. According to your Oracle The database is listening on the connected port , Adjust accordingly . Make sure the output shows “ Connected to 10.1.10.15:1521”:
nc -zv 10.1.10.15 15216. Test and SQLPlus The connection of
Continuing ODBC Before configuration , We can simulate with Oracle Database connection . Make sure that Oracle The user name and password are correct . For this task , We need to install... First SQLPlus package .:
rpm -ivh /tmp/oracle-instantclient19.12-sqlplus-19.12.0.0.0-1.x86_64.rpmTo simulate the connection , We can use single line commands . In the example command , Use my user name “system” And password “oracle” Through the port “1521” visit Oracle database server “10.1.10.15” And connect to the service name “xe”:
sqlplus64 'system/[email protected](DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.10.15)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xe)))'In the output, we can see : We use 19.12 The client connects to 11.2 The server :
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Sep 6 13:47:36 2021Version 19.12.0.0.0Copyright (c) 1982, 2021, Oracle. All rights reserved.Connected to:Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production** Be careful :** This provides us with information about Oracle Additional tips for instant clients —— The new version of the client is backward compatible with the old version Oracle database server . Although this does not apply to Oracle client / Each version of the server , But please check first Oracle Instant client documentation .
7.ODBC The connector
When it comes to configuration ODBC, Let's install ODBC Drive manager
dnf -y install unixODBCNow we can see that we have two new documents ——“/etc/odbc.ini”( It could be empty ) and “/etc/odbcinst.ini”. file “/etc/odbcinst.ini” Describes the driver relationship . at present , When we 'grep' keyword 'oracle' There was no installation oracle Relationship , When we run, the output is empty :
grep -i oracle /etc/odbcinst.iniOur next step is to install Oracle ODBC Driver package :
rpm -ivh /tmp/oracle-instantclient19.12-odbc-19.12.0.0.0-1.x86_64.rpm'oracle-instantclient*-odbc' The package contains a script , Will automatically update '/etc/odbcinst.ini' To configure :
cd /usr/lib/oracle/19.12/client64/bin./odbc_update_ini.sh / /usr/lib/oracle/19.12/client64/libShow results :
*** ODBCINI environment variable not set,defaulting it to HOME directory!Now when we print documents on the screen :
cat /etc/odbcinst.iniWe will see that Oracle 19 ODBC Drive part :
[Oracle 19 ODBC driver]Description = Oracle ODBC driver for Oracle 19Driver = /usr/lib/oracle/19.12/client64/lib/libsqora.so.19.1Setup =FileUsage =CPTimeout =CPReuse =In execution “ldd” On command , It is important to check whether there are no errors in the output . This ensures that dependencies are satisfied and accessible , And there is no conflict with library version control :
ldd /usr/lib/oracle/19.12/client64/lib/libsqora.so.19.1It will print something similar :
linux-vdso.so.1 (0x00007fff121b5000)libdl.so.2 => /lib64/libdl.so.2 (0x00007fb18601c000)libm.so.6 => /lib64/libm.so.6 (0x00007fb185c9a000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb185a7a000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fb185861000)librt.so.1 => /lib64/librt.so.1 (0x00007fb185659000)libaio.so.1 => /lib64/libaio.so.1 (0x00007fb185456000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fb18523f000)libclntsh.so.19.1 => /usr/lib/oracle/19.12/client64/lib/libclntsh.so.19.1 (0x00007fb1810e6000)libclntshcore.so.19.1 => /usr/lib/oracle/19.12/client64/lib/libclntshcore.so.19.1 (0x00007fb180b42000)libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007fb18092c000)libc.so.6 => /lib64/libc.so.6 (0x00007fb180567000)/lib64/ld-linux-x86-64.so.2 (0x00007fb1864da000)libnnz19.so => /usr/lib/oracle/19.12/client64/lib/libnnz19.so (0x00007fb17fdba000)libltdl.so.7 => /lib64/libltdl.so.7 (0x00007fb17fbb0000)When we execute “odbc_update_ini.sh” Script time , stay “/root/.odbc.ini” Created a new DSN( Data source name ) file . This is an example configuration ODBC The configuration file , It describes this version of ODBC What settings does the driver support .
Let's move this configuration file from the user directory to a system wide accessible location :
cat /root/.odbc.ini | sudo tee -a /etc/odbc.iniAnd completely delete the file from the user directory :
rm /root/.odbc.inisuch , Every user in the system will only use this ODBC The configuration file . We can now change the existing configuration – /etc/odbc.ini. I want to highlight what has changed from the default :
[Oracle11g]AggregateSQLType = FLOATApplication Attributes = TAttributes = WBatchAutocommitMode = IfAllSuccessfulBindAsFLOAT = FCacheBufferSize = 20CloseCursor = FDisableDPM = FDisableMTS = TDisableRULEHint = TDriver = Oracle 19 ODBC driverDSN = Oracle11gEXECSchemaOpt =EXECSyntax = TFailover = TFailoverDelay = 10FailoverRetryCount = 10FetchBufferSize = 64000ForceWCHAR = FLobPrefetchSize = 8192Lobs = TLongs = TMaxLargeData = 0MaxTokenSize = 8192MetadataIdDefault = FQueryTimeout = TResultSets = TServerName = //10.1.10.15:1521/xeSQLGetData extensions = FSQLTranslateErrors = FStatementCache = FTranslation DLL =Translation Option = 0UseOCIDescribeAny = FUserID = systemPassword = oracleDSN – Data source name . It should match the partial names in parentheses , for example :[Oracle11g] ServerName – Oracle Server address UserID – Oracle user name Password – Oracle User password
To test the connection from the command line , Let's use isql Command line tools , The tool should simulate ODBC Connect , Be similar to Zabbix The operation being performed when collecting indicators :
isql -v Oracle11gIn this example isql Command from the odbc.ini Select... From the file ODBC Set up ( user name 、 password 、 Server address ). All we have to do is quote specific DSN – Oracle11g
On the other hand , If we don't want to be in the file system (/etc/odbc.ini) Keep password on , We can delete “UserID” and “Password” That's ok . Then we can test ODBC Connect :
isql -v Oracle11g 'system' 'oracle'If the connection is successful , It should print : This is it. ODBC To configure ! Now we should be able to Zabbix Application in Oracle by ODBC The template
+---------------------------------------+| Connected! || || sql-statement || help [tablename] || quit || |+---------------------------------------+SQL>
Don't forget it , We also need to provide the necessary Oracle Vouchers to start collecting Oracle Database metrics :

边栏推荐
- PySide6/PyQt开发经验总结(2) - 设置快捷键
- Antd's tool function getprefixcls gets the public prefix
- Jesd204b debugging notes (practical version)
- Poj1548 robots [bipartite graph minimum path coverage]
- Application parameters of Southern biotech HRP labeled avidin avidin avidin
- 力扣 1480. 一维数组的动态和 383. 赎金信412. Fizz Buzz
- 分布式系统架构理论与组件
- [Nuxt 3] (十二) 项目目录结构 2
- 固定定位
- 高度塌陷和BFC
猜你喜欢

文章复现:SRCNN

v-on基础指令

@Simple understanding and use of conditionalonproperty

Eccv2022 | Ru & Google proposed to use clip for zero shot target detection!

From the perspective of it, the CIO of B2B industry talks about how to change from "cost center" to "growth center"?

Article reproduction: srcnn

Initializing database error after reinstalling MySQL

Summary of common methods of ArrayList

Zhongke Lanxun fell 30% on the first day of listing: Huang Zhiqiang, 60, started a company with a market value of 7.7 billion

字节跳动的 Flink OLAP 作业调度和查询执行优化实践
随机推荐
What should I do if I can't see any tiles on SAP Fiori launchpad?
Seata's landing practice in ant International Banking
银行案例|Zabbix跨版本升级指南,4.2-6.0不香吗?
JS true / false array conversion
js真伪数组转换
图标字体
PySide6/PyQt开发经验总结(2) - 设置快捷键
v-on基础指令
Distributed system architecture theory and components
Gartner 权威预测未来4年网络安全的8大发展趋势
500强企业如何提升研发效能?来看看行业专家怎么说!
Plus SBOM: assembly line BOM pbom
从tidb实时同步到mysql 只能用 tidb binlog 工具吗?
PG synchronizes multiple data tables to MySQL. Is there a way to simplify the configuration?
Initializing database error after reinstalling MySQL
延迟队列DelayQueue性能测试
一款能模糊的地方都能模糊的测试工具——Wfuzz
7-16 daily sword finger offer II 041. Average value of sliding window
Firefox 103 发布,更快、更安全
v-text