Zabbix利用Orabbix插件监控Oracle数据库(增强版)

按照网上的一些资料进行安装最后发现问题挺多的,于是自己修复了一些问题便记录了下来。

一.jdk的安装(Orabbix Server)

1.软件解压,放到固定位置

tar zxf jdk-8u51-linux-x64.tar.gz
mv jdk1.8.0_51/ /usr/local/

2.设置系统变量,编辑/etc/profile在末尾增加

export JAVA_HOME=/usr/local/jdk1.8.0_51
exportCLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

3.执行一下/etc/profile使之生效

source /etc/profile

二.Oracle中增加监控用户,并设置相应的用户权限,这一步在sqlplus中完成(ORACLE服务器)

su - oracle
sqlplus / as sysdba
SQL>CREATE USER zabbix
IDENTIFIED BY zabbix_password
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;

赋予zabbix用户对应权限

GRANT ALTER SESSION TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT CONNECT TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
GRANT SELECT ON V_$INSTANCE TO ZABBIX;
GRANT SELECT ON DBA_USERS TO ZABBIX;
GRANT SELECT ON V_$LOG_HISTORY TO ZABBIX;
GRANT SELECT ON V_$LOG TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO ZABBIX;
GRANT SELECT ON V_$LOCK TO ZABBIX;
GRANT SELECT ON DBA_REGISTRY TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$SYSSTAT TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON V_$LATCH TO ZABBIX;
GRANT SELECT ON V_$PGASTAT TO ZABBIX;
GRANT SELECT ON V_$SGASTAT TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$PROCESS TO ZABBIX;
GRANT SELECT ON DBA_DATA_FILES TO ZABBIX;
GRANT SELECT ON DBA_TEMP_FILES TO ZABBIX;
GRANT SELECT ON DBA_FREE_SPACE TO ZABBIX;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;
GRANT SELECT ON V_$locked_object TO ZABBIX;
GRANT SELECT ON dba_objects TO ZABBIX;
GRANT SELECT ON dba_tablespaces TO ZABBIX;
GRANT SELECT ON v_$session TO ZABBIX;

以上有部分小写的是我对其他文章的增加部分

如果数据库是11G,还要执行如下部分:

1
2
3 exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description=> 'resolve acl', principal =>'ZABBIX', is_grant => true, privilege => 'resolve');
exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');
commit;

三.安装orabbix(Orabbix Server)

其实orabbix只需要安装在一台服务器即可,我就选择安装在Zabbix Server上,当然上面的jdk是为orabbix服务的,因为orabbix就是一个oracle客户端去查找oracle中的数据,然后传给zabbix.

mkdir /usr/local/orabbix
cd /usr/local/orabbix
wget orabbix
unzip orabbix-1.2.3.zip
chmod +x run.sh
cp init.d/orabbix /etc/init.d/
sed -i 's#/opt/orabbix#orabbix=/usr/local/orabbix#g' /etc/init.d/orabbix
chmod +x /etc/init.d/orabbix
sed -i 's#java#/usr/local/jdk1.8.0_51/bin/java#g' /usr/local/orabbix/run.sh
#用以解决/usr/local/orabbix/run.sh: line 2: java: command not found这个错误

配置orabbix,进入/usr/local/orabbix/conf/目录

cd /usr/local/orabbix/conf

cp config.props.sample config.props

ZabbixServerList=ZabbixServer
ZabbixServer.Address=192.168.0.81
ZabbixServer.Port=10051
OrabbixDaemon.PidFile=./logs/orabbix.pid
OrabbixDaemon.Sleep=300
OrabbixDaemon.MaxThreadNumber=100
DatabaseList=tpy100
DatabaseList.MaxActive=10
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1
tpy100.Url=jdbc:oracle:thin:@192.168.0.209:1521:orcl
tpy100.User=ZABBIX
tpy100.Password=zabbix
tpy100.MaxActive=10
tpy100.MaxWait=100
tpy100.MaxIdle=1
tpy100.QueryListFile=./conf/query.props

需要注意的是DatabaseList=CRMDB指的是被监控服务器的名称,该名称要和zabbixserver界面中的机器名称保持一致,该配置文件中后续所引用的设定都以该名称为准。
CRMDB.Url=jdbc:oracle:thin:@192.168.0.209:1521:orcl 指定的是被监控服务器的连接信息(例如采用jdbc的联接方式,服务器地址是192.168.0.209,oracle的端口是1521,orcl指的是数据库的实例)

默认按照上面的步骤就差不多了,但是你导入模板之后就会发现监控项目不全,如dbsize及dbfilesize这些类目,orabbix默认情况下未开启数据库大小,需要配置query.props

编辑 /usr/local/orabbix/conf/query.props文件

在QueryList=类目下增加dbfilesize,dbsize,如图所示

Zabbix利用orabbix插件监控Oracle数据库(增强版)

然后在该文件的末尾添加

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/345831d4870fb9087f4e22b0e4aa69d9.html