官方配置地址:http://www.smartmarmot.com/wiki/index.php?title=Orabbix
1。在被监控端创建用户并创建zabbix专用表空间
CREATE USER ZABBIX IDENTIFIED BY ZABBIX;
GRANT CONNECT,resource TO ZABBIX;
grant create session to ZABBIX;
grant create tablespace to ZABBIX;
conn ZABBIX/ZABBIX;
CREATE TABLESPACE ORABBIX DATAFILE
'/u01/app/oracle/oradata/POSP/orabbix.dbf' SIZE 1G AUTOEXTEND ON NEXT 1G MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
conn sys/sys as sysdba;
alter USER ZABBIX
IDENTIFIED BY ZABBIX
DEFAULT TABLESPACE orabbix
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
2.安装jdk包,依赖于java
去官网下载
3.建立对应的目录
orabbix默认的配置是/opt/orabbix,相关的内容都会在此文件夹内,如果安装时指定了其它的目录请记得在配置文件中更改为正确的文件路径。
mkdir –p /opt/orabbix
cd /opt/orabbix
4.安装orabbix包
unzip orabbix-1.2.3.zip
cp init.d/orabbix /etc/init.d/
chmod +x run.sh
chmod +x /etc/init.d/orabbix
5.在数据中创建用户并授权
GRANT ALTER SESSION 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 V_$LOCKED_OBJECT 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 ANY DICTIONARY TO ZABBIX;
GRANT UNLIMITED TABLESPACE TO ZABBIX;
GRANT SELECT ANY TABLE TO ZABBIX;
GRANT SELECT ANY SECUENCE TO ZABBIX;
grant SELECT ANY TRANSACTION to ZABBIX;
grant execute on dbms_lock to ZABBIX;
revoke execute on dbms_lock from ZABBIX;
revoke dba from ZABBIX;
orabbix执行了那些语句
https://github.com/sboschman/orabbix/blob/master/src/main/conf/query.props.extended
6.如果是11G的数据库版本,还需要执行下面的语句开放ACL的访问控制,否则在监控的过程中有部份内容无法正常显示(例于数据库版本,数据库文件大小等),而且orabbix的日志显示中也会有以下的错误提示。
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;
设置完成后,可以通过以下的语句查看添加的状态。
select utl_inaddr.get_host_name('127.0.0.1') from dual;
7.配置文件
orabbix所有的配置文件都在conf目录中,需要将默认的配置文件config.props.sample复制一份后再进行修改和配置。
cd conf
cp config.props.sample config.props
vim config.progs
ZabbixServerList=ZabbixServer
ZabbixServer.Address=10.21.255.236
ZabbixServer.Port=10051
OrabbixDaemon.PidFile=./logs/orabbix.pid
OrabbixDaemon.Sleep=300
OrabbixDaemon.MaxThreadNumber=100
DatabaseList=CRMDB
DatabaseList.MaxActive=10
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1
CRMDB.Url=jdbc:oracle:thin:@10.21.100.5:1521:dsdfdb--实例名
CRMDB.User=ZABBIX
CRMDB.Password=ZABBIX
CRMDB.MaxActive=10
CRMDB.MaxWait=100
CRMDB.MaxIdle=1
CRMDB.QueryListFile=./conf/query.props
需要注意的是DatabaseList=CRMDB指的是被监控服务器的名称,该名称要和zabbix server界面中的机器名称保持一致,该配置文件中后续所引用的设定都以该名称为准。
CRMDB.Url=jdbc:oracle:thin:@192.168.0.209:1521:orcl指定的是被监控服务器的连接信息(例如采用jdbc的联接方式,服务器地址是192.168.0.209,oracle的端口是1521,orcl指的是数据库的实例)
8.配置并启动orabbix服务
chkconfig --add orabbix
chkconfig --level 345 orabbix on
service orabbix start
tail –f /opt/orabbix/logs/orabbix.log
可能遇到的问题
[root@mqserver template]# service orabbix start
Starting Orabbix service:
/opt/orabbix/run.sh: /usr/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录
解决方法:
[root@mqserver template]# sudo yum install glibc.i686
9.配置javahome
查找java路径
[root@localhost ~]# which java
/usr/bin/java
[root@localhost ~]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 Aug 17 15:12 /usr/bin/java -> /etc/alternatives/java
[root@localhost ~]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 46 Aug 17 15:12 /etc/alternatives/java -> /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
配置javahome
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_60/bin/java
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
配置软连接
ln -s /usr/java/jdk1.8.0_60/bin/java java
10.安装zabbix
zabbix-agent-3.2.6-1.el6.x86_64.rpm
配置zabbix config
启动服务
/etc/init.d/zabbix-agent restart(centos6版本启动方式)
systemctl restart zabbix-agent.service (centos7版本启动方式)
11.导入模板
配置===模板===导入模板
12.添加主机(名字必须跟config.props里面定义的名称的配置保持一致)
(主机名称一定要与配置中的 DatabaseList=DB_QM保持一致)!
13.模板中的主机和模板名字一定要正确