Zabbix2.2安装配置

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

简介:

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

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
存储 监控 前端开发
|
监控 关系型数据库 MySQL
zabbix4.0安装配置及使用
zabbix4.0安装配置及使用
5847 0
|
监控 关系型数据库 应用服务中间件
|
监控 关系型数据库 MySQL
|
监控 关系型数据库 PHP
|
关系型数据库 应用服务中间件 PHP
|
SQL 监控 关系型数据库