orabbix监控oracle

时间:2021-11-11 11:44:20

Orabbix 是一个用来监控 Oracle 数据库实例的 Zabbix 插件。下载地址:

http://www.smartmarmot.com/product/orabbix/download/

Orabbix插件的安装与配置

确保安装jdk环境,java version查看,没有则通过yum来安装JAVA:yum install java

 1.在/opt目录下新建一个orabbix目录:

[root@oracle orabbix]#mkdir -p /opt/orabbix

(建议在此目录下,如果放置其他目录稍后需要更改orabbix的启动文件orabbix,启动文件默认写在opt/orabbix目录下 )

 2. 解压安装文件

[root@oracle orabbix]#unzip orabbix-1.2.3.zip

3.赋予权限

[root@oracle orabbix]# chmod -R a+x orabbix/

4 通过/opt/orabbix/conf/config.props.sample文件创建一个config.props文件:

[root@oracle orabbix]#cp/opt/orabbix/conf/config.props.sample /opt/orabbix/conf/config.props

5.  编辑orabbix配置文件,具体如下

[root@oracle orabbix]#vi confi/config.props

#comma separed list of Zabbix servers
#ZabbixServerList=ZabbixServer1,ZabbixServer2
ZabbixServerList=ZabbixServer1
#(zabbixserver的名字,下行中address和port都引用到了这个名字,所以下面两行的前缀名字要与这里的名字保持一致)
#ZabbixServer1.Address=IP_ADDRESS_OF_ZABBIX_SERVER
ZabbixServer1.Address=192.168.3.163
#ZabbixServer1.Port=PORT_OF_ZABBIX_SERVER
ZabbixServer1.Port=10051
#ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER
#ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER
#pidFile
OrabbixDaemon.PidFile=./logs/orabbix.pid
#frequency of item's refresh
OrabbixDaemon.Sleep=300
#MaxThreadNumber should be >= than the number of your databases
OrabbixDaemon.MaxThreadNumber=100
#put here your databases in a comma separated list
#DatabaseList=DB1,DB2,DB3
DatabaseList=DB_QM (DB名称,可随意定义,但要与下文保持一致,切记要与监控的主机名称保持一致)
#Configuration of Connection pool
#if not specified Orabbis is going to use default values (hardcoded)
#Maximum number of active connection inside pool
DatabaseList.MaxActive=10
#The maximum number of milliseconds that the pool will wait
#(when there are no available connections) for a connection to be returned
#before throwing an exception, or <= 0 to wait indefinitely.
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1
#define here your connection string for each database
#DB1.Url=jdbc:oracle:thin:@server.domain.example.com:<LISTENER_PORT>:DB1
DB_QM.Url=jdbc:oracle:thin:@192.168.3.250:1521:qmeas
#确保有jdk环境,因为这里是通过JDBC连接的
#DB1.User=zabbix
DB_QM.User=qm
#DB1.Password=zabbix_password
DB_QM.Password=qm
#DB的用户和密码,可创建zabbix用户,并赋予权限,如下文(这里直接用dba权限用户)
#Those values are optionals if not specified Orabbix is going to use the general values
DB_QM.MaxActive=10
DB_QM.MaxWait=100
DB_QM.MaxIdle=1
DB_QM.QueryListFile=./conf/query.props
#DB2.Url=jdbc:oracle:thin:@server2.domain.example.com:<LISTENER_PORT>:DB2
#DB2.User=zabbix
#DB2.Password=zabbix_password
#DB2.QueryListFile=./conf/query.props
#DB3.Url=jdbc:oracle:thin:@server3.domain.example.com:<LISTENER_PORT>:DB3
#DB3.User=zabbix
#DB3.Password=zabbix_password
#DB3.QueryListFile=./conf/query.props
#注释未用到的DB连接

创建zabbix用户如下步骤:

CREATE USER ZABBIX

IDENTIFIEDBY zabbix     <Password>

DEFAULTTABLESPACE SYSTEM

TEMPORARYTABLESPACE TEMP

PROFILEDEFAULT

ACCOUNTUNLOCK;

GRANT CONNECT TO ZABBIX;

GRANTRESOURCE TO ZABBIX;

ALTERUSER ZABBIX DEFAULT ROLE ALL;

GRANT SELECT ANY TABLE TO ZABBIX;

GRANT CREATE SESSION TO ZABBIX;

GRANTSELECT ANY DICTIONARY TO ZABBIX;

GRANTUNLIMITED TABLESPACE TO ZABBIX;

GRANTSELECT ANY DICTIONARY TO ZABBIX;。

Oracle 11g添加如下命令

execdbms_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;

 6.  创建执行文件(直接cp即可)

[root@oracle orabbix]# cp /opt/orabbix/init.d/orabbix/etc/init.d/orabbix

7.保存退出,启动orabbix服务(确保有执行权限)

/etc/init.d/orabbix start

Orabbix服务加入随系统启动:

chkconfig --add orabbix

chkconfig --level 345 orabbix on

 常见问题:

若config.props文件未配置,或是配置了错误,无法通过配置的信息正确连进Oracle数据库的,会出现以下错误信息

[root@zabbix orabbix]# /etc/init.d/orabbix start

Starting Orabbix service:

[root@zabbix orabbix]# Stopping

java.lang.Exception: ERROR on main - Connections is empty

atcom.smartmarmot.orabbix.Orabbixmon.run(Orabbixmon.java:101)

atcom.smartmarmot.orabbix.bootstrap.main(bootstrap.java:50)

可查看log信息判断解决

[root@oracle orabbix]# tail -f /opt/orabbix/logs/orabbix.log

到此,安装配置完成,则通过web页面访问直接导入模块即可

导入模版,模版放置在/opt/orabbix/template下
Orabbix_export_full.xml         全部导入(图表 监控项 触发器)
Orabbix_export_graphs.xml    图表
Orabbix_export_items.xml      监控项
Orabbix_export_triggers.xml   触发器

选中Orabbix_export_full.xml直接导入,则可以直接在主机中链接到模版就可以使用全部功能了(主机名称一定要与配置中的 DatabaseList=DB_QM保持一致)!

也可以再模版中找到此模版。然后将需要的信息直接cp过去,比如打开此处的监控项,把它全部复制到oracle主机下,触发器、图像显示同理!

创建图表,部分效果如下:

orabbix监控oracle