---
title: "ubuntu16.04下安装部署zabbix3.0"
author: "phipray"
date: "2016-10-06T14:58:54Z"
tags: []
categories: ["行业应用"]
slug: "ubuntu16-04-zabbix3-0"
draft: false
lastmod: "2016-10-06T14:58:54Z"
id: 2328695
url: "https://phipray.iteye.com/blog/2328695"
---

一 配置zabbix软件下载源

# wget [http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release\_3.0-1+trusty\_all.deb](http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+trusty_all.deb)

# dpkg -i zabbix-release\_3.0-1+trusty\_all.deb

# apt-get update

 

二 安装Server端

需要安装如下组件：

apache2

php5

php5-gd

libapache2-mod-php5

zabbix-server-mysql 

php5-mysql 

zabbix-frontend-php 

在ubuntu16.04中的apt-get源不能正常下载安装 zabbix-server-mysql和php5等等，所以要更换源问的内容。

 

1 首先到/etc/apt/目录对原来的source.list进行备份

#cp source.list source.list\_16.04

 

2 然后把15.10的source.list的内容

 

```
deb http://us.archive.ubuntu.com/ubuntu/ wily main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ wily main restricted
deb http://us.archive.ubuntu.com/ubuntu/ wily-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ wily-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ wily universe
deb-src http://us.archive.ubuntu.com/ubuntu/ wily universe
deb http://us.archive.ubuntu.com/ubuntu/ wily-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ wily-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ wily multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ wily multiverse
deb http://us.archive.ubuntu.com/ubuntu/ wily-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ wily-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ wily-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ wily-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu wily-security main restricted
deb-src http://security.ubuntu.com/ubuntu wily-security main restricted
deb http://security.ubuntu.com/ubuntu wily-security universe
deb-src http://security.ubuntu.com/ubuntu wily-security universe
deb http://security.ubuntu.com/ubuntu wily-security multiverse
deb-src http://security.ubuntu.com/ubuntu wily-security multiverse
```

 

 

覆盖原来的source.list的内容

 

3 清理一下apt缓存信息

#apt-get clean

#apt-get upgrade

 

#apt-get update

 

4 如果zabbix-frontend-php无法下载的话可以切换回16.04的source.list进行下载安装

 

 

三 配置Server

 

# vi /etc/zabbix/zabbix\_server.conf

 

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

StartTrappers=200

 

CacheSize=512M

 

四 设置Mysql

#mysql -u root -p

(安装mysql时我把root账号的密码设置为zabbix)

Enter passworld:zabbix

mysql&gt;create database zabbix character set utf8 collate utf8\_bin;

mysql&gt;grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

mysql&gt;flush privileges;

mysql&gt;set GLOBAL max\_connections=1000;

mysql&gt;show variables like '%max\_connections%';

mysql&gt; quit;

#cd /usr/share/doc/zabbix-server-mysql

#zcat create.sql.gz | mysql -u root -p zabbix

#cp -r /usr/share/zabbix /var/www/html/zabbix

 

#service zabbix-server restart

 

五 服务器容器配置

1 php

#vim /etc/php5/apache2/php.ini修改项：

post\_max\_size = 16M

max\_execution\_time = 300

max\_input\_time = 300

date.timezone = "Asia/Shanghai"

extension\_dir = "/usr/lib/php5/20131226/"(gd.so被apt在到/usr/lib/php5/20131226下)

extension=gd.so

修改完成后重启apache2

 

#service apache2 star

 

2 按照网页指引配置

用浏览器打开http://10.92.21.160/zabbix，通过网站方式对zabbixserver进行配置初始化检查

![](http://dl2.iteye.com/upload/attachment/0120/4266/dc0d705f-c865-350e-ad21-60ca6aded05a.jpg)  
 直接按照网页端配置执行。

 

 用户名密码:Admin/zabbix

 

六 安装客户端

 

#apt-get install zabbix-agent

安装客户端后，若不是服务器本机，修改zabbix配置文件/etc/zabbix/zabbix\_agentd.conf的数据

#vi /etc/zabbix/zabbix\_agentd.conf

修改ServerAcive的IP，地址为服务端地址

ServerActive=10.92.21.160

 设置为0 仅为主动模式,如果需要发送数据等 可以不修改此项

 StartAgents=0

Hostname修改为网页里面添加的Hostname，需要保持一致。

 

Hostname=Zabbix server

 

七 添加host进行监控

Configuration--&gt;Hosts--&gt;选择默认的Zabbix server，进入详细页面然后full clone，调整一下配置信息

![](http://dl2.iteye.com/upload/attachment/0120/4268/45e2e0ed-719c-3b7b-ae08-652fc712ef00.jpg)  
 

如果出现时间不对应的情况下需要设置下服务器的时区

#dpkg-reconfigure tzdata

  选择Asia -&gt; 再选择Shanghai -&gt; OK

 

#date -s "02 OCT 2016 17:07:00"