Zabbix安装部署(for rhel5.7)之前的Nagios与Cacti整合部署(for_RHEL_5.7) 与这篇Zabbix安装部署(for rhel5.7)都是学习监控时网络查询和实操所做,在这里非常感谢网友门的开源精神,大家共同学习,每天进步一点,积累就是收获For Think email:cnbjthink@ (*^__^*) 。
Word导出PDF,文档可能错位但不影响观看,请不要计较。
一> Zabbix简介Zabbix 是一个提供Web 管理界面的企业级的开源系统/网络监控分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利。
官方网站:Zabbix 1.8官方文档:/documentation/1.8/startZabbix通过C/S模式采集数据,通过B/S模式在web端展示和配置。
被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据Server端:通过收集SNMP和agent发送的数据,写入MySQL数据库,再通过php+apache 在web前端展示。
Zabbix运行条件:Server:Zabbix Server需运行在LAMP(Linux+Apache+Mysql+PHP)环境下,对硬件要求低Agent:目前已有的agent基本支持市面常见的OS,包含Linux、HPUX、Solaris、Sun、windows SNMP:支持各类常见的网络设备二> Zabbix功能具备常见的商业监控软件所具备的功能(主机的性能监控、网络设备性能监控、数据库性能监控、FTP等通用协议监控、多种告警方式、详细的报表图表绘制)支持自动发现网络设备和服务器,支持分布式,能集中展示、管理分布式的监控点,扩展性强,server提供通用接口,可以自己开发完善各类监控三>优劣势优点:开源,无软件成本投入Server对设备性能要求低(实际测试环境:虚拟机Redhat EL AS5,2GCPU 1G内存,监控5台设备,CPU使用率基本保持在10%以下,内存剩余400M以上)支持设备多支持分布式集中管理开放式接口,扩展性强缺点:全英文,界面不友好无厂家支持,出现问题解决比较麻烦需在被监控主机上安装agent四>下载软件:/project/zabbix/ZABBIX%20Latest%20Stable/1.8.9/zab bix-1.8.9.tar.gz/downloads/1.8.5/zabbix_agents_1.8.5.linux2_6.amd64.tar.gz/downloads/1.8.5/zabbix_agents_1.8.5.linux2_6.i386.tar.gz安装前先配置好PHP,要求支持php-gd、php-bcmath、php-xml、php-mysql、php-net-socket、php-mbstring,即configure 参数中加上–with-gd –enable-bcmath –enable-xml –with-mysql –enable-sockets –enable-mbstring由于zabbix是基于web界面将存储在数据库中的数据成图表显示出来,所以zabbix需要运行在web和数据库的平台上,在这里我们使用lemp环境。
Linuxtone提供了自动部署lemp的脚本,只需下载后解压运行里面的lemp.sh即可,或者leam脚本(Apache与Nginx 看需求)基于lemp改编的,可以问我要lemp下载地址:/docs/autoinstall/lemp_auto_v1.0.6.tar.gz五>开始安装:redhat 提前安装好YUM确保能用,安装zabbix所需的组件[root@rhel ~]# yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath1> install lemp.sh[root@rhel ~]# cd /usr/local/src/[root@rhel src]# wget /docs/autoinstall/lemp_auto_v1.0.6.tar.gz[root@rhel src]# tar xzvf lemp_auto_v1.0.6.tar.gz[root@rhel src]# cd lemp[root@rhel lemp]# ./lemp.sh (估计半小时左右,依据个人网络和机器性能而定)2> install zabbix (为zabbix创建自己的数据库,以便zabbix可以把收集到的数据信息存放在那里调用)[root@rhel src]# useradd zabbix[root@rhel src]# passwd zabbix[root@rhel src]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.1.56-LTOPS-log Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database zabbix;Query OK, 1 row affected (0.02 sec)mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix' ;Query OK, 0 rows affected (0.08 sec)mysql> quitBye[root@rhel src]# tar xzvf zabbix-1.8.9.tar.gz[root@rhel src]# cd zabbix-1.8.9[root@rhel zabbix-1.8.9]# mysql -u root zabbix < create/schema/mysql.sql[root@rhel zabbix-1.8.9]# mysql -u root zabbix < create/data/data.sql[root@rhel zabbix-1.8.9]# mysql -u root zabbix < create/data/images_mysql.sql[root@rhel zabbix-1.8.9]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql=/usr/local/mysql-5.1.56/bin/mysql_config --with-net-snmp --with-libcurl--prefix指定zabbix安装目录,--enable-server 支持zabbix服务器,--enable-agent支持zabbix 代理,--enable-proxy 支持zabbix代理服务器,--with-mysql 使用MySQL客户端库可以选择指定路径mysql_config,--with-net-snmp 使用net-snmp软件包,择性地指定路径net-snmp配置, --with-libcurl 使用curl包[root@rhel zabbix-1.8.9]# make && make install添加zabbix服务对应的端口[root@rhel zabbix-1.8.9]# cat >> /etc/services << EOFzabbix-agent 10050/tcp Zabbix Agentzabbix-agent 10050/udp Zabbix Agentzabbix-trapper 10051/tcp Zabbix Trapperzabbix-trapper 10051/udp Zabbix TrapperEOF[root@rhel zabbix-1.8.9]#[root@rhel zabbix-1.8.9]# mkdir /etc/zabbixcp: omitting directory `misc/conf/zabbix_agentd'[root@rhel zabbix-1.8.9]# cp -r frontends/php/ /data/www/wwwroot/zabbix修改zabbix连接的数据库的用户名和密码[root@rhel zabbix-1.8.9]# vim /etc/zabbix/zabbix_server.conf (set nu)86 DBName=zabbix102 DBUser=zabbix112 DBPassword=zabbix为zabbix 的启动、关闭和重启的脚本文件做链接,方便系统可以找得到[root@rhel zabbix-1.8.9]# cd /usr/local/zabbix/bin/[root@rhel bin]# for i in *;do ln -s /usr/local/zabbix/bin/${i} /usr/bin/${i};done[root@rhel bin]# cd /usr/local/zabbix/sbin/[root@rhel sbin]# for i in *;do ln -s /usr/local/zabbix/sbin/${i} /usr/sbin/${i};done把mysql的lib库文件添加到系统动态库配置文件中,方便系统可以找到mysql的lib库[root@rhel sbin]# echo "/usr/local/mysql-5.1.56/lib/mysql/" >> /etc/ld.so.conf[root@rhel sbin]# ldconfig (立即生效)将zabbix相关的启动脚本等文件拷贝的/etc/init.d/下,方便日后对zabbix 的启动关闭操作[root@rhel sbin]# cd /usr/local/src/zabbix-1.8.9[root@rhel zabbix-1.8.9]# cp misc/init.d/redhat/8.0/zabbix_server /etc/init.d/[root@rhel zabbix-1.8.9]# chmod +x /etc/init.d/zabbix_server[root@rhel zabbix-1.8.9]# cp misc/init.d/redhat/8.0/zabbix_agentd /etc/init.d/[root@rhel zabbix-1.8.9]# chmod +x /etc/init.d/zabbix_agentd修改zabbix server和agentd程序目录的位置[root@rhel zabbix-1.8.9]# vim /etc/init.d/zabbix_server (set nu)17 progdir="/usr/local/zabbix/sbin/"[root@rhel zabbix-1.8.9]# vim /etc/init.d/zabbix_agentd (set nu)17 progdir="/usr/local/zabbix/sbin/"添加开机启动服务[root@rhel zabbix-1.8.9]# chkconfig --add zabbix_agentd[root@rhel zabbix-1.8.9]# chkconfig --level 345 zabbix_server on[root@rhel zabbix-1.8.9]# chkconfig --level 345 zabbix_agentd on[root@rhel zabbix-1.8.9]# chkconfig --list | grep zabbix(使用chkconfig --list 检查一下)在nginx 配置文件中建立zabbix 虚拟机的配置文件[root@rhel zabbix-1.8.9]# cat > /usr/local/nginx/conf/vhosts/monitor.conf << EOFserver {listen 80;server_name ;#access_log logs/zabbix_access.log main;location / {root /data/www/wwwroot/zabbix;index index.html index.htm index.php;}location ~ \.php$ {root /data/www/wwwroot/zabbix;fastcgi_pass 127.0.0.1:9000;fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_index index.php;include fastcgi_params;}}EOF对php配置文件做相应的调整,使其满足zabbix运行的最低环境要求[root@rhel zabbix-1.8.9]# vim /usr/local/php-5.2.17/etc/php.ini255 max_execution_time = 300256 max_input_time = 300439 post_max_size = 16M663 [Date]664 ; Defines the default timezone used by the date functions665 date.timezone = Asia/Shanghai[root@rhel ~]# cd /data/www/wwwroot/zabbix/[root@rhel zabbix]# chmod 777 conf (权限不给的话web界面安装到最后一步会报错)[root@rhel ~]# /etc/init.d/zabbix_agentd restart[root@rhel ~]# /etc/init.d/zabbix_server restart[root@rhel ~]# /etc/init.d/fastcgi restart[root@rhel ~]# /etc/init.d/mysqld restart[root@rhel ~]# /etc/init.d/snmpd restartweb enter install zabbix:http://IP/zabbix/,用户名和密码为默认:admin/zabbix,进入zabbix 安装界面,同意许可协议,环境最低要求(前面对php 配置文件的修改),数据库连接配置(连接mysql的用户名和密码之前以配置,zabbix/zabbix),zabbix server的信息,next,next,完成安装,对zabbix进行汉化,中文的监控界面wget /wp-content/uploads/2010/03/cn_zh.inc.php_.tar.gz解压后的文件复制到/data/www/wwwroot/zabbix/include/locales下覆盖原来的文件,重启zabbix登陆zabbix监控界面,点击zabbix首页右上角porfile,language中选择Chinese(CN)保存即可,完成看监控页面屏幕。