zabbix-使用orabbix来监控oracle11g
Orabbix简介说明
-
DB Version (i.e. Validity of package)数据库版本
-
Archiving (Archive log production with trend analysis)归档文件
-
Event Waits (Files I/O, single block read, multi-block read, direct path read, SQLNet Messages, Control file I/O, Log Write)等待的事件
-
Hit Ratio (Hit Ratio on Triggers, Tables/Procedures, SQL Area, Body)
-
Logical I/O (Server performance on Logical I/O of: Current Read, Consistent Read, Block Change)逻辑I/O
-
Physical I/O (Redo Writes, Datafile Writes, Datafile Reads)物理I/O
PGA
-
SGA (In particular; Fixed Buffer, Java Pool, Large Pool, Log Buffer, Shared Poolm Buffer Cache)
-
Shared Pool (Pool Dictionary Cache, Pool Free Memory, Library Chache, SQL Area, MISC.)共享池
-
Pin Hit Ratio (Oracle library cache pin are caused by contention with the library cache, the area used to store SQL executables for re-use)
-
Sessions / Processes**会话数和进程数**
-
Sessions (Active Sessions, Inactive Sessions, System Sessions)
-
DBSize/DBFileSize (DBSize size of database really used space and of Filesize)数据库大小
下载安装jdk8
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
安装步骤:
#将软件上传到服务器#mkdir /usr/java#tar -zxvf jdk-8u171-linux-x64.tar.gz#mv jdk1.8.0_171 /usr/java/#echo -e '# config java\nJAVA_HOME=/usr/java/jdk1.8.0_171\nCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar\n# config path\nPATH=$JAVA_HOME/bin:$PATH\nexport PATH JAVA_HOME CLASSPATH\n' >> /etc/profile
r/java/jdk1.8.0_171\nCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar\n# config path\nPATH=$JAVA_HOME/bin:$PATH\nexport PATH JAVA_HOME CLASSPATH\n' >> /etc/profile
#source /etc/profile
创建oracle监控帐号,在oracle的sqlplus窗口里面执行:
create tablespace zabbix datafile'+DATA' size 16G autoextend off;create tablespace zabbix_idx datafile'+DATA' size 2G autoextend off;CREATE USER zabbix IDENTIFIED BY zabbix DEFAULT TABLESPACE zabbix TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;GRANT ALTER SESSION TO zabbix;GRANT CREATE SESSION TO zabbix;GRANT CONNECT TO zabbix;ALTER USER zabbix DEFAULT ROLE ALL;GRANT SELECT ON V_$INSTANCE TO zabbix;GRANT SELECT ON DBA_USERS TO zabbix;GRANT SELECT ON V_$LOG_HISTORY TO zabbix;GRANT SELECT ON V_$LOG TO zabbix;GRANT SELECT ON V_$PARAMETER TO zabbix;GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO zabbix;GRANT SELECT ON V_$LOCK TO zabbix;GRANT SELECT ON DBA_REGISTRY TO zabbix;GRANT SELECT ON V_$LIBRARYCACHE TO zabbix;GRANT SELECT ON V_$SYSSTAT TO zabbix;GRANT SELECT ON V_$PARAMETER TO zabbix;GRANT SELECT ON V_$LATCH TO zabbix;GRANT SELECT ON V_$PGASTAT TO zabbix;GRANT SELECT ON V_$SGASTAT TO zabbix;GRANT SELECT ON V_$LIBRARYCACHE TO zabbix;GRANT SELECT ON V_$PROCESS TO zabbix;GRANT SELECT ON DBA_DATA_FILES TO zabbix;GRANT SELECT ON DBA_TEMP_FILES TO zabbix;GRANT SELECT ON DBA_FREE_SPACE TO zabbix;GRANT SELECT ON V_$SYSTEM_EVENT TO zabbix;GRANT SELECT ON V_$locked_object TO zabbix;GRANT SELECT ON dba_objects TO zabbix;GRANT SELECT ON dba_tablespaces TO zabbix;GRANT SELECT ON v_$SESSION TO zabbix;
如果是oracle11g的数据库版本,还需要执行下面的语句开放ACL的访问控制,否则在监控的过程中有部份内容无法正常显示(例于数据库版本,数据库文件大小等),而且orabbix的日志显示中也会有错误提示。:
SQL> exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description=> 'resolve acl', principal =>'zabbix', is_grant => true, privilege => 'resolve');BEGIN dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description=> 'resolve acl', principal =>'zabbix', is_grant => true, privilege => 'resolve'); END;*ERROR at line 1:ORA-30554: function-based index XDB.XDB$ACL_XIDX is disabledORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 258ORA-06512: at line 1SQL> exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');BEGIN dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*'); END;*ERROR at line 1:ORA-31001: Invalid resource handle or path name "/sys/acls/resolve.xml"ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 97ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 485ORA-06512: at line 1
安装部署orabbix
orabbix只需要安装在一台服务器即可,orabbix就是一个oracle客户端去查找oracle中的数据,然后传给zabbix:
# 下载:mkdir /usr/local/orabbixcd /usr/local/orabbixwget http://nchc.dl.sourceforge.net/project/orabbix/orabbix-1.2.3.zip# 安装:unzip orabbix-1.2.3.zipchmod +x run.shcp init.d/orabbix /etc/init.d/sed -i 's#orabbix=/opt/orabbix#orabbix=/usr/local/orabbix#g' /etc/init.d/orabbix
chmod +x /etc/init.d/orabbixsed -i 's#java#/usr/java/jdk1.8.0_171/bin/java#g' /usr/local/orabbix/run.sh
配置config. Props:
orabbix所有的配置文件都在conf目录中,需要将默认的配置文件config.props.sample复制一份后再进行修改和配置。
cd /usr/local/orabbix/confcp config.props.sample config.propsvim config.props
PS:需要注意的是DatabaseList=DB1指的是被监控服务器的名称,该名称要和zabbix server界面中的机器名称保持一致,该配置文件中后续所引用的设定都以该名称为准。
DB1.Url=jdbc:oracle:thin:@ 192.167.3.90:1521:powerdes指定的是被监控服务器的连接信息(例如采用jdbc的联接方式,服务器地址是192.167.3.90,oracle的端口是1521,powerdes指的是数据库的实例名称)
启动orabbix服务
#启动程序[root@ntpd orabbix]# service orabbix startStarting Orabbix service:#查看启动日志是否有报错[root@ntpd logs]# tail -200f orabbix.log2018-06-13 16:32:46,326 [main] INFO Orabbix - Starting Orabbix Version 1.2.32018-06-13 16:32:46,341 [main] INFO Orabbix - Orabbix started with pid:141462018-06-13 16:32:46,341 [main] INFO Orabbix - PidFile -> ./logs/orabbix.pid2018-06-13 16:32:46,513 [main] INFO Orabbix - DB Pool created: org.apache.commons.dbcp.datasources.SharedPoolDataSource@7fbe847c2018-06-13 16:32:46,514 [main] INFO Orabbix - URL=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.220.2.84)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.220.2.85)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = yes))(CONNECT_DATA = (SERVER = DEDICATED)(FAILOVER_MODE = (TYPE = SESSION)(METHOD = BASIC))(SERVICE_NAME = orcl)(RETRIES = 1)(DELAY = 3)))2018-06-13 16:32:46,514 [main] INFO Orabbix - maxPoolSize=102018-06-13 16:32:46,514 [main] INFO Orabbix - maxIdleSize=12018-06-13 16:32:46,514 [main] INFO Orabbix - maxIdleTime=1800000ms2018-06-13 16:32:46,514 [main] INFO Orabbix - poolTimeout=1002018-06-13 16:32:46,514 [main] INFO Orabbix - timeBetweenEvictionRunsMillis=-12018-06-13 16:32:46,514 [main] INFO Orabbix - numTestsPerEvictionRun=3#查看进程是否存在[root@ntpd logs]# ps aux |grep orabbixroot 14146 8.1 0.5 7059940 86192 pts/3 Sl 16:32 0:02 /usr/java/jdk1.8.0_171/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
界面导入oracle模版文件
[root@ntpd template]# lltotal 228-rw-r--r-- 1 root root 107257 Oct 25 2011 Orabbix_export_full.xml
-rw-r--r-- 1 root root 21399 Oct 25 2011 Orabbix_export_graphs.xml
-rw-r--r-- 1 root root 86724 Oct 25 2011 Orabbix_export_items.xml
-rw-r--r-- 1 root root 4911 Oct 25 2011 Orabbix_export_triggers.xml
[root@ntpd template]# pwd/usr/local/orabbix/template
导入成功后:
将模板导入到被监控的节点: