阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Zabbix 3.2.6 通过Orabbix监控Oracle数据库

100次阅读
没有评论

共计 5224 个字符,预计需要花费 14 分钟才能阅读完成。

一、背景

    公司业务使用的是一直 Oracle 数据库,因为多次出现表空间满的时候不能及时发现,每次都是业务组的人员通知处理,这样下来 DBA 这边就比较被动,所以老大要求监控表空间剩余大小并且当剩余过小时能够及时报警。刚想出来的方案是通过写脚本获取表空间的数据,通脚本中使用 expect 自动输入密码登陆 oracle 用户然后再登陆数据库查询数据返回给 zabbix_server。但是由于脚本运行时间大概 12 秒左右,zabbix 获取数据总是超时,在网上搜索中发现 zabbix 插件 orabbix,原理是通过 orabbix 登陆被监控主机 oracle 数据库,查询数据。个人认为非常好用,包括自定义监控项。唯一的麻烦就是需要在配置文件中添加每一个数据库服务器 ip、数据库用户、密码。

二、Orabbix 介绍

    Orabbix 是设计用来为 zabbix 监控 Oracle 的数据库的插件,它提供多层次的监控,包括可用性和服务器性能的指标。它提供了从众多 Oracle 实例采集的有效机制,进而提供此信息的监控和性能指标。然后,您可以利用的 zabbix 的报告功能为收集的所有数据,并提供分析。目前的发行版中包含了一组预先定义的模板,包括从初始部署报警和图形功能。然而,这些可以进行微调,以满足您额需求和数据 / 监控要求。

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

三、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)
  • Physical I/O (Redo Writes, Datafile Writes, Datafile Reads)
  • 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)

四、Orabbix 的安装配置

    其实 orabbix 只需要安装在一台服务器即可,我就选择安装在 Zabbix Server 上,当然上面的 jdk 是为 orabbix 服务的,因为 orabbix 就是一个 oracle 客户端去查找 oracle 中的数据,然后传给 zabbix。

    关于 JDK 的安装可以参加我其他的博文,安装非常简单,这里不再进行介绍。

1、下载 Orabbix

    建议使用我修改好的软件,下载地址为 http://down.51cto.com/data/2337373。

unzip Orabbix-1.2.3.zip
mv orabbix-1.2.3 /usr/local/orabbix

2、调整配置文件

cd /usr/local/orabbix
cp init.d/orabbix /etc/init.d/
chmod +x /etc/init.d/orabbix
chmod +x /usr/local/orabbix/run.sh

3、创建数据库账号

    首先我们需要在被监控的 Oracle 上面创建一个账号,用于 zabbix 的数据获取,在 oracle 的 sqlplus 里面执行。

CREATE USER ZABBIX
IDENTIFIED BY "zabbix"
DEFAULT TABLESPACE SYSTEM
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
  
#2 Roles for ZABBIX
  
GRANT CONNECT TO ZABBIX;
GRANT RESOURCE TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
  
#5 System Privileges for ZABBIX
  
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;

    如果我们的数据库是 Oracle 11g,我们还需要执行下面的语句。

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;

4、配置 config.props

    config.props 是 Orabbix 的配置文件,路径为 /usr/local/orabbix/conf。

cp config.props.sample config.props

    打开配置文件,修改后内容如下:

#comma separed list of Zabbix servers
ZabbixServerList=ZabbixServer1
  
ZabbixServer1.Address=10.0.0.14
ZabbixServer1.Port=10051
  
#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=10.0.2.64,10.0.2.63
  
#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
10.0.2.64.Url=jdbc:oracle:thin:@10.0.2.64:1521:unicode
10.0.2.64.User=zabbix
10.0.2.64.Password=zabbix
#Those values are optionals if not specified Orabbix is going to use the general values
10.0.2.64.MaxActive=10
10.0.2.64.MaxWait=100
10.0.2.64.MaxIdle=1
10.0.2.64.QueryListFile=./conf/query.props
  
#define here your connection string for each database
10.0.2.63.Url=jdbc:oracle:thin:@10.0.2.63:1521:orcl
10.0.2.63.User=zabbix
10.0.2.63.Password=zabbix
#Those values are optionals if not specified Orabbix is going to use the general values
10.0.2.63.MaxActive=10
10.0.2.63.MaxWait=100
10.0.2.63.MaxIdle=1
10.0.2.63.QueryListFile=./conf/query.props

    备注:

  • ZabbixServerList:可以设置多个,用 ”,” 进行分割;

  • DatabaseList:可以设置多个被监控的 Oracle 数据库服务器,用 ”,” 进行分割,该名称要和 zabbix server 界面中的 Host name 保持一致,该配置文件中后续所引用的设定都以该名称为准。

五、启动 Orabbix 服务

service orabbix start

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

六、配置 Zabbix 添加监控

1、导入模板

    模板在软件包的 template 目录下面,全部导入即可。

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

   Configuration–>Templates–>Import

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

2、Oracle 主机添加监控模板

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

 

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

七、验证

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

 

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

 

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

 

Zabbix 3.2.6 通过 Orabbix 监控 Oracle 数据库

更多 Zabbix 相关教程集合

在 Ubuntu 16.04 服务器上安装 Zabbix 3.2  http://www.linuxidc.com/Linux/2017-07/145519.htm 

CentOS 7 LNMP 环境搭建 Zabbix3.0  http://www.linuxidc.com/Linux/2017-02/140134.htm 

Ubuntu 16.04 安装部署监控系统 Zabbix2.4  http://www.linuxidc.com/Linux/2017-03/141436.htm 

Zabbix 监控安装部署及警报配置  http://www.linuxidc.com/Linux/2017-03/141611.htm 

Zabbix 触发器表达式详解 http://www.linuxidc.com/Linux/2017-03/141921.htm 

Ubuntu 16.04 下安装部署 Zabbix3.0  http://www.linuxidc.com/Linux/2017-02/140395.htm 

CentOS 6.3 下 Zabbix 监控 apache server-status http://www.linuxidc.com/Linux/2013-05/84740.htm 

CentOS 7 下 Zabbix 3.0 安装详解 http://www.linuxidc.com/Linux/2017-03/141716.htm 

64 位 CentOS 6.2 下安装 Zabbix 2.0.6   http://www.linuxidc.com/Linux/2014-11/109541.htm 

ZABBIX 的详细介绍:请点这里
ZABBIX 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-10/147224.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计5224字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中