orabbix监控oracle数据库

  1. 云栖社区>
  2. 博客>
  3. 正文

orabbix监控oracle数据库

余传琪 2019-09-05 12:36:17 浏览180
展开阅读全文

orabbix监控oracle数据库
数据库授权(亦可使用oracle的sys用户)
#su - oralce登录 oracle 命令行

 #sqlplus / as sysdba

2) 创建zabbix用户

 create user zabbix identified by zabbix

default tablespace system temporary tablespace temp
profile default account unlock;
3) 赋予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;

4) 如果是11G的数据库版本,还需要执行下面的语句开放ACL的访问控制,否则在监控的过程中有部份内容无法正常显示(例于数据库版本,数据库文件大小等),而且orabbix的日志显示中也会有以下的错误提示。

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;
配置orabbix
将orabbix上传至服务器中,并解压为:/opt/orabbix,并授权chmod a+x /opt/zabbix;
基础环境必需具备JAVA;
_

配置文件在/opt/orabbix/conf中,先将config.props.sample文件复制一份为config.props
[root@backup-shareserver orabbix]# ls
conf install.cmd orabbix-1.2.3.jar run.bat uninstall.cmd
doc lib orabbix.exe run.sh
init.d logs orabbixw.exe template

[root@backup-shareserver conf]# cp config.props.sample config.props
[root@backup-shareserver conf]# ls
config.props query_a_1.props query.props
config.props.sample query_a.props query.props.sample
log4j.properties query_b.props
log4j.properties.sample query - Copy.props
配置文件修改如下
[root@backup-shareserver conf]# cat config.props
ZabbixServerList=ZabbixServer1 #服务器名随意
ZabbixServer1.Address=192.168.0.124 #zabbix服务器IP
ZabbixServer1.Port=10051 #zabbix服务端口
OrabbixDaemon.PidFile=./logs/orabbix.pid #默认存放在解压目录/opt/orabbix/logs
OrabbixDaemon.Sleep=300
OrabbixDaemon.MaxThreadNumber=100
DatabaseList=DB1

名字必需和下面的DB1.user一致;且配置zabbix监控时名称也必需与此一致

DatabaseList.MaxActive=10
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1
DB1.Url=jdbc:oracle:thin:@192.168.0.54:1521:testdb

本机IP地址及数据库服务端口:实例名称

DB1.User=zabbix #数据库用户
DB1.Password=zabbix #数据库密码
DB1.MaxActive=10
DB1.MaxWait=100
DB1.MaxIdle=1
DB1.QueryListFile=./conf/query.props
可对主机多个库监控

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

DB2.User=zabbix

DB2.Password=zabbix_password

DB2.QueryListFile=./conf/query.props

[root@backup-shareserver logs]cp /opt/orabbix/init.d/orabbix /etc/init.d/orabbix
[root@backup-shareserver logs] /etc/init.d/orabbix start
启动服务;查看启动是否成功;
[root@backup-shareserver logs]# ps aux | grep orabbix
root 24140 0.0 0.0 103244 856 pts/0 S+ 17:20 0:00 grep orabbix
root 27984 0.1 0.8 9987696 178616 pts/0 Sl 13:09 0:25 java -Duser.language=en -Duser.country=US -Dlog4j.configuration=./conf/log4j.properties -cp lib/commons-codec-1.4.jar:lib/commons-dbcp-1.4.jar:lib/commons-lang-2.5.jar:lib/commons-logging-1.1.1.jar:lib/commons-pool-1.5.4.jar:lib/hsqldb.jar:lib/log4j-1.2.15.jar:lib/ojdbc6.jar:.:./orabbix-1.2.3.jar com.smartmarmot.orabbix.bootstrap start ./conf/config.props

查看启动日志,已成功启动,如报错则数据库配置错误;
[root@backup-shareserver ~]# tail -f /opt/orabbix/logs/orabbix.log
2016-06-08 13:09:28,649 [main] INFO Orabbix - Starting Orabbix Version 1.2.3
2016-06-08 13:09:28,663 [main] INFO Orabbix - Orabbix started with pid:27984
2016-06-08 13:09:28,663 [main] INFO Orabbix - PidFile -> ./logs/orabbix.pid
2016-06-08 13:09:29,040 [main] INFO Orabbix - DB Pool created: org.apache.commons.dbcp.datasources.SharedPoolDataSource@5b422b45
2016-06-08 13:09:29,040 [main] INFO Orabbix - URL=jdbc:oracle:thin:@192.168.0.54:1521:testdb
2016-06-08 13:09:29,040 [main] INFO Orabbix - maxPoolSize=10
2016-06-08 13:09:29,040 [main] INFO Orabbix - maxIdleSize=1
2016-06-08 13:09:29,040 [main] INFO Orabbix - maxIdleTime=1800000ms
2016-06-08 13:09:29,040 [main] INFO Orabbix - poolTimeout=100
2016-06-08 13:09:29,041 [main] INFO Orabbix - timeBetweenEvictionRunsMillis=-1
2016-06-08 13:09:29,041 [main] INFO Orabbix - numTestsPerEvictionRun=3
2016-06-08 13:09:30,234 [main] INFO Orabbix - Connected as ZABBIX
2016-06-08 13:09:30,236 [main] INFO Orabbix - --------- on Database -> testdb
配置监控
Zabbix配置监控,在orabbix文件中有template模板,导入Orabbix_export_full.xml模板
_
_
_
_

导入模板
_

_

导入成功后可在模板里找到相应模板
_

配置监控主机,主机名必需与orabbix配置文件中的DatabaseList=DB1一致;由于它是主动推送端口随意填写;

_

服务器端未安装zabbix-agent所以显示未监控;
_

查看监控可以看到有数据流入
_

网友评论

登录后评论
0/500
评论
余传琪
+ 关注