Zabbix监控工具

Contents
  1. 基本环境
    1. zabbix简介
    2. DEB源的配置
    3. 安装zabbix-server
    4. 安装zabbix-agent

基本环境

操作系统:

  • PM:centos 7
  • VM:ubuntu 12.04

共9台物理机,131台虚拟机,启动vm基于openstack

zabbix监控工具的部署

=============

zabbix简介

Zabbix是一种网络监视、管理系统。基于Server-Client架构,可用于监视各种网络服务、服务器和网络机器等状态。

Server端基于C语言,Web管理端frontend则是基于PHP制作的。在Client端如 UNIX, Windows 中安装 Zabbix Agent 之后,可监视 CPU Load、网络使用状况、硬盘容量等各种状态。

DEB源的配置

参考文档:https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages

各版本配置信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Zabbix 2.2 for Ubuntu 12.04 LTS:
# wget http://repo.zabbix.com/zabbix/2.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.2-1+precise_all.deb
# dpkg -i zabbix-release_2.2-1+precise_all.deb
# apt-get update
Zabbix 2.2 for Ubuntu 14.04 LTS:
# wget http://repo.zabbix.com/zabbix/2.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.2-1+trusty_all.deb
# dpkg -i zabbix-release_2.2-1+trusty_all.deb
# apt-get update
Zabbix 2.2 for Centos 7 LTS:
yum -y install zabbix22-server-mysql zabbix22-web-mysql
# cat /etc/apt/sources.list.d/zabbix.list #源里面的记录如下
deb http://repo.zabbix.com/zabbix/2.2/ubuntu trusty main
deb-src http://repo.zabbix.com/zabbix/2.2/ubuntu trusty main

安装zabbix-server

ssh到zabbix server主机,并进行如下操作:

1、安装zabbix-server

1
# sudo apt-get install zabbix-server-mysql php5-mysql zabbix-frontend-php

2、配置zabbix_server.conf

1
2
3
4
5
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

3、设置开机启动项

1
2
# vi /etc/default/zabbix-server
START=yes

4、启动zabbix-server服务

1
# sudo service zabbix-server start

5、启动MySQL服务

1
# sudo service mysql start

6、创建Zabbix数据库

1
2
3
4
# mysql -uroot
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to [email protected] identified by 'zabbix';
mysql> flush privileges;

7、导入Zabbix数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# cd /usr/share/zabbix-server-mysql/
# sudo gunzip *.gz
# mysql -u zabbix -p zabbix < schema.sql
# mysql -u zabbix -p zabbix < images.sql
# mysql -u zabbix -p zabbix < data.sql
# sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
# sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/sites-enabled/apache.conf
# cat /etc/apache2/sites-enabled/apache.conf
# Define /zabbix alias, this is the default
<IfModule mod_alias.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value date.timezone Europe/Riga
Alias /zabbix /usr/share/zabbix
</IfModule>

启动apache

1
# sudo service apache2 restart

安装zabbix-agent

ssh到任意一台zabbix agent主机,并进行如下操作:

1
2
3
4
5
6
# sudo apt-get update
# sudo apt-get install zabbix-agent
# sudo vim /etc/zabbix/zabbix_agentd.conf
Server="your_server_ip_addr"
Hostname="your_client_hostname"
# sudo service zabbix-agent restart