一.jdk的安装(Orabbix Server)
1.软件解压,放到固定位置
1
2
|
tar zxf jdk-8u51-linux-x64. tar .gz
mv jdk1.8.0_51/ /usr/local/
|
2.设置系统变量,编辑/etc/profile在末尾增加
1
2
3
|
export JAVA_HOME= /usr/local/jdk1 .8.0_51
exportCLASSPATH=$JAVA_HOME /lib/dt .jar:$JAVA_HOME /lib/tools .jar
export PATH=$JAVA_HOME /bin :$PATH
|
3.执行一下/etc/profile使之生效
1
|
source /etc/profile
|
二.Oracle中增加监控用户,并设置相应的用户权限,这一步在sqlplus中完成(ORACLE服务器)
1
2
3
4
5
6
7
8
|
su - oracle sqlplus / as sysdba
SQL> CREATE USER zabbix
IDENTIFIED BY zabbix_password
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK; |
赋予zabbix用户对应权限
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
|
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_$LOG 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;
GRANT SELECT ON V_$locked_object TO ZABBIX;
GRANT SELECT ON dba_objects TO ZABBIX;
GRANT SELECT ON dba_tablespaces TO ZABBIX;
GRANT SELECT ON v_$session TO ZABBIX;
|
以上有部分小写的是我对其他文章的增加部分
如果数据库是11G,还要执行如下部分:
1
2
3
|
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 ;
|
三.安装orabbix(Orabbix Server)
其实orabbix只需要安装在一台服务器即可,我就选择安装在Zabbix Server上,当然上面的jdk是为orabbix服务的,因为orabbix就是一个oracle客户端去查找oracle中的数据,然后传给zabbix.
1
2
3
4
5
6
7
8
9
10
|
mkdir /usr/local/orabbix
cd /usr/local/orabbix
wget orabbix http: //nchc .dl.sourceforge.net /project/orabbix/orabbix-1 .2.3.zip
unzip orabbix-1.2.3.zip chmod +x run.sh
cp init.d /orabbix /etc/init .d/
sed -i 's#/opt/orabbix#orabbix=/usr/local/orabbix#g' /etc/init .d /orabbix
chmod +x /etc/init .d /orabbix
sed -i 's#java#/usr/local/jdk1.8.0_51/bin/java#g' /usr/local/orabbix/run .sh
#用以解决/usr/local/orabbix/run.sh: line 2: java: command not found这个错误 |
配置orabbix,进入/usr/local/orabbix/conf/目录
cd /usr/local/orabbix/conf
cp config.props.sample config.props
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
ZabbixServerList=ZabbixServer ZabbixServer.Address=192.168.0.81 ZabbixServer.Port=10051 OrabbixDaemon.PidFile=. /logs/orabbix .pid
OrabbixDaemon.Sleep=300 OrabbixDaemon.MaxThreadNumber=100 DatabaseList=tpy100 DatabaseList.MaxActive=10 DatabaseList.MaxWait=100 DatabaseList.MaxIdle=1 tpy100.Url=jdbc:oracle:thin:@192.168.0.209:1521:orcl tpy100.User=ZABBIX tpy100.Password=zabbix tpy100.MaxActive=10 tpy100.MaxWait=100 tpy100.MaxIdle=1 tpy100.QueryListFile=. /conf/query .props
|
需要注意的是DatabaseList=CRMDB指的是被监控服务器的名称,该名称要和zabbixserver界面中的机器名称保持一致,该配置文件中后续所引用的设定都以该名称为准。
CRMDB.Url=jdbc:oracle:thin:@192.168.0.209:1521:orcl 指定的是被监控服务器的连接信息(例如采用jdbc的联接方式,服务器地址是192.168.0.209,oracle的端口是1521,orcl指的是数据库的实例)
默认按照上面的步骤就差不多了,但是你导入模板之后就会发现监控项目不全,如dbsize及dbfilesize这些类目,orabbix默认情况下未开启数据库大小,需要配置query.props
编辑 /usr/local/orabbix/conf/query.props文件
在QueryList=类目下增加dbfilesize,dbsize,如图所示
然后在该文件的末尾添加
1
2
3
4
5
6
7
8
|
dbfilesize.Query= select to_char( sum (bytes /1024/1024/10 ), 'FM99999999999999990' ) retvalue from dba_data_files
dbsize.Query=SELECT to_char( sum ( NVL(a.bytes /1024/1024/10 - NVL(f.bytes /1024/1024/10 , 0), 0)), 'FM99999999999999990' ) retvalue \
FROM sys.dba_tablespaces d, \ ( select tablespace_name, sum (bytes) bytes from dba_data_files group by tablespace_name) a, \
( select tablespace_name, sum (bytes) bytes from dba_free_space group by tablespace_name) f \
WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) \ AND NOT (d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY' )
|
用以定义查询dbfilesize,dbsize的SQL语句
这个时候就可以启动orabbix服务了
service orabbix start
检查服务ps aux |grep orabbix|wc -l 如果等于2就说明启动那个成功了,启动成功不一定就是没问题了,这个时候需要查看日志
/usr/local/orabbix/logs/orabbix.log
从以上可以看到我很多数据是抓不到的,都是因为权限的问题找不到表,于是就需要利用query.props
/usr/local/orabbix/conf/query.props
找到对应的表,如这里找archive的表
如果没有权限的话 就需要用DBA的权限进数据库给予权限
GRANT SELECT ON v_$LOG TO ZABBIX;
即可