zabbix+orabbix安装

Posted CHINA ORACLE-BASE

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix+orabbix安装相关的知识,希望对你有一定的参考价值。

zabbix + orabbix 监控oracle数据库

zabbix 监控搭建

一,LNMP环境搭建

LNMP环境搭建.md

二,zabbix服务端安装配置

(1)下载zabbix并安装
所有版本下载地址:http://www.zabbix.com/download.php

  1. yum install mysql-dev gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xm
  2. ./configure --prefix=/usr/local/zabbix-2.2.13/ --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
  3. make && make install

(2)创建用户

  1. groupadd zabbix
  2. useradd -g zabbix zabbix

(3)初始化数据库

  1. mysql -uroot -proot
  2. create database zabbix default charset utf8;
  3. cd cd zabbix-2.2.13/database/mysql/
  4. mysql -uroot -p zabbix < schema.sql
  5. mysql -uroot -p zabbix < images.sql
  6. mysql -uroot -p zabbix < data.sql

(4)配置zabbix

  1. # mkdir /etc/zabbix
  2. # cp config/zabbix_server.conf /etc/zabbix/
  3. # vim /etc/zabbix/zabbix_server.conf
  4. DBName=zabbix
  5. DBUser=root
  6. DBPassword=root
  7. DBPort=3306

DBName 存放zabbix对象的数据库
DBUser 数据库名
DBPassword 数据库密码

(5)启动zabbix

  1. # /usr/local/zabbix-2.2.13/sbin/zabbix_server

默认端口10051

如果启动后显示不出10051监听或者进程单一,尝试修改/usr/local/zabbix-2.2.13/etc/zabbix_server.conf 安装目录下的配置文件

(6)zabbix网站管理配置 拷贝前端文件

  1. cp -rp frontends/php /usr/local/nginx/html/

浏览器打开进行图形配置

http://localhost/php

解决:

修改/usr/local/php/etc/php.ini

  1. max_execution_time = 300
  2. memory_limit = 128M
  3. post_max_size = 16M
  4. upload_max_filesize = 2M
  5. max_input_time = 300
  6. date.timezone = Asia/Shanghai

处理方法:安装Mysqli模块

  1. ###################
  2. # mysqli模块的安装 #
  3. ###################

原来在编译php的已经加了参数
–with-mysql=/usr/local/mysql \\
–with-mysqli=/usr/local/mysql/bin/mysql_config \\

mysqli是优化过的mysql函数库,MYSQL版本不能低于4.1.12

1.进入到mysqli的目录

无需专门下载mysqli,就在php安装包中!!!

  1. cd /root/php-5.5.38/ext/mysqli --- 解压的文件目录

2.使用phpize生成configure文件:

  1. [root@mss_db_monitor mysqli]# /usr/local/php/bin/phpize
  2. Configuring for:
  3. PHP Api Version: 20121113
  4. Zend Module Api No: 20121212
  5. Zend Extension Api No: 220121212
  1. ./configure --prefix=/usr/local/mysqli \\
  2. --with-php-config=/usr/local/php/bin/php-config \\ --根据环境实际路径:find / -name php-config
  3. --with-mysqli=/usr/local/mysql/bin/mysql_config ---根据环境实际路径:find / -name mysql_config
  4. make
  5. make test
  6. [root@mss_db_monitor mysqli]# make install
  7. Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
  8. Installing header files: /usr/local/php/include/php/
  9. [root@mss_db_monitor mysqli]#

3.然后在/usr/local/php/etc/php.ini
加上一句:

  1. extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/mysqli.so

4.重启php服务

  1. [root@mss_db_monitor no-debug-non-zts-20121212]# /etc/init.d/php-fpm restart
  2. Gracefully shutting down php-fpm . done
  3. Starting php-fpm done

5.点击Retry OK

又有错误!!!

解决方法,见文章最后!

登陆zabbix,默认用户名:Admin,密码:zabbix

开头的红色提示,下面解决!!!

三,zabbix客户端安装配置

完全参考:http://www.1987.name/760.html

上传文件,或者是直接从服务端scp到客户端

用户组建立

  1. groupadd -g 1006 zabbix
  2. useradd -u 1006 -g 1006 -s /sbin/nologix -M zabbix

安装

  1. tar zxvf zabbix-2.0.5.tar.gz && cd zabbix-2.0.5
  2. ./configure --prefix=/usr/local/zabbix --enable-agent
  3. make && make install

添加服务端口和修改启动脚本

  1. sed -i "/^# Local services/izabbix-agent 10050/tcp #Zabbix Agent" /etc/services
  2. sed -i "/^# Local services/izabbix-agent 10050/udp #Zabbix Agent" /etc/services
  3. cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
  4. sed -i \'s/BASEDIR=\\/usr\\/local\\/BASEDIR=\\/usr\\/local\\/zabbix/g\' /etc/init.d/zabbix_agentd
  5. chkconfig --add zabbix_agentd
  6. chkconfig zabbix_agentd on

修改zabbix_agent配置文件

  1. vim /usr/local/zabbix/etc/zabbix_agentd.conf
  2. Server=192.168.1.140
  3. Hostname=linux server1
  4. PidFile=/var/tmp/zabbix_agentd.pid
  5. LogFile=/var/log/zabbix/zabbix_agentd.log

创建日志

  1. >mkdir /var/log/zabbix
  2. touch /var/log/zabbix/zabbix_agentd.log
  3. chown -R zabbix.zabbix /var/log/zabbix

启动

  1. /etc/init.d/zabbix_agentd start

四,orabbix安装配置

参考:http://denghaibin.blog.51cto.com/4128215/1556816
http://www.smartmarmot.com/wiki/index.php/Orabbix

官方文档参考:https://www.zabbix.com/documentation/2.4/manual/installation/install

服务端
http://www.smartmarmot.com/product/orabbix/download/

  1. #mkdir /opt/orabbix
  2. #mv orabbix-1.2.3.zip /opt/orabbix
  3. #cd /opt/orabbit
  4. #unzip orabbix-1.2.3.zip
  1. #chmod a+x /opt/orabbix -R
  1. cat /opt/orabbix/conf/config.props.sample | grep -v "#" > /opt/orabbix/conf/config.props
  1. [root@localhost orabbix]# cat config.props
  2. ZabbixServerList=ZabbixServer1
  3. ZabbixServer1.Address=192.168.9.127
  4. ZabbixServer1.Port=10051
  5. #ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER
  6. #ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER
  7. OrabbixDaemon.PidFile=./logs/orabbix.pid
  8. OrabbixDaemon.Sleep=300
  9. OrabbixDaemon.MaxThreadNumber=100
  10. DatabaseList=p0cdb001,p0cap001,10.140.4.14,p5cwfdbb02,p5cwfdbb03
  11. DatabaseList.MaxActive=10
  12. DatabaseList.MaxWait=100
  13. DatabaseList.MaxIdle=1
  14. p0cdb001.Url=jdbc:oracle:thin:@192.168.68.51:1521:MDM1
  15. #ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER
  16. OrabbixDaemon.PidFile=./logs/orabbix.pid
  17. OrabbixDaemon.Sleep=300
  18. OrabbixDaemon.MaxThreadNumber=100
  19. DatabaseList=p0cdb001,p0cap001,10.140.4.14,p5cwfdbb02,p5cwfdbb03
  20. DatabaseList.MaxActive=10
  21. DatabaseList.MaxWait=100
  22. DatabaseList.MaxIdle=1
  23. p0cdb001.Url=jdbc:oracle:thin:@192.168.68.51:1521:MDM1
  24. p0cdb001.User=zabbix
  25. p0cdb001.Password=zabbix
  26. p0cdb001.MaxActive=10
  27. p0cdb001.MaxWait=100
  28. p0cdb001.MaxIdle=1
  29. p0cdb001.QueryListFile=./conf/query.props
  30. p0cap001.Url=jdbc:oracle:thin:@192.168.68.52:1521:MDM2
  31. p0cap001.User=zabbix
  32. p0cap001.Password=zabbix
  33. p0cap001.MaxActive=10
  34. p0cap001.MaxWait=100
  35. p0cap001.MaxIdle=1
  36. p0cap001.QueryListFile=./conf/query.props
  37. 10.140.4.14.Url=jdbc:oracle:thin:@10.140.4.14:1521:p5cwfb1
  38. 10.140.4.14.User=zabbix
  39. 10.140.4.14.Password=zabbix
  40. 10.140.4.14.MaxActive=10
  41. 10.140.4.14.MaxWait=100
  42. 10.140.4.14.MaxIdle=1
  43. 10.140.4.14.QueryListFile=./conf/query.props
  44. p5cwfdbb02.Url=jdbc:oracle:thin:@10.140.4.15:1521:p5cwfb2
  45. p5cwfdbb02.User=zabbix
  46. p5cwfdbb02.Password=zabbix
  47. p5cwfdbb02.MaxActive=10
  48. p5cwfdbb02.MaxWait=100
  49. p5cwfdbb02.MaxIdle=1
  50. p5cwfdbb02.QueryListFile=./conf/query.props
  51. p5cwfdbb03.Url=jdbc:oracle:thin:@10.140.4.16:1521:p5cwfb3
  52. p5cwfdbb03.User=zabbix
  53. p5cwfdbb03.Password=zabbix
  54. p5cwfdbb03.MaxActive=10
  55. p5cwfdbb03.MaxWait=100
  56. p5cwfdbb03.MaxIdle=1
  57. p5cwfdbb03.QueryListFile=./conf/query.props

注意:DatabaseList 中的名字和下面对应具体属性的名字一定要相同,并且和监控界面中显示的名字要相同,否则可能不能正常显示

客户端

  1. create user zabbix identified by "zabbix" default tablespace users temporary tablespace temp profile default account unlock;
  2. grant alter session to zabbix;
  3. grant create session to zabbix;
  4. grant connect to zabbix;
  5. alter user zabbix default role all;
  6. grant select on v_$instance to zabbix;
  7. grant select on dba_users to zabbix;
  8. grant select on v_$log_history to zabbix;
  9. grant select on v_$parameter to zabbix;
  10. grant select on sys.dba_audit_session to zabbix;
  11. grant select on v_$lock to zabbix;
  12. grant select on dba_registry to zabbix;
  13. grant select on v_$librarycache to zabbix;
  14. grant select on v_$sysstat to zabbix;
  15. grant select on v_$parameter to zabbix;
  16. grant select on v_$latch to zabbix;
  17. grant select on v_$pgastat to zabbix;
  18. grant select on v_$sgastat to zabbix;
  19. grant select on v_$librarycache to zabbix;
  20. grant select on v_$process to zabbix;
  21. grant select on dba_data_files to zabbix;
  22. grant select on dba_temp_files to zabbix;
  23. grant select on dba_free_space to zabbix;
  24. grant select on v_$system_event to zabbix;
  25. GRANT CONNECT TO ZABBIX;
  26. GRANT RESOURCE TO ZABBIX;
  27. ALTER USER ZABBIX DEFAULT ROLE ALL;
  28. -- 5 System Privileges for ZABBIX
  29. GRANT SELECT ANY TABLE TO ZABBIX;
  30. GRANT CREATE SESSION TO ZABBIX;
  31. GRANT SELECT ANY DICTIONARY TO ZABBIX;
  32. GRANT UNLIMITED TABLESPACE TO ZABBIX;
  33. GRANT SELECT ANY DICTIONARY TO ZABBIX;

11g执行下面语句

  1. exec dbms_network_acl_admin.create_acl(acl => \'resolve.xml\',description =>\'resolve acl\', principal =>\'ZABBIX\', is_grant => true, privilege =>\'resolve\');
  2. exec dbms_network_acl_admin.assign_acl(acl=> \'resolve.xml\', host =>\'*\');
  3. commit;

服务端操作

  1. #cp -a /opt/orabbix/init.d/orabbix /etc/init.d/orabbix
  2. #/etc/init.d/orabbix start
  3. Starting Orabbix service:
  4. # ps aux |grep orabbix

在图形界面上导入模板

模板在/opt/orabbix/template目录中

Orabbix_export_full.xml 全部导入(图表 监控项 触发器)
Orabbix_export_graphs.xml 图表
Orabbix_export_items.xml 监控项
Orabbix_export_triggers.xml 触发器

如有报错请先查看日志:

  1. [root@oracle orabbix]# tail -f /opt/orabbix/logs/orabbix.log

遇到的问题和解决方案


查看确实的库文件:

解决:
加入环境变量

  1. export LD_LIBRARY_PATH=/usr/lib64:/lib64:/usr/local/mysql/lib

让环境变量生效!

再次查看依赖包情况:

启动

成功!


解决:/usr/local/nginx/html/php 没有权限创建文件,分别修改各目录的权限,然后执行Retry

如果修改权限后依然不行,那么点击Download configuration file,把配置文件下载下来,然后再复制到/usr/local/nginx/html/php/conf/

报错原因:
配置php的时候没有加–with-gettext参数

yum install gettext-devel

解决办法:
重新编译gettext
http://xingxing5421.blog.163.com/blog/static/11944631920131213314768/

在php的源文件中进入/ext/gettext目录

  1. [root@mss_db_monitor ~]# cd php-5.5.38/ext/gettext/
  2. [root@mss_db_monitor gettext]# /usr/local/php/bin/phpize
  3. Configuring for:
  4. PHP Api Version: 20121113
  5. Zend Module Api No: 20121212
  6. Zend Extension Api No: 220121212
  7. [root@mss_db_monitor gettext]# ./configure -with-php-config=/usr/local/php/bin/php-config
  8. [root@mss_db_monitor gettext]# make && make install
  9. [root@mss_db_monitor gettext]# make test
  10. [root@mss_db_monitor ~]# vi /usr/local/php/etc/php.ini
  11. 加上下面内容
  12. extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/gettext.so

解决:
查看日志

修改端口号:

原来是10051


上面问题未解决,但是关联上再去掉关联不清理在下拉选项里依然存在主机的选项

—————————2016-09-18 21:27:41 星期日—————————————*

orabbix取不到数据,查看日志报如下错误:
[root@mss_db_monitor ~]# tail -f /opt/orabbix/logs/orabbix.log

取不到数据一定是配置文件config.props的问题

这个参数的端口号应该是zabbix server的端口号,应该为10051,原来为10050 ,修改完成后,重启orabbix进程,恢复正常!





以上是关于zabbix+orabbix安装的主要内容,如果未能解决你的问题,请参考以下文章

zabbix利用orabbix监控oracle

zabbix利用orabbix监控oracle

Zabbix利用orabbix插件监控Oracle数据库

orabbix 监控oracle

orabbix监控oracle

zabbix之 orabbix模板监控oracle