zabbix ODBC 数据库监控
ODBC 是 C 语言开发的、用于访问数据库的中间件接口.zabbix 支持查询任何 ODBC 支持的数据库.zabbix 经过调用 ODBC 来获取数据库的数据以及数据库状态等等信息
一、安装unixODBC
官方主页:http://www.unixodbc.org/download.html
使用阿里巴巴提供的开源镜像站:https://opsx.alibaba.com/?lang=zh-CNapi
[root@zabbix-server ~]# wget https://rpmfind.net/linux/centos-stream/9-stream/CRB/x86_64/os/Packages/unixODBC-devel-2.3.9-4.el9.x86_64.rpm
--2022-12-09 15:06:45-- https://rpmfind.net/linux/centos-stream/9-stream/CRB/x86_64/os/Packages/unixODBC-devel-2.3.9-4.el9.x86_64.rpm
正在解析主机 rpmfind.net (rpmfind.net)... 195.220.108.108
正在连接 rpmfind.net (rpmfind.net)|195.220.108.108|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:54942 (54K) [application/x-rpm]
正在保存至: “unixODBC-devel-2.3.9-4.el9.x86_64.rpm”
unixODBC-devel-2.3.9-4.el9.x 100%[=============================================>] 53.65K 100KB/s 用时 0.5s
2022-12-09 15:06:47 (100 KB/s) - 已保存 “unixODBC-devel-2.3.9-4.el9.x86_64.rpm” [54942/54942])
[root@zabbix-server ~]# wget https://rpmfind.net/linux/centos-stream/9-stream/AppStream/x86_64/os/Packages/unixODBC-2.3.9-4.el9.x86_64.rpm
--2022-12-09 15:07:13-- https://rpmfind.net/linux/centos-stream/9-stream/AppStream/x86_64/os/Packages/unixODBC-2.3.9-4.el9.x86_64.rpm
正在解析主机 rpmfind.net (rpmfind.net)... 195.220.108.108
正在连接 rpmfind.net (rpmfind.net)|195.220.108.108|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:503092 (491K) [application/x-rpm]
正在保存至: “unixODBC-2.3.9-4.el9.x86_64.rpm”
unixODBC-2.3.9-4.el9.x86_64. 100%[=============================================>] 491.30K 153KB/s 用时 3.2s
2022-12-09 15:07:18 (153 KB/s) - 已保存 “unixODBC-2.3.9-4.el9.x86_64.rpm” [503092/503092])
[root@zabbix-server ~]# ll
总用量 2556
-rw-------. 1 root root 819 12月 6 10:24 anaconda-ks.cfg
drwxr-xr-x 3 root root 17 12月 8 12:21 go
-rw-r--r-- 1 root root 503092 8月 13 2021 unixODBC-2.3.9-4.el9.x86_64.rpm
-rw-r--r-- 1 root root 54942 8月 13 2021 unixODBC-devel-2.3.9-4.el9.x86_64.rpm
[root@zabbix-server ~]# yum -y install unixODBC-2.3.9-4.el9.x86_64.rpm
上次元数据过期检查:2:34:00 前,执行于 2022年12月09日 星期五 12时34分12秒。
依赖关系解决。
===================================================================================================================
软件包 架构 版本 仓库 大小
===================================================================================================================
安装:
unixODBC x86_64 2.3.9-4.el9 @commandline 491 k
事务概要
===================================================================================================================
安装 1 软件包
总计:491 k
安装大小:1.4 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : unixODBC-2.3.9-4.el9.x86_64 1/1
运行脚本: unixODBC-2.3.9-4.el9.x86_64 1/1
验证 : unixODBC-2.3.9-4.el9.x86_64 1/1
已安装:
unixODBC-2.3.9-4.el9.x86_64
完毕!
[root@zabbix-server ~]# yum -y install unixODBC-devel-2.3.9-4.el9.x86_64.rpm
上次元数据过期检查:2:34:28 前,执行于 2022年12月09日 星期五 12时34分12秒。
依赖关系解决。
===================================================================================================================
软件包 架构 版本 仓库 大小
===================================================================================================================
安装:
unixODBC-devel x86_64 2.3.9-4.el9 @commandline 54 k
事务概要
===================================================================================================================
安装 1 软件包
总计:54 k
安装大小:208 k
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : unixODBC-devel-2.3.9-4.el9.x86_64 1/1
运行脚本: unixODBC-devel-2.3.9-4.el9.x86_64 1/1
验证 : unixODBC-devel-2.3.9-4.el9.x86_64 1/1
已安装:
unixODBC-devel-2.3.9-4.el9.x86_64
完毕!
二、安装Oracle-instantclient
[root@zabbix-server ~]# mkdir -p /opt/oracle
[root@zabbix-server ~]# cd /opt/oracle/
[root@zabbix-server oracle]# 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
--2022-12-09 15:13:59-- https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-basic-21.3.0.0.0-1.x86_64.rpm
正在解析主机 download.oracle.com (download.oracle.com)... 104.97.44.84
正在连接 download.oracle.com (download.oracle.com)|104.97.44.84|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:56417260 (54M) [application/x-redhat-package-manager]
正在保存至: “oracle-instantclient-basic-21.3.0.0.0-1.x86_64.rpm”
oracle-instantclient-basic-2 100%[=============================================>] 53.80M 2.97MB/s 用时 17s
2022-12-09 15:14:17 (3.16 MB/s) - 已保存 “oracle-instantclient-basic-21.3.0.0.0-1.x86_64.rpm” [56417260/56417260])
--2022-12-09 15:14:17-- https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64.rpm
正在解析主机 download.oracle.com (download.oracle.com)... 104.97.44.84
正在连接 download.oracle.com (download.oracle.com)|104.97.44.84|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:721792 (705K) [application/x-redhat-package-manager]
正在保存至: “oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64.rpm”
oracle-instantclient-sqlplus 100%[=============================================>] 704.88K 161KB/s 用时 4.4s
2022-12-09 15:14:23 (161 KB/s) - 已保存 “oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64.rpm” [721792/721792])
--2022-12-09 15:14:23-- https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-devel-21.3.0.0.0-1.x86_64.rpm
正在解析主机 download.oracle.com (download.oracle.com)... 104.97.44.84
正在连接 download.oracle.com (download.oracle.com)|104.97.44.84|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:669192 (654K) [application/x-redhat-package-manager]
正在保存至: “oracle-instantclient-devel-21.3.0.0.0-1.x86_64.rpm”
oracle-instantclient-devel-2 100%[=============================================>] 653.51K 435KB/s 用时 1.5s
2022-12-09 15:14:25 (435 KB/s) - 已保存 “oracle-instantclient-devel-21.3.0.0.0-1.x86_64.rpm” [669192/669192])
--2022-12-09 15:14:25-- https://download.oracle.com/otn_software/linux/instantclient/213000/oracle-instantclient-odbc-21.3.0.0.0-1.x86_64.rpm
正在解析主机 download.oracle.com (download.oracle.com)... 104.97.44.84
正在连接 download.oracle.com (download.oracle.com)|104.97.44.84|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:247684 (242K) [application/x-redhat-package-manager]
正在保存至: “oracle-instantclient-odbc-21.3.0.0.0-1.x86_64.rpm”
oracle-instantclient-odbc-21 100%[=============================================>] 241.88K 207KB/s 用时 1.2s
2022-12-09 15:14:28 (207 KB/s) - 已保存 “oracle-instantclient-odbc-21.3.0.0.0-1.x86_64.rpm” [247684/247684])
[root@zabbix-server oracle]# ll
总用量 56704
-rw-r--r-- 1 root root 56417260 8月 10 2021 oracle-instantclient-basic-21.3.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root 669192 8月 10 2021 oracle-instantclient-devel-21.3.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root 247684 8月 10 2021 oracle-instantclient-odbc-21.3.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root 721792 8月 10 2021 oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64.rpm
安装oracle-instantclient
[root@zabbix-server oracle]# yum localinstall oracle-instantclient-*
上次元数据过期检查:2:42:58 前,执行于 2022年12月09日 星期五 12时34分12秒。
依赖关系解决。
===================================================================================================================
软件包 架构 版本 仓库 大小
===================================================================================================================
安装:
oracle-instantclient-basic x86_64 21.3.0.0.0-1 @commandline 54 M
oracle-instantclient-devel x86_64 21.3.0.0.0-1 @commandline 654 k
oracle-instantclient-odbc x86_64 21.3.0.0.0-1 @commandline 242 k
oracle-instantclient-sqlplus x86_64 21.3.0.0.0-1 @commandline 705 k
事务概要
===================================================================================================================
安装 4 软件包
总计:55 M
安装大小:244 M
确定吗?[y/N]: y
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : oracle-instantclient-basic-21.3.0.0.0-1.x86_64 1/4
运行脚本: oracle-instantclient-basic-21.3.0.0.0-1.x86_64 1/4
安装 : oracle-instantclient-devel-21.3.0.0.0-1.x86_64 2/4
安装 : oracle-instantclient-odbc-21.3.0.0.0-1.x86_64 3/4
安装 : oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64 4/4
运行脚本: oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64 4/4
验证 : oracle-instantclient-basic-21.3.0.0.0-1.x86_64 1/4
验证 : oracle-instantclient-devel-21.3.0.0.0-1.x86_64 2/4
验证 : oracle-instantclient-odbc-21.3.0.0.0-1.x86_64 3/4
验证 : oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64 4/4
已安装:
oracle-instantclient-basic-21.3.0.0.0-1.x86_64 oracle-instantclient-devel-21.3.0.0.0-1.x86_64
oracle-instantclient-odbc-21.3.0.0.0-1.x86_64 oracle-instantclient-sqlplus-21.3.0.0.0-1.x86_64
完毕!
oracle-instantclient的安装位置如下
/usr/lib/oracle/21/client64
/usr/share/oracle/21/client64
/usr/include/oracle/21/client64
[root@zabbix-server oracle]# ll /usr/lib/oracle/21/client64/
总用量 4
drwxr-xr-x 2 root root 74 12月 9 15:17 bin
drwxr-xr-x 3 root root 4096 12月 9 15:17 lib
[root@zabbix-server oracle]# ll /usr/share/oracle/21/client64/
总用量 0
drwxr-xr-x 2 root root 27 12月 9 15:17 admin
drwxr-xr-x 2 root root 192 12月 9 15:17 demo
drwxr-xr-x 2 root root 168 12月 9 15:17 doc
[root@zabbix-server oracle]# ll /usr/include/oracle/21/client64/
总用量 2044
-rw-r--r-- 1 root root 118740 7月 27 2021 jzndom.h
-rw-r--r-- 1 root root 19577 7月 27 2021 jznerr.h
-rw-r--r-- 1 root root 68907 7月 27 2021 jznev.h
-rw-r--r-- 1 root root 584 7月 27 2021 jznotn.h
-rw-r--r-- 1 root root 17951 7月 27 2021 jzntypes.h
-rw-r--r-- 1 root root 43577 7月 27 2021 ldap.h
-rw-r--r-- 1 root root 40071 7月 27 2021 nzerror.h
-rw-r--r-- 1 root root 82507 7月 27 2021 nzt.h
-rw-r--r-- 1 root root 11649 7月 27 2021 occiAQ.h
-rw-r--r-- 1 root root 35604 7月 27 2021 occiCommon.h
-rw-r--r-- 1 root root 72752 7月 27 2021 occiControl.h
-rw-r--r-- 1 root root 40153 7月 27 2021 occiData.h
-rw-r--r-- 1 root root 2115 7月 27 2021 occi.h
-rw-r--r-- 1 root root 24778 7月 27 2021 occiObjects.h
-rw-r--r-- 1 root root 7203 7月 27 2021 oci1.h
-rw-r--r-- 1 root root 10361 7月 27 2021 oci8dp.h
-rw-r--r-- 1 root root 469360 7月 27 2021 ociap.h
-rw-r--r-- 1 root root 6204 7月 27 2021 ociapr.h
-rw-r--r-- 1 root root 43001 7月 27 2021 ocidef.h
-rw-r--r-- 1 root root 4048 7月 27 2021 ocidem.h
-rw-r--r-- 1 root root 11913 7月 27 2021 ocidfn.h
-rw-r--r-- 1 root root 8953 7月 27 2021 ociextp.h
-rw-r--r-- 1 root root 231384 7月 27 2021 oci.h
-rw-r--r-- 1 root root 25022 7月 27 2021 ocijson.h
-rw-r--r-- 1 root root 6494 7月 27 2021 ocikpr.h
-rw-r--r-- 1 root root 509 7月 27 2021 ociver.h
-rw-r--r-- 1 root root 8138 7月 27 2021 ocixmldb.h
-rw-r--r-- 1 root root 111837 7月 27 2021 ocixstream.h
-rw-r--r-- 1 root root 36027 7月 27 2021 odci.h
-rw-r--r-- 1 root root 326 7月 27 2021 orajson.h
-rw-r--r-- 1 root root 6606 7月 27 2021 oratypes.h
-rw-r--r-- 1 root root 15083 7月 27 2021 orid.h
-rw-r--r-- 1 root root 102775 7月 27 2021 ori.h
-rw-r--r-- 1 root root 161370 7月 27 2021 orl.h
-rw-r--r-- 1 root root 43126 7月 27 2021 oro.h
-rw-r--r-- 1 root root 123766 7月 27 2021 ort.h
-rw-r--r-- 1 root root 9892 7月 27 2021 xa.h
配置SQLPlus连接直接通过下面的命令安装 oracle-instantclient创建 network/admin 文件夹
## zabbix-server端配置
[root@zabbix-server oracle]# mkdir -p /usr/lib/oracle/21/client64/network/admin/
[root@zabbix-server oracle]# cd /usr/lib/oracle/21/client64/network/admin/
[root@zabbix-server admin]# cat tnsnames.ora
testdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.111.139 )(PORT = 1521 ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE = DEDICATED)
(SERVICE_NAME = testdb)
)
)
##数据库端创建监控用户
SQL> set linesize 300
set pagesize 300
col USERNAME for a30
col DEFAULT_TABLESPACE for a30
col TEMPORARY_TABLESPACE for a20
col account_status for a20
select username,account_status,DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE from dba_users where username='DBSNMP';
USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
------------------------------ -------------------- ------------------------------ --------------------
DBSNMP EXPIRED & LOCKED SYSAUX TEMP
SQL> alter user DBSNMP identified by "test_2022";
User altered.
SQL> alter user DBSNMP account unlock;
User altered.
### zabbix-server端连接
[root@zabbix-server admin]# sqlplus dbsnmp/test_2022@ip:port/testdb
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Dec 9 15:53:54 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
环境变量配置
cat /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
export ORACLE_SID=
保存后适用新的环境变量
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
添加Oracle 驱动,其他不做修改
[root@zabbix-server ~]# cat /etc/odbcinst.ini
# Example driver definitions
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/psqlodbcw.so
Setup = /usr/lib/libodbcpsqlS.so
Driver64 = /usr/lib64/psqlodbcw.so
Setup64 = /usr/lib64/libodbcpsqlS.so
FileUsage = 1
# Driver from the mysql-connector-odbc package in Fedora >=29
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL 8
# mysql-connector-odbc package provides shared libraries with "w" or "a" suffix.
# 'w' stands for 'wide' or 'unicode' character set, 'a' stands for 'ANSI'
# Symlinks used in the configuration below lead to the 'w' variant by default
Driver = /usr/lib/libmyodbc8.so
Driver64 = /usr/lib64/libmyodbc8.so
FileUsage = 1
# Driver from the mysql-connector-odbc package in Fedora <=28
# Setup from the unixODBC package
[MySQL-5]
Description = ODBC for MySQL 5
# mysql-connector-odbc package provides shared libraries with "w" or "a" suffix.
# 'w' stands for 'wide' or 'unicode' character set, 'a' stands for 'ANSI'
# Symlinks used in the configuration below lead to the 'w' variant by default
Driver = /usr/lib/libmyodbc5.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
# Driver from the freetds-libs package
# Setup from the unixODBC package
[FreeTDS]
Description = Free Sybase & MS SQL Driver
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/libtdsS.so
Driver64 = /usr/lib64/libtdsodbc.so
Setup64 = /usr/lib64/libtdsS.so
Port = 1433
# Driver from the mariadb-connector-odbc package
# Setup from the unixODBC package
[MariaDB]
Description = ODBC for MariaDB
Driver = /usr/lib/libmaodbc.so
Driver64 = /usr/lib64/libmaodbc.so
FileUsage = 1
[root@zabbix-server ~]# vim /etc/odbcinst.ini
[root@zabbix-server ~]# cat /etc/odbcinst.ini
# Example driver definitions
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/psqlodbcw.so
Setup = /usr/lib/libodbcpsqlS.so
Driver64 = /usr/lib64/psqlodbcw.so
Setup64 = /usr/lib64/libodbcpsqlS.so
FileUsage = 1
# Driver from the mysql-connector-odbc package in Fedora >=29
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL 8
# mysql-connector-odbc package provides shared libraries with "w" or "a" suffix.
# 'w' stands for 'wide' or 'unicode' character set, 'a' stands for 'ANSI'
# Symlinks used in the configuration below lead to the 'w' variant by default
Driver = /usr/lib/libmyodbc8.so
Driver64 = /usr/lib64/libmyodbc8.so
FileUsage = 1
# Driver from the mysql-connector-odbc package in Fedora <=28
# Setup from the unixODBC package
[MySQL-5]
Description = ODBC for MySQL 5
# mysql-connector-odbc package provides shared libraries with "w" or "a" suffix.
# 'w' stands for 'wide' or 'unicode' character set, 'a' stands for 'ANSI'
# Symlinks used in the configuration below lead to the 'w' variant by default
Driver = /usr/lib/libmyodbc5.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
# Driver from the freetds-libs package
# Setup from the unixODBC package
[FreeTDS]
Description = Free Sybase & MS SQL Driver
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/libtdsS.so
Driver64 = /usr/lib64/libtdsodbc.so
Setup64 = /usr/lib64/libtdsS.so
Port = 1433
# Driver from the mariadb-connector-odbc package
# Setup from the unixODBC package
[MariaDB]
Description = ODBC for MariaDB
Driver = /usr/lib/libmaodbc.so
Driver64 = /usr/lib64/libmaodbc.so
FileUsage = 1
########### oralce ################
[Oracle]
Description = ODBC for Oracle
Driver = /usr/lib/oracle/21/client64/lib/libsqora.so.21.1
[root@zabbix-server ~]#
添加Oracle数据源
[root@zabbix-server ~]# cat /etc/odbc.ini
[TESTDB]
Driver = Oracle
DSN = TESTDB
ServerName = 192.168.111.139:1521/testdb
UserID = DBSNMP
Password = test_2022
ISQL 测试
[root@zabbix-server ~]# isql -v TESTDB
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
版本信息
[root@zabbix-server ]# odbcinst -j
unixODBC 2.3.9
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
创建用于监控的专用账号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;
三、数据库端安装zabbix-agent
[root@oracle ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
本次zabbix-agent版本为:Zabbix agent v6.0.3
[root@oracle ~]# rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/7/x86_64/zabbix-release-6.2-3.el7.noarch.rpm
获取https://repo.zabbix.com/zabbix/6.2/rhel/7/x86_64/zabbix-release-6.2-3.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.iVoL5j: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-6.2-3.el7 ################################# [100%]
[root@oracle ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates zabbix zabbix-agent2-plugins zabbix-non-supported
Cleaning up list of fastest mirrors
[root@oracle ~]# yum install zabbix-agent
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.ustc.edu.cn
* extras: mirrors.cqu.edu.cn
* updates: mirrors.cqu.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-agent2-plugins | 2.9 kB 00:00:00
zabbix-non-supported | 2.9 kB 00:00:00
(1/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/7): extras/7/x86_64/primary_db | 249 kB 00:00:00
(3/7): zabbix-agent2-plugins/x86_64/primary_db | 2.9 kB 00:00:01
(4/7): zabbix-non-supported/x86_64/primary_db | 3.7 kB 00:00:01
(5/7): base/7/x86_64/primary_db | 6.1 MB 00:00:02
(6/7): zabbix/x86_64/primary_db | 44 kB 00:00:03
(7/7): updates/7/x86_64/primary_db | 18 MB 00:00:04
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-agent.x86_64.0.6.2.6-release1.el7 将被 安装
--> 正在处理依赖关系 libpcre2-8.so.0()(64bit),它被软件包 zabbix-agent-6.2.6-release1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 pcre2.x86_64.0.10.23-2.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================
Package 架构 版本 源 大小
==================================================================================================
正在安装:
zabbix-agent x86_64 6.2.6-release1.el7 zabbix 533 k
为依赖而安装:
pcre2 x86_64 10.23-2.el7 base 201 k
事务概要
==================================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:734 k
安装大小:2.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): pcre2-10.23-2.el7.x86_64.rpm | 201 kB 00:00:00
warning: /var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-6.2.6-release1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
zabbix-agent-6.2.6-release1.el7.x86_64.rpm 的公钥尚未安装
(2/2): zabbix-agent-6.2.6-release1.el7.x86_64.rpm | 533 kB 00:00:05
--------------------------------------------------------------------------------------------------
总计 131 kB/s | 734 kB 00:00:05
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 检索密钥
导入 GPG key 0xA14FE591:
用户ID : "Zabbix LLC <packager@zabbix.com>"
指纹 : a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
软件包 : zabbix-release-6.2-3.el7.noarch (installed)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : pcre2-10.23-2.el7.x86_64 1/2
正在安装 : zabbix-agent-6.2.6-release1.el7.x86_64 2/2
验证中 : zabbix-agent-6.2.6-release1.el7.x86_64 1/2
验证中 : pcre2-10.23-2.el7.x86_64 2/2
已安装:
zabbix-agent.x86_64 0:6.2.6-release1.el7
作为依赖被安装:
pcre2.x86_64 0:10.23-2.el7
完毕!
[root@oracle ~]# find / -name "zabbix_agentd.conf"
/etc/zabbix/zabbix_agentd.conf
[root@oracle ~]# cat /etc/zabbix/zabbix_agentd.conf
PidFile=/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.111.137
ServerActive=192.168.111.137
Hostname=zabbix-server
UnsafeUserParameters=1
Include=/etc/zabbix/zabbix_agentd.d/*.conf
#####启动zabbix-agent
[root@oracle zabbix]# systemctl start zabbix-agent
[root@oracle zabbix]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@oracle zabbix]# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2022-12-09 17:19:31 CST; 12s ago
Main PID: 43123 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─43123 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─43124 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─43125 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─43126 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─43127 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─43128 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
12月 09 17:19:31 oracle systemd[1]: Starting Zabbix Agent...
12月 09 17:19:31 oracle systemd[1]: Started Zabbix Agent.
[root@oracle zabbix]#
确认zabbix服务端的10051端口 和 zabbix客户端的10050端口是否能通信
[root@oracle zabbix]# telnet ip 10051
[root@zabbix-server]# telnet ip 10050
四、在zabbix页面上添加主机监控
模板选择 Oracle By ODBC
宏配置中添加
{$ORACLE.DSN}
{$ORACLE.USER}
{$ORACLE.PASSWORD}
{$ORACLE.PORT}
三项即可
监控效果