Zabbix系列之(六):Zabbix3.0+Orabbix监控Oracle性能

title: Zabbix系列之(六):Zabbix3.0+Orabbix监控Oracle性能
categories: Linux
tags:
– Zabbix
– Oracle
timezone: Asia/Shanghai
date: 2019-01-17

环境

[root@centos181001 orabbix]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core) 

[root@centos181001 orabbix]# zabbix_server -V
zabbix_server (Zabbix) 3.0.24
Revision 87227 26 November 2018, compilation time: Nov 26 2018 10:08:56

Copyright (C) 2018 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.0.1e-fips 11 Feb 2013
Running with OpenSSL 1.0.1e-fips 11 Feb 2013

[root@centos181001 orabbix]# zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 3.0.24
Revision 87227 26 November 2018, compilation time: Nov 26 2018 10:09:32

Copyright (C) 2018 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.0.1e-fips 11 Feb 2013
Running with OpenSSL 1.0.1e-fips 11 Feb 2013

注意:Orabbix目前官网最新版本是1.2.3,是不支持Zabbix4.0的,只能支持到Zabbix3.0

简介

What can it monitor?

Orabbix使用Oracle数据库的Java数据库连接器(JDBC),因此不需要安装Oracle客户端。

Below are some examples of what Orabbix is capable of monitoring:

-- 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)

第一步:在Zabbix Server服务器上安装Java Runtime Environment 6

bash jdk-6u45-linux-x64.bin
mv jdk1.6.0_45/ jdk
cat <<EOF >>/etc/profile
export JAVA_HOME=/home/jdk
export CLASSPATH=.:\${JAVA_HOME}/jre/lib/rt.jar:\${JAVA_HOME}/lib/dt.jar:\${JAVA_HOME}/lib/tools.jar
export PATH=\$PATH:\${JAVA_HOME}/bin
EOF
source /etc/profile

第二步:下载Orabbix并安装

1.在Zabbix Server服务器上下载并安装Orabbix
Steps for Installation

Download Orabbix to your Zabbix Server
On your Zabbix server, unzip Orabbix to: /opt/orabbix
Copy file /opt/orabbix/init.d/orabbix to /etc/init.d/orabbix
Grant execute permissions to the following files:
    /etc/init.d/orabbix
    /opt/orabbix/run.sh

# 1.下载Orabbix到Zabbix Server
wget https://nchc.dl.sourceforge.net/project/orabbix/orabbix-1.2.3.zip

# 2.在Zabbix server解压Orabbix到/opt/orabbix
unzip orabbix-1.2.3.zip -d /opt/orabbix

# 3.Copy file /opt/orabbix/init.d/orabbix to /etc/init.d/orabbix
cp /opt/orabbix/init.d/orabbix /etc/init.d/orabbix

# 4.赋予以下两个文件可执行权限
chmod +x /etc/init.d/orabbix
chmod +x /opt/orabbix/run.sh
2.在需要监控的Oracle服务器上为Orabbix创建ZABBIX用户

1.登录数据库

sqlplus / as sysdba

2.使用官方提供的脚本创建zabbix用户(以下两个脚本任选)

# Create a User (ZABBIX) for Orabbix to access your Oracle Database.
# You can use the following script:
# 为Orabbix创建用户(ZABBIX)以访问Oracle数据库。
# 您可以使用以下脚本:

CREATE USER ZABBIX
-- IDENTIFIED BY <REPLACE WITH PASSWORD>
IDENTIFIED BY xiaoliu
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;

# NOTE if you need an User (ZABBIX) for Orabbix with the minimum grants available
# you can use the following script:
# 注意如果您需要具有可用最小授权的Orabbix用户(ZABBIX)
# 您可以使用以下脚本:

CREATE USER ZABBIX
-- IDENTIFIED BY <REPLACE WITH PASSWORD>
IDENTIFIED BY xiaoliu
DEFAULT TABLESPACE USERS
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_$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;
3.注意:如果您使用的是Oracle 11g,则需要添加以下内容:
# NOTE : If you are using Oracle 11g, you will need to add the following:

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.您可以通过运行来验证以上内容是否正确:
# You can verify the above is correct by running:
select utl_inaddr.get_host_name('127.0.0.1') from dual;
5.为Zabbix导入模板
# Create a Host entry in Zabbix for the DB Instance/s you are planning to monitor, and import the templates found at: /opt/orabbix/template

登录Zabbix管理页面 - 配置 - 模板 - 导入 - 浏览(将所有模板导入)
6.修改配置文件config.props

注意:这里的DatabaseList的名字要跟Zabbix Server添加的监控主机名字保持一致。

# 需要先用原始模板复制一份,然后修改
cp /opt/orabbix/conf/config.props.sample /opt/orabbix/conf/config.props

# 根据实际情况修改以下几项(Orabbix支持同时监视N个Oracle数据库,这里演示1个的配置文件)
vim /opt/orabbix/conf/config.props

ZabbixServerList=ZabbixServer1
ZabbixServer1.Address=10.0.1.66
ZabbixServer1.Port=10051

DatabaseList=DB1
DB1.Url=jdbc:oracle:thin:@10.0.1.111:1521:oracledb
DB1.User=zabbix
DB1.Password=xiaoliu
7.启动Orabbix
/opt/orabbix/run.sh
8.在Oracle数据库服务器上装agent并启动
# 1.安装agent
rpm -i https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install -y zabbix-agent

# 2.修改配置文件(根据实际情况修改以下3项,其他可以保持默认)
vim /etc/zabbix/zabbix_agentd.conf

Server=11.11.11.61
ServerActive=11.11.11.61
Hostname=Oracle

# 3.开启并设置开机自动启动
systemctl start zabbix-agent
systemctl enable zabbix-agent
systemctl status zabbix-agent
9.在Zabbix Server添加监控主机
1.增加监控主机
    登录Zabbix管理页面 - 配置 - 主机 - 创建主机
        主机名称:任意
        群组:根据自己实际情况,我这里选的是Linux servers
        agent代理程序的接口
            IP地址:填写Oracle数据库服务器的IP地址
            端口:如果没有修改的话,保持默认的10050即可
    
2.为主机增加监控项
    登录Zabbix管理页面 - 配置 - 主机 - 选择刚添加的主机
        模板 - 选择刚添加的Orabbix模板(Template_Oracle)
10.至此配置完成,登录Zabbix Server管理有页面可以查看Oracle的监控情况。

附录:

Orabbix官网:http://www.smartmarmot.com

    原文作者:小六的昵称已被使用
    原文地址: https://www.jianshu.com/p/d76154fbb165
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞