Orabbix监控Oracle 11g
Orabbix简介说明
orabbix是一个用来监控oracle数据库性能的zabbix插件工具,通过安装在被监控服务器上客户端上收集数据并传给zabbix服务器端,然后通过调用图形显示。具有以下功能:
- 数据库版本
- 归档文件
- 等待的事件(如文件的I/O,单块的读,多块的读,直接读,SQLNet消息,控制文件I/O,日志写等)
- HitRatio(监控Hit Ratio的触发,表/存储过程,SQLArea,Body)
- 逻辑I/O(当前读操作,持续的读操作,块的更改)
- PGA
- SGA(固定的缓冲,JAVApool,Large Pool,Log Buffer,Shared Pool,Buffer Cache)
- 物理I/O(重写操作,数据文件写操作,数据文件读操作)
- SharePool(PoolDictionary Cache, Pool Free Memory, Library Cache,Sql Area ,Misc.)
- Pin Hit Ratio(monitor Hit Ratio on Trigger, Tables/Procedures, SQLArea,Body)
- Session/Processes(monitor Sessions and processes)
- Session (ActiveSession, Inactive Sessions, System Session)
环境
Oracle Server: 192.168.88.53:1521:orcl Zabbix Server: 192.168.88.56:10050 Zabbix Agent: 192.168.88.56:10051 Orabbix: 192.168.88.56 jdk 1.8: 192.168.88.56
1,下载并安装jdk8
如果已经安装了java,这步可以跳过。
下载地址
http://www.oracle.com/technetwork/java/javase/downloads/index.html
解压安装,这里以jdk-8u152-linux-x64版本为例
mkdir -p /usr/local/java tar -zxvf jdk-8u152-linux-x64.tar.gz -C /usr/local/java
2,创建oracle监控帐号,在oracle的sqlplus窗口里面执行:
CREATE USER ZABBIX_MONITOR IDENTIFIED BY zabbix456 DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; GRANT CONNECT TO ZABBIX_MONITOR; GRANT RESOURCE TO ZABBIX_MONITOR; ALTER USER ZABBIX_MONITOR DEFAULT ROLE ALL; GRANT SELECT ANY TABLE TO ZABBIX_MONITOR; GRANT CREATE SESSION TO ZABBIX_MONITOR; GRANT SELECT ANY DICTIONARY TO ZABBIX_MONITOR; GRANT UNLIMITED TABLESPACE TO ZABBIX_MONITOR; GRANT SELECT ANY DICTIONARY TO ZABBIX_MONITOR;
if you need an User (ZABBIX) for Orabbix with the minimum grants available
GRANT ALTER SESSION TO ZABBIX_MONITOR; GRANT CREATE SESSION TO ZABBIX_MONITOR; GRANT CONNECT TO ZABBIX_MONITOR; ALTER USER ZABBIX_MONITOR DEFAULT ROLE ALL; GRANT SELECT ON V_$INSTANCE TO ZABBIX_MONITOR; GRANT SELECT ON DBA_USERS TO ZABBIX_MONITOR; GRANT SELECT ON V_$LOG_HISTORY TO ZABBIX_MONITOR; GRANT SELECT ON V_$PARAMETER TO ZABBIX_MONITOR; GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO ZABBIX_MONITOR; GRANT SELECT ON V_$LOCK TO ZABBIX_MONITOR; GRANT SELECT ON DBA_REGISTRY TO ZABBIX_MONITOR; GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX_MONITOR; GRANT SELECT ON V_$SYSSTAT TO ZABBIX_MONITOR; GRANT SELECT ON V_$PARAMETER TO ZABBIX_MONITOR; GRANT SELECT ON V_$LATCH TO ZABBIX_MONITOR; GRANT SELECT ON V_$PGASTAT TO ZABBIX_MONITOR; GRANT SELECT ON V_$SGASTAT TO ZABBIX_MONITOR; GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX_MONITOR; GRANT SELECT ON V_$PROCESS TO ZABBIX_MONITOR; GRANT SELECT ON DBA_DATA_FILES TO ZABBIX_MONITOR; GRANT SELECT ON DBA_TEMP_FILES TO ZABBIX_MONITOR; GRANT SELECT ON DBA_FREE_SPACE TO ZABBIX_MONITOR; GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX_MONITOR;
如果是oracle11g的数据库版本,还需要执行下面的语句开放ACL的访问控制,否则在监控的过程中有部份内容无法正常显示(例于数据库版本,数据库文件大小等),而且orabbix的日志显示中也会有错误提示。注意如果创建的账号是小写,以下的ZABBIX_MONITOR需要大写。最好还是大写吧。
exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description=> 'resolve acl', principal =>'ZABBIX_MONITOR', is_grant => true, privilege => 'resolve'); exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*'); commit;
3,安装部署orabbix
其实orabbix只需要安装在一台服务器即可,我就选择安装在Zabbix Server上,当然上面的jdk是为orabbix服务的,因为orabbix就是一个oracle客户端去查找oracle中的数据,然后传给zabbix,安装orabbix:
下载:
mkdir -p /usr/local/orabbix cd /usr/local/orabbix wget http://nchc.dl.sourceforge.net/project/orabbix/orabbix-1.2.3.zip
安装:
unzip orabbix-1.2.3.zip chmod +x run.sh cp init.d/orabbix /etc/init.d/ chmod +x /etc/init.d/orabbix sed -i 's#/opt/orabbix#/usr/local/orabbix#g' /etc/init.d/orabbix # 根据实际java路径修改 sed -i 's#java#/usr/local/java/jdk1.8.0_152/bin/java#g' /usr/local/orabbix/run.sh
4,配置config. Props:
orabbix所有的配置文件都在conf目录中,需要将默认的配置文件config.props.sample复制一份后再进行修改和配置。
cd /usr/local/orabbix/conf cp config.props.sample config.props vim config.props
以下是修改后和去注释后的配置
ZabbixServerList=ZabbixServer1 ZabbixServer1.Address=192.168.88.56 ZabbixServer1.Port=10051 OrabbixDaemon.PidFile=./logs/orabbix.pid OrabbixDaemon.Sleep=300 OrabbixDaemon.MaxThreadNumber=100 DatabaseList=testora DatabaseList.MaxActive=10 DatabaseList.MaxWait=100 DatabaseList.MaxIdle=1 testora.Url=jdbc:oracle:thin:@192.168.88.53:1521:orcl testora.User=zabbix_monitor testora.Password=zabbix456 testora.MaxActive=10 testora.MaxWait=100 testora.MaxIdle=1 testora.QueryListFile=./conf/query.props
PS:需要注意的是DatabaseList=testora指的是被监控服务器的名称,该名称要和zabbix server界面中的机器名称保持一致,该配置文件中后续所引用的设定都以该名称为准。
testora.Url=jdbc:oracle:thin:@192.168.88.53:1521:orcl指定的是被监控服务器的连接信息(例如采用jdbc的联接方式,服务器地址是192.168.88.53,oracle的端口是1521,orcl指的是数据库的实例名称)
5,启动orabbix服务
启动orabbix
service orabbix start Starting Orabbix service:
查看启动的orabbix进程
ps aux |grep orabbix root 1259 0.3 0.6 12112256 203324 pts/1 Sl 16:02 0:13 /usr/local/java/jdk1.8.0_152/bin/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
6,界面导入oracle模版文件
导入时应该注意模板里面的host的name属性,group的属性值是否与zabbix已存在的设置有冲突,如果导入失败,可能是冲突造成的。把这两个属性改一下名即可。
参考
上一篇: MySQL备份恢复之mydumper
推荐阅读
-
win10下oracle安装(11g)的步骤教程
-
深入剖析哪些服务是Oracle 11g必须开启的
-
WMware redhat 5 oracle 11g 安装方法
-
Oracle性能优化——SQL基线(SQLbaseline)的载入与进化(11g中引入的基线)
-
Oracle 11g空表导出的方法讲解
-
Oracle 11g静默安装
-
Window下Oracle Database 11g 发行版2安装教程
-
Windows10 x64安装、配置Oracle 11g过程记录(图文教程)
-
Oracle 11g 安装配置图文教程
-
Oracle 11g for Linux CentOS 5.2 详细安装步骤分享(图解教程)