zabbix利用orabbix监控oracle数据库
一.环境:
1.需要jdk7或8都可以
2.zabbix服务端上安装orabbix
3.oracle的监控要需要JAVA的支持
二.安装:
安装JAVA
准备文件:jdk-8u192-linux-x64.tar.gz
下载地址:[root@zabbix data]# wget https://wangxuejin-data-1252194948.cos.ap-shanghai.myqcloud.com/jdk-8u192-linux-x64.tar.gz
解压文件到/usr
[root@zabbix data]# tar xf jdk-8u192-linux-x64.tar.gz -C /usr/
[root@zabbix data]# vim /etc/profile
添加
#Java Env wangxuejin 2018-12-15
export JAVA_HOME=/usr/jdk1.8.0_192
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
使其生效
[root@zabbix data]# source /etc/profile
查看JAVA版本
[root@zabbix data]# java -version
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)
安装orabbix
准备文件:Orabbix-1.2.3.zip
下载地址:[root@zabbix data]# wget https://wangxuejin-data-1252194948.cos.ap-shanghai.myqcloud.com/Orabbix-1.2.3.zip
新建/opt/orabbix目录
[root@zabbix data]# mkdir /opt/orabbix
解压orabbix文件到orabbix目录
[root@zabbix data]# unzip Orabbix-1.2.3.zip -d /opt/orabbix/
进入目录并赋予脚本和services文件可执行权限
[root@zabbix data]# cd /opt/orabbix/
[root@zabbix orabbix]# mv orabbix-1.2.3/* .
[root@zabbix orabbix]# cp init.d/orabbix /etc/init.d/
[root@zabbix orabbix]# chmod a+x run.sh
[root@zabbix orabbix]# chmod a+x /etc/init.d/orabbix
三.配置
[root@zabbix orabbix]# cd conf/
[root@zabbix conf]#cp config.props.sample config config.progs
[root@zabbix conf]# vim config.props
---------------------------------------------
ZabbixServerList=ZabbixServer
ZabbixServer.Address=127.0.0.1
ZabbixServer.Port=10051
OrabbixDaemon.PidFile=./logs/orabbix.pid
OrabbixDaemon.Sleep=300
OrabbixDaemon.MaxThreadNumber=100
DatabaseList=CRMDB
DatabaseList.MaxActive=10
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1
CRMDB.Url=jdbc:oracle:thin:@172.18.1.102:1521:orcl
CRMDB.User=zabbix
CRMDB.Password=zabbix
CRMDB.MaxActive=10
CRMDB.MaxWait=100
CRMDB.MaxIdle=1
CRMDB.QueryListFile=./conf/query.prop
注:一定要注释掉不必要的参数
四.被监控的oracle上添加授权
CREATE USER ZABBIX IDENTIFIED BY "zabbix" DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;
(CREATE USER ZABBIX IDENTIFIED BY "zabbix" 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 TABLESPCE TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
###以下是oracle11g需要执行的
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;
-------------------------------
[root@zabbix conf]# vim /etc/init.d/orabbix
orabbix=/opt/orabbix
[root@zabbix orabbix]# vim run.sh
/usr/jdk1.8.0_192/bin/java -Duser.language=en -Duser.country=US -Dlog4j.configuration=./conf/log4j.properties -cp $(for i in lib/*.jar ; do echo -n $i: ; done).:./orabbix-1.2.3.jar com.smartmarmot.orabbix.bootstrap start ./conf/config.props &
五.启动orabbix并设置开机启动
[root@zabbix orabbix]# /etc/init.d/orabbix start
Starting orabbix (via systemctl): Warning: orabbix.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[ OK ]
[root@zabbix orabbix]# systemctl daemon-reload
[root@zabbix orabbix]# chkconfig --add orabbix
[root@zabbix orabbix]# chkconfig orabbix on
王学金
2018/12/25