Zabbix-Orabbix插件监控Oracle 11g
介绍:
使用Orabbix插件
由于agent2监控oracle目前只支持oracle12以上,所以低于12c版本的oracle需要用Orabbix插件来监控oracle11g
一、Server端安装JDK
二、Server端安装Orabbix插件
三、添加模板
一、Server端安装JDK
jdk压缩包链接:https://pan.baidu.com/s/1-BVMfG1thDfMN0bPKIo-nA
提取码:QGS1
首先得安装Server端的JKD:
1.创建两个文件夹,/export/sort、/export/install
mkdir -p /export/sort
mkdir -p /export/install
2.把jkd压缩包上传到/export/sort里
3.cd进入/export/sort,tar命令解压jkd文件到export/install/里
cd /export/sort
tar -zxvf /export/sort/jdk-linux-x64.tar.gz -C /export/install/
4.编辑java.sh脚本,编辑JAVA_HOME的路径及导出路径
vi /etc/profile.d/java.sh
export JAVA_HOME=/export/install/jdk1.8.0_131/
export PATH=$PATH:$JAVA_HOME/bin
5.进入/export/install/jdk1.8.0_131里,更新profile
cd /export/install/jdk1.8.0_131/
source /etc/profile
jps
6.验证
java -version
二、Server端安装Orabbix插件
1.创建/opt/orabbix目录
mkdir -p /opt/orabbix
2.安装wget和unzip命令并下载orabbix安装文件到/opt/目录并解压文件
yum -y install wget
yum -y install unzip
3.切换到/opt/目录
cd /opt/
wget https://jaist.dl.sourceforge.net/project/orabbix/orabbix-1.2.3.zip
4.解压文件到/opt/orabbix
unzip -o orabbix-1.2.3.zip -d /opt/orabbix/
5.拷贝orabbix模板配置文件
cp /opt/orabbix/conf/config.props.sample /opt/orabbix/conf/config.props
6.拷贝orabbix启动文件并授权
cp /opt/orabbix/init.d/orabbix /etc/init.d/
chmod u+x /etc/init.d/orabbix
chmod u+x /opt/orabbix/run.sh
7.安装 net-tools
yum -y install net-tools
8.查看zabbix端口
netstat -tnlp|grep zabbix
9.配置config.props文件
vi /opt/orabbix/conf/config.props
附:
#查看实例名
select instance_name from v$instance;
#查看服务名
select global_name from global_name;
添加ojdbc8.jar驱动,删除jdbc6.jar驱动,ojdbc6.jar驱动的认证协议不匹配。
ojdbc8.jar驱动链接:https://pan.baidu.com/s/1hEABz4ww-AoiMgso6H1Xhw
提取码:QGS1
10.把ojdbc8.jar移动到/opt/orabbox/lib下面
mv ojdbc8.jar /opt/orabbix/lib/
11.删除ojdbc6.jar
rm -rf /opt/orabbix/lib/ojdbc6.jar
12.给ojdbc8.jar授权
chown -Rf root.root /opt/orabbix/lib/ojdbc8.jar
chmod 644 /opt/orabbix/lib/ojdbc8.jar
13.安装git命令
yum install -y git
14.重新编译orabbix-1.2.3.jar
cd /usr/local/src/
git clone https://github.com/snickerjp/orabbix.git
cd orabbix/
cp -rf /opt/orabbix-1.2.3.zip ./
mkdir orabbix-1.2.3
unzip -o orabbix-1.2.3.zip -d orabbix-1.2.3/
15.拷贝orabbix-1.2.3.jar和lib库下的jar包到指定文件
javac -cp "orabbix-1.2.3/orabbix-1.2.3.jar:orabbix-1.2.3/lib/*" com/smartmarmot/orabbix/Sender.java
16.创建build目录并把orabbix-1.2.3.jar复制到build
mkdir -p ./build
cp orabbix-1.2.3/orabbix-1.2.3.jar ./build
17.切换到./build目录下操作,重新打包orabbix
cd ./build
jar -xvf orabbix-1.2.3.jar com
cp ../com/smartmarmot/orabbix/Sender.class com/smartmarmot/orabbix/Sender.class
jar -uf orabbix-1.2.3.jar com
cp -rf orabbix-1.2.3.jar /opt/orabbix/orabbix-1.2.3.jar
18.切换到orabbix目录下,一系列操作
cd /opt/orabbix/
运行./run.sh
./run.sh
加入开机启动
chkconfig --add orabbix
验证开机启动项
chkconfig orabbix on
启动orabbix
systemctl start orabbix
验证orabbix是否启动
ps aux | grep orabbix
检查orabbix日志是否报错,如下图,说明没有报错,有报错就处理报错即可
tail -f /opt/orabbix/logs/orabbix.log
19.由于无法监控到数据库大小所以进入该文件,进行添加一些语句
vi /opt/orabbix/conf/query.props
在QueryList=下增加
dbfilesize,dbsize
在最后添加如下内容
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')
三、添加模板
1.将/opt/orabbix目录下template里的文件导入模板
cd /opt/orabbix
2.将template里的四个文件一一导入
=>=>=>
3.添加主机
参考博客:
- 点赞
- 收藏
- 关注作者
评论(0)