Zabbix是完全开源的监控系统,同时整合了Cacti和Nagios,还提供了更多额外的功能如分布式监控、可以监控WEB页面的响应、代码、内容;适合大规模环境监控,支持10W以上设备;可布置分支机构代理服务器,减轻并发压力;
一、安装Zabbix
1、安装依赖软件包
[[email protected] ~]# yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI gcc
2、下载zabbix
http://www.zabbix.com/download.php
[[email protected] ~]# mkdir /home/zabbix [[email protected] ~]# cd /home/zabbix [[email protected] zabbix]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.5/zabbix-2.2.5.tar.gz
3、安装zabbix
[[email protected] zabbix]# useradd zabbix -s /sbin/nologin [[email protected] zabbix]# tar zvxf zabbix-2.2.5.tar.gz [[email protected] zabbix]# cd zabbix-2.2.5 [[email protected] zabbix-2.2.5]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl [[email protected] zabbix-2.2.5]# make install
4、创建数据库
[[email protected] zabbix-2.2.5]# mysql -uroot -p123456 >create database zabbix character set utf8; >grant all on zabbix.* to [email protected] identified by ‘zabbix‘; >flush privileges; >quit
5、导入数据
[[email protected] zabbix-2.2.5]# vi database/mysql/schema.sql :%s/ENGINE=InnoDB/ENGINE=InnoDB CHARACTER SET utf8/g #用于解决中文显示问号问题 [[email protected] zabbix-2.2.5]# mysql -uzabbix -pzabbix -hlocalhost zabbix < database/mysql/schema.sql [[email protected] zabbix-2.2.5]# mysql -uzabbix -pzabbix -hlocalhost zabbix < database/mysql/images.sql [[email protected] zabbix-2.2.5]# mysql -uzabbix -pzabbix -hlocalhost zabbix < database/mysql/data.sql
6、添加服务
[[email protected] zabbix-2.2.5]# cat >>/etc/services <<EOF > zabbix-agent 10050/tcp Zabbix Agent > zabbix-agent 10050/udp Zabbix Agent > zabbix-trapper 10051/tcp Zabbix Trapper > zabbix-trapper 10051/udp Zabbix Trapper > EOF
二、配置文件
1、配置Zabbix
[[email protected] zabbix-2.2.5]# vi /usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=zabbix
2、配置PHP
[[email protected] zabbix-2.2.5]# vi /etc/php.ini max_input_time = 600 max_execution_time = 300 date.timezone = Asia/Shanghai post_max_size = 32M memory_limit = 128M mbstring.func_overload = 2 [[email protected] zabbix-2.2.5]# service httpd restart
三、自动启动
1、修改参数
修改启动脚本中的路径/usr/local改成/usr/local/zabbix
[[email protected] zabbix-2.2.5]# cp misc/init.d/fedora/core/* /etc/init.d/ [[email protected] zabbix-2.2.5]# sed -i ‘s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g‘ /etc/init.d/zabbix_server [[email protected] zabbix-2.2.5]# sed -i ‘s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g‘ /etc/init.d/zabbix_agentd
2、启动进程
[[email protected] zabbix-2.2.5]# echo "/etc/init.d/zabbix_server start" >> /etc/rc.local [[email protected] zabbix-2.2.5]# echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.local [[email protected] zabbix-2.2.5]# /etc/init.d/zabbix_server start [[email protected] zabbix-2.2.5]# /etc/init.d/zabbix_agentd start
3、查看端口
[[email protected] zabbix-2.2.5]# netstat -npl|grep 10050 tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2404/zabbix_agentd [[email protected] zabbix-2.2.5]# netstat -npl|grep 10051 tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2380/zabbix_server
4、开放端口
[[email protected] zabbix-2.2.5]# iptables -I INPUT -p tcp --dport 10050:10051 -j ACCEPT [[email protected] zabbix-2.2.5]# iptables -I INPUT -p udp --dport 10050:10051 -j ACCEPT [[email protected] zabbix-2.2.5]# service iptables save
时间: 2024-12-29 11:26:46