Zabbix2.2安装配置

Zabbix监控系统部署
本文介绍如何部署Zabbix监控系统,包括安装LAMP环境、Zabbix Server及其组件、配置数据库和Web界面等步骤,并覆盖了常见问题的解决方法。

简介:

zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。

zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据

Server端:通过收集SNMP和agent发送的数据,写入MySQL数据库,再通过php+apache在web前端展示。

它可以运行在Linux, Unix,Windows等平台上。Zabbix Server需要运行在LAMP环境。

特点:

支持多语言(包括中文)

免费开源

自动发现服务器与网络设备

分布式监视以及WEB集中管理功能

可以无agent监视

用户安全认证和柔软的授权方式

通过WEB界面设置或查看监视结果

- email等通知功能

Zabbix主要功能:

- CPU负荷

内存使用

磁盘使用

网络状况

端口监视

日志监视

下载:http://sourceforge.net/projects/zabbix/files/ZABBIXLatest Stable/2.2.1/zabbix-2.2.1.tar.gz

1、安装LAMP环境

1
2
3
4
5
6
7
8
9
[root@monitor ~] # yum install httpd mysql mysql-server mysql-devel php php-mysql php-gd php-bcmath php-xml php-mbstring net-snmp net-snmp-devel curl-devel –y
[root@monitor ~] # service httpd start
[root@monitor ~] # chkconfig httpd on
[root@monitor ~] # service mysqld start
[root@monitor ~] # mysqladmin -u root password 123.com
[root@monitor ~] # chkconfig mysqld on
[root@monitor ~] # vi /etc/my.cnf
[mysqld]
character_set_server=utf8    #设置数据库默认编码

2、安装Zabbix Server

1
2
3
4
5
6
[root@monitor ~] # groupadd zabbix
[root@monitor ~] # useradd -g zabbix -s /sbin/nologin zabbix
[root@monitor ~] # tar zxvf zabbix-2.2.1.tar.gz
[root@monitor ~] # cd zabbix-2.2.1
[root@monitor zabbix-2.2.1] # ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
[root@monitor zabbix-2.2.1] # make && make install

常用参数说明

--enable-server #安装zabbix server

--enable-proxy #安装zabbix proxy

--enable-agent #安装zabbix agent(如果不监控本机也可以不装)

--with-mysql #使用mysql做数据库

--with-net-snmp #支持snmp协议

--with-libcurl #支持curl,用于web服务监控

编译报错:

checking whether build environment is sane... configure:error: newly created file is older than distributed files!

Check your system clock

解决:这是由于系统时间不对导致的,设置系统时间即可

[root@monitor zabbix-2.2.1]# date -s "2013-12-1110:24:00"

[root@monitor zabbix-2.2.1]# hwclock #写入硬件时间

3、导入数据库

1
2
3
[root@monitor zabbix-2.2.1] # mysql -u root -p123.com -hlocalhost zabbix < database/mysql/schema.sql
[root@monitor zabbix-2.2.1] # mysql -u root -p123.com -hlocalhost zabbix < database/mysql/images.sql
[root@monitor zabbix-2.2.1] # mysql -u root -p123.com -hlocalhost zabbix < database/mysql/data.sql

4、定义服务端口

1
2
3
4
5
[root@monitor ~] # vi /etc/services
zabbix-agent   10050 /tcp    #zabbixagent
zabbix-agent    10050 /udp    #zabbix agent
zabbix-trapper 10051 /tcp    #zabbix trapper
zabbix-trapper 10051 /udp    #zabbix trapper

5、修改配置文件

1
2
3
[root@monitor zabbix-2.2.1] # cpmisc/init.d/fedora/core/zabbix_server /etc/init.d/
[root@monitor zabbix-2.2.1] # cpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@monitor zabbix-2.2.1] # cp -R frontends/php/ /var/www/html/zabbix  #复制网站程序

1
2
3
4
5
[root@monitor ~] # vi /usr/local/zabbix/etc/zabbix_server.conf
LogFile= /tmp/zabbix_server .log   #zabbix服务日志
DBName=zabbix    #数据库名字
DBUser=root    #数据库用户
DBPassword=123.com   #数据库密码

#修改启动脚本zabbix安装目录位置

1
2
3
4
[root@monitor ~] # vi /etc/init.d/zabbix_server
BASEDIR= /usr/local/zabbix
[root@monitor ~] # vi /etc/init.d/zabbix_agentd
BASEDIR= /usr/local/zabbix

6、加入系统服务

1
2
3
4
5
6
[root@monitor ~] # /etc/init.d/zabbix_server start
[root@monitor ~] # /etc/init.d/zabbix_agentd start
[root@monitor ~] # chkconfig --add zabbix_server
[root@monitor ~] # chkconfig zabbix_server on
[root@monitor ~] # chkconfig --add zabbix_agentd
[root@monitor ~] # chkconfig zabbix_agentd on

#查看zabbix启动进程及端口号

从下面看出,zabbix_server默认使用TCP/10051,启动了好多进程,分别处理不同任务

170048774.jpg7、zabbix web页面初始化设置

输入:http://192.168.1.153/zabbix/访问zabbix页面

141155253.png

Fail失败之处是PHP没有满足Zabbix要求,我们对其修改

1
2
3
4
5
6
[root@monitor ~] # vi /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date .timezone = Asia /Shanghai
[root@monitor ~] # /etc/init.d/httpd restart

141210883.png

点击Retry重试,可以看到全部OK了。

141221816.png

配置连接Mysql

141233737.png

141319479.png141334759.png

提示zabbix.conf.php配置文件创建失败,我们需要点击Downloadconfiguretion file下载这个配置文件,然后上传到/var/www/html/zabbix/conf目录,然后重试就行了。

141354384.png

可以看到已经OK,点击完成就能到zabbix登陆页面了。默认用户是admin,密码是zabbix

141406413.png

141416132.png

设置中文字体,点击右上角Profile,Language选择Chinese (zh CN),再点击Save保存。

141434212.png

141446454.png

自带的字体有点不好看,我们可以选择windows系统里C:\Windows\Fonts下的字体来用,

1
2
3
[root@monitor ~] # cd /var/www/html/zabbix/fonts/
[root@monitor fonts] # mv DejaVuSans.ttf DejaVuSans.ttf.bak
[root@monitor fonts] # mv simsunb.ttf DejaVuSans.ttf

8、zabbix监控已经搭建好了,默认是关闭对本机监控

手动开启:Configuration —> Hosts —> Status --> 点击Not monitored

监控本地的一些资源类型(Item)、Graphs都已经创建了,所以我们直接使用就行了,我们可以查看一下生产的图像页面,Configuration --> Screens --> Zabbix server,可以自定义添加显示的资源、列数和行数。

144722253.jpg


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值