Loading... <p>一.Zabbix简介 <br />Zabbix 是一个提供 Web 管理界面的企业级的开源系统/网络监控分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利。 <br />官方网站:<span class="external-link"><a class="no-external-link" href="http://www.zabbix.com" target="_blank"><i data-feather="external-link"></i>http://www.zabbix.com</a></span> <br />英文安装文档 <span class="external-link"><a class="no-external-link" href="http://www.zabbix.com/wiki/howto/install/centos/centosinstall" target="_blank"><i data-feather="external-link"></i>http://www.zabbix.com/wiki/howto/install/centos/centosinstall</a></span> <br />Zabbix通过C/S模式采集数据,通过B/S模式在web端展示和配置。 <br />被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据 <br />Server端:通过收集SNMP和agent发送的数据,写入MySQL数据库,再通过php+apache在web前端展示。 <br />Zabbix运行条件: <br />Server: <br />Zabbix Server需运行在LAMP(Linux+Apache+Mysql+PHP)环境下,对硬件要求低 <br />Agent: <br />目前已有的agent基本支持市面常见的OS,包含Linux、HPUX、Solaris、Sun、windows <br />SNMP: <br />支持各类常见的网络设备</p> <p>二. Zabbix功能 <br />  具备常见的商业监控软件所具备的功能(主机的性能监控、网络设备性能监控、数据库性能监控、FTP等通用协议监控、多种告警方式、详细的报表图表绘制) <br />支持自动发现网络设备和服务器,支持分布式,能集中展示、管理分布式的监控点,扩展性强,server提供通用接口,可以自己开发完善各类监控</p> <p>三.优劣势 <br />优点: <br />开源,无软件成本投入 <br />Server对设备性能要求低(实际测试环境:虚拟机Redhat EL AS5,2GCPU 1G内存,监控5台设备,CPU使用率基本保持在10%以下,内存剩余400M以上) <br />支持设备多 <br />支持分布式集中管理 <br />开放式接口,扩展性强 <br />缺点: <br />全英文,界面不友好 <br />无厂家支持,出现问题解决比较麻烦 <br />需在被监控主机上安装agent <br />-------------------------------------------------------- <br />安装开始 <br />安装条件:a.以root用户运行所有命令 b.连接网络 (建议搭建先搭建本地yum)</p> <p>1.搭建YUM <br />[root@rhel ~]# yum -y install httpd php php-mysql mysql-server mysql-client curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath zlib-devel mysql-devel glibc-devel gcc automake libidn-devel openssl-devel net-snmp-devel rpm-devel OpenIPMI-devel</p> <p>2. install zabbix <br />(为zabbix创建自己的数据库,以便zabbix可以把收集到的数据信息存放在那里调用) <br />[root@rhel src]# useradd zabbix <br />[root@rhel src]# passwd zabbix <br />[root@rhel src]# mysql -u root -p <br />Enter password: <br />Welcome to the MySQL monitor.  Commands end with ; or \g. <br />Your MySQL connection id is 1 <br />Server version: 5.1.56-LTOPS-log Source distribution</p> <p>Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. <br />This software comes with ABSOLUTELY NO WARRANTY. This is free software, <br />and you are welcome to modify and redistribute it under the GPL v2 license</p> <p>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</p> <p>mysql> create database zabbix; <br />Query OK, 1 row affected (0.02 sec) <br />mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix' ; <br />Query OK, 0 rows affected (0.08 sec) <br />mysql> quit <br />Bye</p> <p> <br />[root@rhel src]# tar xzvf zabbix-1.8.12.tar.gz <br />[root@rhel src]# cd zabbix-1.8.12 <br />[root@rhel zabbix-1.8.12]# mysql -u root zabbix < create/schema/mysql.sql <br />[root@rhel zabbix-1.8.12]# mysql -u root zabbix < create/data/data.sql <br />[root@rhel zabbix-1.8.12]# mysql -u root zabbix < create/data/images_mysql.sql <br />[root@rhel zabbix-1.8.12]# ./configure --enable-server --with-mysql --with-net-snmp --with-jabber --with-libcurl --with-openipmi --enable-agent</p> <p> <br />--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包</p> <p>注意啦:请执行两次以上 ./configure ,检查是否有错误</p> <p>[root@rhel zabbix-1.8.12]# make && make install</p> <p>添加zabbix服务对应的端口</p> <p>[root@rhel zabbix-1.8.12]# cat >> /etc/services << EOF <br />zabbix-agent 10050/tcp Zabbix Agent <br />zabbix-agent 10050/udp Zabbix Agent <br />zabbix-trapper 10051/tcp Zabbix Trapper <br />zabbix-trapper 10051/udp Zabbix Trapper <br />EOF</p> <p>[root@rhel zabbix-1.8.12]# <br />[root@rhel zabbix-1.8.12]# mkdir /etc/zabbix <br />[root@rhel zabbix-1.8.12]# cp misc/conf/* /etc/zabbix/ <br />cp: omitting directory `misc/conf/zabbix_agentd' <br />[root@rhel zabbix-1.8.12]# cp -r frontends/php/* /var/www/html/zabbix</p> <p>修改zabbix连接的数据库的用户名和密码</p> <p>[root@rhel zabbix-1.8.12]# vim /etc/zabbix/zabbix_server.conf     </p> <p>86 DBName=zabbix <br />102 DBUser=zabbix <br />112 DBPassword=zabbix</p> <p>为 zabbix 的启动、关闭和重启的脚本文件做链接,方便系统可以找得到</p> <p>[root@rhel zabbix-1.8.12]# cd /usr/local/zabbix/bin/ <br />[root@rhel bin]# for i in *;do ln -s /usr/local/zabbix/bin/${i} /usr/bin/${i};done <br />[root@rhel bin]# cd /usr/local/zabbix/sbin/ <br />[root@rhel sbin]# for i in *;do ln -s /usr/local/zabbix/sbin/${i} /usr/sbin/${i};done</p> <p>把mysql的lib库文件添加到系统动态库配置文件中,方便系统可以找到mysql的lib库</p> <p>[root@rhel sbin]# echo "/usr/local/mysql-5.1.56/lib/mysql/" >> /etc/ld.so.conf <br />[root@rhel sbin]# ldconfig        (立即生效)</p> <p>将zabbix相关的启动脚本等文件拷贝的/etc/init.d/下,方便日后对 zabbix 的启动关闭操作</p> <p>[root@rhel sbin]# cd /usr/local/src/zabbix-1.8.12 <br />[root@rhel zabbix-1.8.12]# cp misc/init.d/redhat/8.0/zabbix_server /etc/init.d/ <br />[root@rhel zabbix-1.8.12]# chmod +x /etc/init.d/zabbix_server <br />[root@rhel zabbix-1.8.12]# cp misc/init.d/redhat/8.0/zabbix_agentd /etc/init.d/ <br />[root@rhel zabbix-1.8.12]# chmod +x /etc/init.d/zabbix_agentd </p> <p>修改zabbix server和agentd程序目录的位置</p> <p>[root@rhel zabbix-1.8.12]# vim /etc/init.d/zabbix_server</p> <p>17 progdir="/usr/local/zabbix/sbin/"</p> <p>[root@rhel zabbix-1.8.12]# vim /etc/init.d/zabbix_agentd</p> <p>17 progdir="/usr/local/zabbix/sbin/"</p> <p>添加开机启动服务</p> <p>[root@rhel zabbix-1.8.12]# chkconfig --add zabbix_server <br />[root@rhel zabbix-1.8.12]# chkconfig --add zabbix_agentd <br />[root@rhel zabbix-1.8.12]# chkconfig --level 345 zabbix_server on <br />[root@rhel zabbix-1.8.12]# chkconfig --level 345 zabbix_agentd on <br />[root@rhel zabbix-1.8.12]# chkconfig --list | grep zabbix                <br />(使用 chkconfig --list 检查一下)</p> <p> <br />对php配置文件做相应的调整,使其满足zabbix运行的最低环境要求</p> <p>[root@rhel zabbix-1.8.12]# vim /usr/local/php-5.2.17/etc/php.ini</p> <p>255 max_execution_time = 300     <br />256 max_input_time = 300    <br />439 post_max_size = 16M <br />663 [Date] <br />664 ; Defines the default timezone used by the date functions <br />665 date.timezone = Asia/Shanghai</p> <p>[root@rhel ~]# cd /data/www/wwwroot/zabbix/ <br />[root@rhel zabbix]# chmod 777 conf    ;             (权限不给的话web界面安装到最后一步会报错) <br />[root@rhel ~]# /etc/init.d/zabbix_agentd restart <br />[root@rhel ~]# /etc/init.d/zabbix_server restart <br />[root@rhel ~]# /etc/init.d/fastcgi restart <br />[root@rhel ~]# /etc/init.d/mysqld restart <br />[root@rhel ~]# /etc/init.d/snmpd restart</p> <p>web enter install zabbix:<span class="external-link"><a class="no-external-link" href="http://IP/zabbix/,用户名和密码为默认:admin/zabbix,进入zabbix安装界面,同意许可协议,环境最低要求(前面对" target="_blank"><i data-feather="external-link"></i>http://IP/zabbix/,用户名和密码为默认:admin/zabbix,进入zabbix安装界面,同意许可协议,环境最低要求(前面对</a></span> php 配置文件的修改),数据库连接配置 (连接mysql的用户名和密码之前以配置,zabbix/zabbix),zabbix server的信息,next,next,完成安装,</p> <p>-------------------------------------------------------------------------------</p> <p>zabbix客户端软件安装配置(Linux操作系统)</p> <p>groupadd zabbix <br />useradd zabbix -g zabbix <br />password zabbix</p> <p>从zabbix Server上拷贝一份zabbix.agentd.conf 拷贝配置文件到/etc/zabbix目录下,修改配置文件中主机名和监控服务器</p> <p>vim /etc/zabbix/zabbix_agentd.conf</p> <p>     81 Server=服务器断IP <br />     92 Hostname=被监控端IP</p> <p> <br />在客户端服务器上添加zabbix监控端口</p> <p>cat >> /etc/services << EOF <br />zabbix-agent 10050/tcp Zabbix Agent <br />zabbix-agent 10050/udp Zabbix Agent <br />zabbix-trapper 10051/tcp Zabbix Trapper <br />zabbix-trapper 10051/udp Zabbix Trapper <br />EOF</p> <p>下载客户端 <br />tar -xzvf zabbix_agents_1.8.5.linux2_6.i386.tar.gz -C /usr/local/zabbix</p> <p>拷贝启动脚本到/etc/init.d目录下</p> <p>cd /usr/local/zabbix/sbin/ <br />cp zabbix_agentd /etc/init.d/ <br />chmod a+x /etc/init.d/zabbix_agentd</p> <p>/etc/init.d/zabbix_agentd start <br />ps -ef | grep zabbix_agentd</p> <p>iptables -A INPUT -p tcp -s 服务器IP -m multiport --dports 10050,10051 -jACCEPT </p> Last modification:October 6, 2023 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 如果觉得我的文章对你有用,请随意赞赏