第一章 zabbix+Orabbix
Orabbix是设计用来为zabbix监控Oracle数据库的插件,它提供多层次的监控,包括可用性和服务器性能指标。 它提供了从众多Oracle实例采集数据的有效机制,进而提供此信息的监控和性能指标。然后,您可以利用的zabbix的报告功能为收集的所有数据,并提供分析。目前的发行版中包含了一组预先定义的模板,包括从初始部署警报和图形功能。然而,这些可以进行微调,以满足您的需求和数据/监控要求。
Orabbix能监控什么?
- 数据库版本
- 归档日志与生产趋势分析
- 触发器,表/过程等命中率
- 逻辑I / O性能
- 物理I / O性能
- PGA
- SGA
- 共享池
- Sessions
- 数据库大小
第一步:安装需求
- Zabbix 2.2.9 Server * Java Runtime Environment 6 * RHEL5.3 * IP: 0.0.0.58
- DB Server: * Oracle 11g * IP: 0.0.0.188
第二步:下载Orabbix到Zabbix Server上 http://www.smartmarmot.com/product/orabbix/download/
On the Zabbix Server( 0.0.0.58)
#unzip Orabbix to: /opt/orabbix
[root@hzbacksto orabbix]# pwd
/opt/orabbix
[root@hzbacksto orabbix]# ll orabbix-1.2.3.zip
-rwxr--r-- 1 root root 4858160 Oct 13 06:50 orabbix-1.2.3.zip
[root@hzbacksto orabbix]# unzip orabbix-1.2.3.zip
[root@hzbacksto orabbix]# tree -L 1 ./
./
|-- conf
|-- doc
|-- init.d
|-- install.cmd
|-- lib
|-- logs
|-- orabbix-1.2.3.jar
|-- orabbix-1.2.3.zip
|-- orabbix.exe
|-- orabbixw.exe
|-- run.bat
|-- run.sh
|-- template
|-- uninstall.cmd
#Copy file /opt/orabbix/init.d/orabbix to /etc/init.d/orabbix
[root@hzbacksto orabbix]# cp /opt/orabbix/init.d/orabbix /etc/init.d/orabbix
#Grant execute permissions to the following files:
[root@hzbacksto orabbix]# chmod 755 /etc/init.d/orabbix
[root@hzbacksto orabbix]# chmod 755 /opt/orabbix/run.sh
第三步:在需要监控的DB上创建zabbix用户,使Orabbix来访问DB
#On the DB Server( 0.0.0.188)
CREATE TABLESPACE TBS_ZABBIX_01 DATAFILE
'/home/oracle/app/oracle/oradata/cha/tbs_zabbix_01.dbf' SIZE 100M AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
CREATE USER ZABBIX
IDENTIFIED BY pass
DEFAULT TABLESPACE TBS_ZABBIX_01
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;
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;
#verify the above is correct by running
select utl_inaddr.get_host_name('127.0.0.1') from dual;
#On the Zabbix Server( 0.0.0.58)
chkconfig --add orabbix
chkconfig --list
第四步:配置文件config.props
cp /opt/orabbix/conf/config.props.sample config.props
#comma separed list of Zabbix servers
ZabbixServerList=ZabbixServer1 #此处的ZabbixServer1与以下两行开头对应
ZabbixServer1.Address= 0.0.0.58 #zabbixserver地址
ZabbixServer1.Port=10051 #zabbixserver端口
#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=cha # 名称与该机在 zabbix 中监控的主机名称保持一致
#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
cha.Url=jdbc:oracle:thin:@ 0.0.0.188:1521:cha #通过jbdc连接,确保系统有jdk环境
cha.User=zabbix
cha.Password=pass
#Those values are optionals if not specified Orabbix is going to use the general values
cha.MaxActive=10
cha.MaxWait=100
cha.MaxIdle=1
cha.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
第五步:启动orabbix程序
[root@hzbacksto conf]# /etc/init.d/orabbix start
[root@hzbacksto ~]# tail -f /opt/orabbix/logs/orabbix.log
2015-10-13 03:32:32,773 [main] INFO Orabbix - maxPoolSize=10
2015-10-13 03:32:32,773 [main] INFO Orabbix - maxIdleSize=1
2015-10-13 03:32:32,773 [main] INFO Orabbix - maxIdleTime=1800000ms
2015-10-13 03:32:32,773 [main] INFO Orabbix - poolTimeout=100
2015-10-13 03:32:32,773 [main] INFO Orabbix - timeBetweenEvictionRunsMillis=-1
2015-10-13 03:32:32,773 [main] INFO Orabbix - numTestsPerEvictionRun=3
2015-10-13 03:32:33,283 [main] INFO Orabbix - Connected as ZABBIX
2015-10-13 03:32:33,286 [main] INFO Orabbix - --------- on Database -> cha
2015-10-13 03:32:34,344 [pool-1-thread-1] INFO Orabbix - Done with dbJob on database cha QueryList elapsed time 998 ms
第六步:导入模板
将该模板 Orabbix_export_full.xml下载到本机,导入zabbix server template中
[root@hzbacksto template]# pwd
/opt/orabbix/template
[root@hzbacksto template]# ll
total 236
-rw-r--r-- 1 root root 107257 Oct 25 2011 Orabbix_export_full.xml
添加主机(名字必须跟config.props里面定义的名称的配置保持一致),所以主机名必须是cha