zabbix3.0安装教程

一、Zabbix介绍


zabbix 简介
Zabbix 是一个高度集成的网络监控解决方案,可以提供企业级的开源分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利
zabbix是一个基于Web界面的,提供分布式系统监控以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营,并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题
zabbix主要由2部分构成zabbix server和zabbix agent,可选组建zabbix proxy
zabbix server可以通过SNMP,zabbix agent,fping端口监视等方法对远程服务器或网络状态完成监视,数据收集等功能。同时支持Linux以及Unix平台,Windows平台只能安装客户端

 

Zabbix 功能
  ①具备常见的商业监控软件所具备的功能(主机的性能监控、网络设备性能监控、数据库、性能监控、FTP 等通用协议监控、多种告警方式、详细的报表图表绘制)
  ②支持自动发现网络设备和服务器(可以通过配置自动发现服务器规则来实现)
  ③支持自动发现(low discovery)key 实现动态监控项的批量监控(需写脚本)
  ④支持分布式,能集中展示、管理分布式的监控点
  ⑤扩展性强,server 提供通用接口(api 功能),可以自己开发完善各类监控(根据相关接口编写程序实现)编写插件容易,可以自定义监控项,报警级别的设置。
  ⑥数据收集

  •  可用和性能检测
  •  支持snmp(包括trapping and polling),IPMI,JMX,SSH,TELNET
  •  自定义的检测
  •  自定义收集数据的频率
  •  服务器/代理和客户端模式
  •  灵活的触发器
  •  可以定义非常灵活的问题阈值,称为触发器,从后端数据库的参考值
  •  高可定制的报警
  •  发送通知,可定制的报警升级,收件人,媒体类型
  •  通知可以使用宏变量有用的变量
  •  自动操作包括远程命令
  •  实时的绘图功能
  •  监控项实时的将数据绘制在图形上面

WEB 监控能力 

 ZABBIX 可以模拟鼠标点击了一个网站,并检查返回值和响应时间


Api 功能
  应用api功能,可以方便的和其他系统结合,包括手机客户端的使用。

更多功能请查看
http://www.zabbix.com/documentation.php


Zabbix版本
Zabbix 3.0 Manual
Zabbix 2.4 Manual
Zabbix 2.2 Manual
Zabbix 2.0 Manual
下载地址:http://www.zabbix.com/documentation.php

Zabbix优缺点

优点
 1、开源,无软件成本投入
 2、Server 对设备性能要求低
 3、支持设备多,自带多种监控模板
 4、支持分布式集中管理,有自动发现功能,可以实现自动化监控
 5、开放式接口,扩展性强,插件编写容易
 6、当监控的item 比较多服务器队列比较大时可以采用被动状态,被监控客户端主动从
 7、server 端去下载需要监控的item 然后取数据上传到server 端。这种方式对服务器的负载比较小。
 8、Api 的支持,方便与其他系统结合

缺点
  需在被监控主机上安装agent,所有数据都存在数据库里,产生的数据据很大,瓶颈主要在数据库。

Zabbix监控原理
Zabbix 通过C/S 模式采集数据,通过B/S模式在web 端展示和配置。
被监控端:主机通过安装agent 方式采集数据,网络设备通过SNMP 方式采集数据
Server 端:通过收集SNMP 和agent 发送的数据,写入数据库(MySQL,ORACLE 等),再通过php+apache 在web 前端展示。
Zabbix 运行条件
Server:Zabbix Server 需运行在LAMP(Linux+Apache+Mysql+PHP)环境下(或者LNMP),对硬件要求低
Agent:目前已有的agent 基本支持市面常见的OS,包含Linux、HPUX、Solaris、Sun、 windows
SNMP:支持各类常见的网络设备
SNMP(Simple Network Management Protocol,简单网络管理协议

Zabbix监控过程逻辑图

二、监控

1、监按对象

2、监控范围

  • 硬件监控
  • 操作系统监控
  • 应用服务监控
  • 业务监控

三、Zabbix服务端安装

1、环境

1 [root@zabbix-server ~]# cat /etc/redhat-release 
2 CentOS release 6.7 (Final)
3 
4 [root@zabbix-server ~]# uname -r
5 2.6.32-573.el6.x86_64
6 
7 [root@zabbix-server ~]# uname -m
8 x86_64

2、server端安装

1 rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
2 yum install httpd zabbix zabbix-server zabbix-web zabbix-server-mysql zabbix-web-mysql mysql-server -y

3、PHP安装

1 rpm -ivh http://mirror.webtatic.com/yum/el6/latest.rpm
2 yum install php55w php55w-mysql php55w-common php55w-gd php55w-mbstring php55w-mcrypt php55w-devel php55w-xml php55w-bcmath -y
3 yum remove zabbix-server-pgsql -y
4 cp -R /usr/share/zabbix/ /var/www/html/
5 #备注:zabbix3.0必须要php5.4以上,因此需要安装特殊源,才能够安装php5.5

4、MySQL配置

 1 [root@zabbix-server ~]#/etc/init.d/mysqld start
 2 
 3 Initializing MySQL database:  Installing MySQL system tables...
 4 161007 10:31:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
 5 OK
 6 Filling help tables...
 7 161007 10:31:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
 8 OK
 9 
10 To start mysqld at boot time you have to copy
11 support-files/mysql.server to the right place for your system
12 
13 PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
14 To do so, start the server, then issue the following commands:
15 
16 /usr/bin/mysqladmin -u root password 'new-password'
17 /usr/bin/mysqladmin -u root -h m01 password 'new-password'
18 
19 Alternatively you can run:
20 /usr/bin/mysql_secure_installation
21 
22 which will also give you the option of removing the test
23 databases and anonymous user created by default.  This is
24 strongly recommended for production servers.
25 
26 See the manual for more instructions.
27 
28 You can start the MySQL daemon with:
29 cd /usr ; /usr/bin/mysqld_safe &
30 
31 You can test the MySQL daemon with mysql-test-run.pl
32 cd /usr/mysql-test ; perl mysql-test-run.pl
33 
34 Please report any problems with the /usr/bin/mysqlbug script!
35 
36                                                            [  OK  ]
37 Starting mysqld:                                           [  OK  ]

5、创建用户并授权

 1 [root@zabbix-server ~]# mysql
 2 Welcome to the MySQL monitor.  Commands end with ; or g.
 3 Your MySQL connection id is 2
 4 Server version: 5.1.73-log Source distribution
 5 
 6 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 7 
 8 Oracle is a registered trademark of Oracle Corporation and/or its
 9 affiliates. Other names may be trademarks of their respective
10 owners.
11 
12 Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
13 
14 mysql> create database zabbix character set utf8 collate utf8_bin;
15 Query OK, 1 row affected (0.00 sec)
16 
17 mysql> grant all on zabbix.* to zabbix@'localhost' identified by '111111';
18 Query OK, 0 rows affected (0.00 sec)
19 
20 mysql> flush privileges;
21 Query OK, 0 rows affected (0.01 sec)
22 
23 mysql> exit
24 Bye

6、导入zabbix数据库文件

1 [root@zabbix-server]# cd /usr/share/doc/zabbix-server-mysql-3.0.5/
2 
3 #导入数据库文件
4 [root@zabbix-server zabbix-server-mysql-3.0.5]# zcat create.sql.gz |mysql -uzabbix -p111111 zabbix

7、修改相关配置文件

修改php配置文件

1 [root@zabbix-server]#vim /etc/php.ini
2 post_max_size = 16M
3 max_execution_time = 300
4 max_input_time = 300
5 date.timezone = Asia/shanghai

修改zabbix_server配置文件

1 [root@zabbix-server ~]# vi  /etc/zabbix/zabbix_server.conf
2 修改数据库地址、数据库名、 用户、密码
3 
4 分别对应
5 DBHost=localhost
6 DBName=zabbix
7 DBUser=zabbix
8 DBPassword=111111   
9 DBSocket=/var/lib/mysql/mysql.sock

文件授权

1 [root@zabbix-server ~]# chmod -R 755 /etc/zabbix/web
2 [root@zabbix-server ~]# chown -R apache.apache /etc/zabbix/web

启动apache && zabbix

1 /etc/init.d/httpd start
2 /etc/init.d/zabbix-server start

8、登录安装

http://192.168.30.132/zabbix

输入用户名(注意大小写)和密码

登录进去后的界面如下:

服务端完装完毕。


四、agent端安装

1、环境准备

1 [root@web01 ~]# cat /etc/redhat-release 
2 CentOS release 6.7 (Final)
3 [root@web01 ~]# uname -r
4 2.6.32-573.el6.x86_645 [root@web01 ~]# uname -m
6 x86_64

2、安装zabbix的yum源,国内阿里的yum源已经提供了zabbix3.0

aliyum源配置

1 rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm

3、zabbix_agent安装配置

1 [root@web01 ~]# rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
2 [root@web01 ~]# yum install zabbix-agent -y
3 [root@web01 ~]# vim /etc/zabbix/zabbix_agentd.conf
4 Server=192.168.30.132                #用于被动模式,数据获取
5 ServerActive=192.168.30.132         #用于主动模式,数据提交
6 [root@web01 ~]# /etc/init.d/zabbix-agent start  #启动zabbix agent

备注:这里的主动模式还有被动模式的出发点是agent端,所以agent主动向server端发送数据就成为主动模式,而等待server端主动获取数据则称为被动模式。

 4、配置开机自启动

1 [root@web01 ~]# chkconfig zabbix-agent on

#详细文档参考:

https://www.cnblogs.com/clsn/p/7885990.html

原文地址:https://www.cnblogs.com/nulige/p/6082206.html