Skip to end of metadata
Go to start of metadata

环境: Windows7, Zabbix4.0.2

Zabbix监控oracle数据库: 表/过程等命中率,逻辑I/O性能,物理I/O性能,PGA,SGA, Sessions,数据库大小,表空间…等

Oracle客户端上必须安装有agent服务并且正常运行状态,才能使用该插件监控。

01. 安装Orabbix

1. 创建安装目录

mkdir  -p /usr/local/orabbix

2. 在创建目录下上传orabbix-1.2.3.zip进行解压

unzip orabbix-1.2.3.zip

3. 备份orabbix配置文件

cp conf/config.props.sample conf/config.props

4. 将启动程序拷贝到/etc/init.d/

cp init.d/orabbix  /etc/init.d/

5. 给启动文件赋予执行权限

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

02. 创建数据库账号给数据库赋权

1. 在开始>所有程序中找到SQL Plus进入终端

2. 登录sys/manager as sysdba

3. 在终端里面执行命令创建用户并授权

CREATE USER ZABBIX123 IDENTIFIED BY "ZABBIX123" EFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;

4. 用户授权

GRANT CONNECT TO ZABBIX123;

GRANT RESOURCE TO ZABBIX123;

ALTER USER ZABBIX123 DEFAULT ROLE ALL;

5. 系统授权

GRANT SELECT ANY TABLE TO ZABBIX123;

GRANT CREATE SESSION TO ZABBIX123;

GRANT SELECT ANY DICTIONARY TO ZABBIX123;

GRANT UNLIMITED TABLESPACE TO ZABBIX123;

GRANT SELECT ANY DICTIONARY TO ZABBIX123;

6. 如果数据库是Oracle 11g,需要执行以下命令:

exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description => 'resolve acl', principal => ‘ZABBIX123’, is_grant => true, privilege => 'resolve');
exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');
commit;

以上命令执行成功即可。

03. 配置Orabbix

1. 检查server端是否安装JDK,否则进行安装。

2. 由于这里orabbix是装在Zabbix Server端

vim  /usr/local/orabbix/conf/config.props

#comma separed list of Zabbix servers

ZabbixServerList=ZabbixServer #代表服务列表,可设置多个一般就设置一个

ZabbixServer.Address=192.168.132.8 #Zabbix server 的IP地址

ZabbixServer.Port=10051 #服务的端口,前缀一定要和ZabbixServerList中的一样

#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=192.168.132.5 #数据库列表,名称对应Zabbix主机名


#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

192.168.132.5.Url=jdbc:oracle:thin:@192.168.132.5:1521:orcl ##数据库连接字符串orcl为数据库实例名

192.168.132.5.User=ZABBIX123 ##监控数据库用户名

192.168.132.5.Password= ZABBIX123 ##监控数据库口令

#Those values are optionals if not specified Orabbix is going to use the general values

192.168.132.5.MaxActive=10

192.168.132.5.MaxWait=100

192.168.132.5.MaxIdle=1

192.168.132.5.QueryListFile=./conf/query.props

192.168.132.5.QueryListFile=./conf/query.props

3. 替换jar由于Zabbix 4.0和之前版本有所差异 例如:orabbix-1.2.4.jar

4. 启动服务

/etc/init.d/orabbix start

出现如上图证明启动成功.

04. 导入模板


1. Orabbix自带模板

cd /usr/local/orabbix/template目录下选择Orabbix_export_full.xml 模板导入即可。

2. Zabbix-web上配置

主机名必须和orabbix配置文件中的DatabaseList 的名称一致。

3. 添加模板

4. 查看最新数据及图形

5. 如果监控数据库文件没有数据,根据规定可以在query.props中加sql语句,也可以自定义,如下图测试成功即可。

如下图即可: