zabbix利用orabbix监控oracle

zabbix利用orabbix监控oracle

Orabbix 是一个用来监控 Oracle 数据库实例的 Zabbix 插件。(插件安装在zabbix-server端)html

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

 

一 、Orabbix 介绍web

orabbix是一个用来监控oracle数据库性能的zabbix插件工具,经过安装在被监控服务器上客户端上收集数据并传给zabbix服务器端,而后经过调用图形显示。具备如下功能:sql

1. 数据库版本数据库

2. 归档文件vim

3. 等待的事件(如文件的I/O,单块的读,多块的读,直接读,SQLNet消息,控制文件I/O,日志写等)服务器

4. HitRatio(监控Hit Ratio的触发,表/存储过程,SQLArea,Body)oracle

5. 逻辑I/O(当前读操做,持续的读操做,块的更改)dom

6. PGA工具

7. SGA(固定的缓冲,JAVApool,Large Pool,Log Buffer,Shared Pool,Buffer Cache)

8. 物理I/O(重写操做,数据文件写操做,数据文件读操做)

9. SharePool(PoolDictionary Cache, Pool Free Memory, Library Cache,Sql Area ,Misc.)

10. Pin Hit Ratio(monitor Hit Ratio on Trigger, Tables/Procedures, SQLArea,Body)

11. Session/Processes(monitor Sessions and processes)

12. Session (ActiveSession, Inactive Sessions, System Session)

 zabbix-server上操做

Orabbix是经过JDBC去链接oracle数据库,而后过滤想要的数据,因此须要jdk环境

我测试过jdk1.7和1.8均可以,直接yum安装,或者下载rpm包,rpm -ivh安装,均可以

这里,我是直接rpm安装的,

1

2

3

4

5

[root@zabbix ~]# rpm -ivh jdk-8u102-linux-x64.rpm

 

Preparing...                ########################################### [100%]

 

   1:jdk1.8.0_102           ########################################### [100%]

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

1

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

(建议在此目录下,若是放置其余目录稍后须要更改orabbix的启动文件orabbix,启动文件默认写在opt/orabbix目录下 )

[root@zabbix opt]# cd orabbix/

上传orabbix-1.2.3.zip

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

[root@zabbix orabbix]# ls

 

orabbix-1.2.3.zip

 

解压

 

[root@zabbix orabbix]# unzip -q orabbix-1.2.3.zip

 

[root@zabbix orabbix]# ls

 

conf  init.d       lib      orabbix-1.2.3.zip  orabbixw.exe  run.sh    uninstall.cmd

 

doc   install.cmd  orabbix-1.2.3.jar  orabbix.exe        run.bat       template

 

受权

 

[root@zabbix orabbix]# cd ..

 

[root@zabbix opt]# chmod -R a+x orabbix/

 

[root@zabbix ~]# cd /opt/orabbix/conf/

 

[root@zabbix conf]# ls

 

config.props    log4j.properties    query_a_1.props  query_b.props     query.props

 

config.props.sample  log4j.properties.sample  query_a.props  query - Copy.props  query.props.sample

 

[root@zabbix conf]# cp config.props.sample config.props

编辑配置文件:

[root@zabbix conf]# vim config.props

源配置文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

[root@zabbix conf]# egrep "^[a-Z,1-9]" config.props.sample

 

ZabbixServerList=ZabbixServer1,ZabbixServer2

 

ZabbixServer1.Address=IP_ADDRESS_OF_ZABBIX_SERVER

 

ZabbixServer1.Port=PORT_OF_ZABBIX_SERVER

 

ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER

 

ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER

 

OrabbixDaemon.PidFile=./logs/orabbix.pid

 

OrabbixDaemon.Sleep=300

 

OrabbixDaemon.MaxThreadNumber=100

 

DatabaseList=DB1,DB2,DB3

 

DatabaseList.MaxActive=10

 

DatabaseList.MaxWait=100

 

DatabaseList.MaxIdle=1

 

DB1.Url=jdbc:oracle:thin:@server.domain.example.com:<LISTENER_PORT>:DB1

 

DB1.User=zabbix

 

DB1.Password=zabbix_password

 

DB1.MaxActive=10

 

DB1.MaxWait=100

 

DB1.MaxIdle=1

 

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

修改以后

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

[root@zabbix conf]# egrep "^[a-Z,1-9]" config.props

 

ZabbixServerList=ZabbixServer1   #(zabbixserver的名字,下行中address和port都引用到了这个名字,因此下面两行的前缀名字要与这里的名字保持一致)

 

ZabbixServer1.Address=127.0.0.1    #我这里就是在zabbix server上面操做的,因此这里是127.0.0.1

 

ZabbixServer1.Port=10051   #zabbix server的服务端口

 

OrabbixDaemon.PidFile=./logs/orabbix.pid

 

OrabbixDaemon.Sleep=300

 

OrabbixDaemon.MaxThreadNumber=100

 

DatabaseList=172.20.10.183-oracle,192.168.56.99-oracle   #这里很重要,跟下面的对应上

 

DatabaseList.MaxActive=10

 

DatabaseList.MaxWait=100

 

DatabaseList.MaxIdle=1

 

172.20.10.183-oracle.Url=jdbc:oracle:thin:@172.20.10.183:1521:orcl      #172.20.10.183 oracle数据库的地址,1521端口,orcl数据库实例名

 

172.20.10.183-oracle.User=zabbix      #受权的帐号

 

172.20.10.183-oracle.Password=zabbix   #受权的密码

 

172.20.10.183-oracle.MaxActive=10

 

172.20.10.183-oracle.MaxWait=100

 

172.20.10.183-oracle.MaxIdle=1

 

172.20.10.183-oracle.QueryListFile=./conf/query.props    #要查询的语句都在这定义的,不满意本身改

oracle主机上操做(这步能够省略,只要知道数据库实例,帐号,密码)

下面是oracle 11g的(12c 语法不同)受权语句以下,创用户,受权,这些操做,我都是在oracle数据库的sqlplus下执行的

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

[oracle@oracle ~]$ sqlplus / as sysdba

 

  

 

SQL*Plus: Release 11.2.0.3.0 Production on Wed Sep 7 18:01:54 2016

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to:

 

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

 

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL>

 

CREATE USER ZABBIX IDENTIFIED BY zabbix DEFAULT TABLESPACE SYSTEM 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;

 

GRANT SELECT ON V_$SESSION TO ZABBIX;

 

GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;

 

GRANT SELECT ON V_$EVENT_NAME TO ZABBIX;

 

GRANT SELECT ON V_$RECOVERY_FILE_DEST TO ZABBIX;

启动orabbix

[root@zabbix orabbix]# cp init.d/orabbix /etc/init.d/

[root@zabbix orabbix]# ll /etc/init.d/orabbix

-rwxr-xr-x 1 root root 1693 Sep 14 21:40 /etc/init.d/orabbix

[root@zabbix orabbix]# /etc/init.d/orabbix start

Starting Orabbix service:

报错的话,检查配置文件,数据库地址,端口,实例名,帐号,密码是否正确,须要验证对于不懂oracle的怎么办,搜命令呗,我也是一路过来,各类坑~~~~~

而后里面看日志

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

 [main] INFO  Orabbix - --------- on Database -> orcl

 [pool-1-thread-1] WARN  Orabbix - Error while executing ->dbversion- on database ->172.20.10.183-oracle- Exception received ORA-24247: network access denied by access control list (ACL)

ORA-06512: at "SYS.UTL_INADDR", line 4

ORA-06512: at "SYS.UTL_INADDR", line 35

ORA-06512: at line 1

出现这些日志,不影响后面的操做,若是你是完美主义者,知足你

在oracle数据库的sqlplus下执行下面三条命令

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;

到此,安装配置完成,则经过web页面访问监控界面直接导入模板便可

模版放置在/opt/orabbix/template下
Orabbix_export_full.xml          #只须要导入这个一个模板就好

 

添加主机

 

而后连接oracle的模板

 

添加完成以后的效果

查看最新数据

 

这时候图也有了

 

 

常见错误

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

 [main] ERROR Orabbix - Error on Configurator for database 172.20.10.183 oracle -->ORA-01017: invalid username/password; logon denied

config.props配置文件中,数据库帐号密码不对,或者在oracle数据库没受权这个用户