Fork me on GitHub
Suzf  Blog

Zabbix之监控Oracle性能

License: Attribution-NonCommercial-ShareAlike 4.0 International

本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。

转载请注明:http://suzf.net/post/52

Orabbix 是一个用来监控 Oracle 数据库实例的 Zabbix 插件。

下载地址:http://www.smartmarmot.com/product/orabbix/download/

官方参考:http://www.smartmarmot.com/wiki/index.php/Orabbix

Orabbix插件的安装与配置

确保安装jdk环境,java version查看

[root@localhost ~]# java -version

java version "1.6.0_28"

OpenJDK Runtime Environment (IcedTea6 1.13.0pre) (rhel-1.66.1.13.0.el6-x86_64)

OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

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

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

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

2. 解压安装文件

unzip orabbix-1.2.3.zip -d /opt/orabbix

3. 赋予权限

chmod -R a+x orabbix/

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

cp/opt/orabbix/conf/config.props.sample /opt/orabbix/conf/config.props

5. 编辑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.Port=PORT_OF_ZABBIX_SERVER

ZabbixServer1.Address=172.16.7.30

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=DB1

#(名称可随意定义,但要与下文保持一致,切记要与监控的主机名称保持一致)

#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::DB1

DB1.Url=jdbc:oracle:thin:@172.16.7.10:1521:LC

##确保有jdk环境,因为这里是通过JDBC连接的,LC为数据库实例名称

DB1.User=ZABBIX #DB的用户和密码并赋予权限,如下文(这里直接用dba权限用户)

DB1.Password=jeffery

#Those values are optionals if not specified Orabbix is going to use the gener

al values

DB1.MaxActive=10

DB1.MaxWait=100

DB1.MaxIdle=1

DB1.QueryListFile=./conf/query.props

#注销未无效的DB链接

#DB2.Url=jdbc:oracle:thin:@server2.domain.example.com::DB2

#DB2.User=zabbix

#DB2.Password=zabbix_password

#DB2.QueryListFile=./conf/query.props

#DB3.Url=jdbc:oracle:thin:@server3.domain.example.com::DB3

#DB3.User=zabbix

#DB3.Password=zabbix_password

#DB3.QueryListFile=./conf/query.props

6. 创建Oracle账户,并赋予权限

A.创建表空间

CREATE TABLESPACE "ZABBIX" DATAFILE

'/opt/oracle/product/11.2.0/dbs/zabbix01.dbf' SIZE 100M

AUTOEXTEND ON NEXT 524288000 MAXSIZE 32767M

LOGGING ONLINE PERMANENT BLOCKSIZE 8192

EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO;

B.创建用户并赋予权限

CREATE USER ZABBIX IDENTIFIED BY "jeffery" DEFAULT TABLESPACE ZABBIX TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;

alter user ZABBIX quota unlimited on ZABBIX;

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;

C.11g数据库还需要执行下面操作

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;

select utl_inaddr.get_host_name('127.0.0.1') from dual;

7. 创建orabbix启动文件

cp /opt/orabbix/init.d/orabbix /etc/init.d/orabbix

chmod +x /etc/init.d/orabbix

chmod +x /opt/orabbix/run.sh

chkconfig --add orabbix

chkconfig --level 345 orabbix on

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

Template 存放路径在现在文件的template目录中
Orabbix_export_full.xml 全部导入(图表 监控项 触发器)
Orabbix_export_graphs.xml 图表
Orabbix_export_items.xml 监控项
Orabbix_export_triggers.xml 触发器

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

关联模板

9. 启动orabbix 看是否能收集到Oracle数据库信息

出现如下信息那么就配置成功了

[root@localhost ~]# tailf /opt/orabbix/logs/orabbix.log

2014-07-19 21:17:09,982 [pool-1-thread-57] INFO Orabbix - Done with dbJob on database DB1 QueryList elapsed time 126 ms

2014-07-19 21:18:09,881 [pool-1-thread-58] INFO Orabbix - Done with dbJob on database DB1 QueryList elapsed time 5 ms

2014-07-19 21:20:09,917 [pool-1-thread-60] INFO Orabbix - Done with dbJob on database DB1 QueryList elapsed time 16 ms

常见问题:

若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

上图:

参考文档:http://www.smartmarmot.com/wiki/index.php/Orabbix

 

「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」

Suzf Blog

(๑>ڡ<)☆ 谢谢 ~

使用微信扫描二维码完成支付