CentOS release 6.8 (Final) 安装 Zabbix 3.2.6


[root@localhost ~]# yum remove -y mysql* httpd* php* nginx* zabbix*

2、安装 yum 扩展源

[root@localhost ~]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm

3、安装 php 所需包

[root@localhost ~]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap wget ntpdate net-snmp*
[root@localhost ~]# yum install -y gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel

4、mysql 安装及账号创建

[root@localhost ~]# yum -y install mysql-server mysql mysql-devel
[root@localhost ~]# /etc/init.d/mysqld start

5、创建 zabbix 数据库

[root@localhost ~]# mysql -u root
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
mysql> quit

6、创建 zabbix 组与用户

[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd -g zabbix zabbix

7、下载 zabbix3.2.x 安装包
下载页面 https://www.zabbix.com/download

[root@localhost ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.6/zabbix-3.2.6.tar.gz

8、导入 zabbix 数据到数据库中

[root@localhost ~]# tar zxvf zabbix-3.2.6.tar.gz
[root@localhost ~]# cd zabbix-3.2.6/database/mysql/
[root@localhost mysql]# mysql -u zabbix -p zabbix < schema.sql
Enter password: (zabbix)
[root@localhost mysql]# mysql -u zabbix -p zabbix < images.sql
Enter password: (zabbix)
[root@localhost mysql]# mysql -u zabbix -p zabbix < data.sql
Enter password: (zabbix)

9、编译安装 zabbix

[root@localhost ~]# cd /root/zabbix-3.2.6/
[root@localhost zabbix-3.2.6]# ./configure --enable-server  --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl
[root@localhost zabbix-3.2.6]# make install

9.1 如果提示 “WARNING: ‘automake-1.14’ is missing on your system.”
说明 antomake 没有对应版本或没有这个软件,执行以下内容

[root@localhost ~]# wget http://ftp.gnu.org/gnu/automake/automake-1.14.1.tar.gz
[root@localhost ~]# tar -xvf automake-1.14.1.tar.gz
[root@localhost ~]# cd automake-1.14.1
[root@localhost automake-1.14.1]# ./configure
[root@localhost automake-1.14.1]# make
[root@localhost automake-1.14.1]# make install


[root@localhost ~]# vim /usr/local/etc/zabbix_server.conf

11、创建 zabbix web 页面目录

[root@localhost ~]# mkdir /var/www/html/zabbix
[root@localhost ~]# cd /root/zabbix-3.2.6/frontends/php/
[root@localhost ~]# cp -a . /var/www/html/zabbix/


12.1 创建一个规则允许 web 服务器访问前端文件

[root@localhost ~]# chcon -Rv --type=httpd_sys_content_t /var/www/html

12.2 运行 apache 和 zabbix 访问外网

[root@localhost ~]# setsebool -P httpd_can_network_connect=1
[root@localhost ~]# setsebool -P zabbix_can_network=1

12.3 设置 apache 用户 web 接口文件的所有者

[root@localhost ~]# chown -R apache:apache /var/www/html/zabbix

12.4 为 zabbix web 界面添加权限

[root@localhost ~]# chmod +x /var/www/html/zabbix/conf/
[root@localhost ~]# cp /root/zabbix-3.2.6/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[root@localhost ~]# chkconfig --add /etc/init.d/zabbix_server

12.5 启用 zabbix 服务器 apache 和 mysql 服务启动

[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig zabbix_server on

13、启动 httpd 和 zabbix_server

[root@localhost ~]# /etc/init.d/httpd start
[root@localhost ~]# service zabbix_server start

14、优化 php

[root@localhost ~]# vim /etc/php.ini

14.1 修改完成后重启 httpd

[root@localhost ~]# /etc/init.d/httpd restart


[root@localhost ~]# vim /etc/sysconfig/iptables
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT

16、访问 zabbix web 管理页面

17、配置 zabbix

17.1 检查参数
进入在 zaibbix web 管理界面后将进行以下配置

Check of pre-requisites
Current value	Required	
PHP version	5.6.40	5.4.0	OK
PHP option "memory_limit"	128M	128M	OK
PHP option "post_max_size"	16M	16M	OK
PHP option "upload_max_filesize"	2M	2M	OK
PHP option "max_execution_time"	300	300	OK
PHP option "max_input_time"	300	300	OK
PHP option "date.timezone"	Asia/Shanghai		OK
PHP databases support	MySQL OK
PHP bcmath	on		OK
PHP mbstring	on		OK
PHP option "mbstring.func_overload"	off	off	OK
PHP option "always_populate_raw_post_data"	off	off	OK
PHP sockets	on		OK
PHP gd	2.1.0	2.0	OK
PHP gd PNG support	on		OK
PHP gd JPEG support	on		OK
PHP gd FreeType support	on		OK
PHP libxml	2.7.6	2.6.15	OK
PHP xmlwriter	on		OK
PHP xmlreader	on		OK
PHP ctype	on		OK
PHP session	on		OK
PHP option "session.auto_start"	off	off	OK
PHP gettext	on		OK
PHP option "arg_separator.output"	&	&	OK

17.2 数据库链接

Configure DB connection
Please create database manually, and set the configuration parameters for connection to this database. Press "Next step" button when done.

Database type MySQL

Database host localhost
Database port 0 (0 - use default port)
Database name zabbix
User zabbix
Password ••••••

17.3 服务器配置

Zabbix server details
Please enter the host name or host IP address and port number of the Zabbix server, as well as the name of the installation (optional).

Host localhost
Port 10051
Name Zabbix3.2

17.4 配置确认清单

Pre-installation summary
Please check configuration parameters. If all is correct, press "Next step" button, or "Back" button to change configuration parameters.

Database type	MySQL
Database server	localhost
Database port	default
Database name	zabbix
Database user	zabbix
Database password	******
Zabbix server	localhost
Zabbix server port	10051
Zabbix server name	zabbix3.2

17.5 完成

Congratulations! You have successfully installed Zabbix frontend.
Configuration file "/var/www/html/zabbix/conf/zabbix.conf.php" created.

18、登录 zabbix web


18.1 如果忘记密码,使用以下方式可以重置
18.1.1 查询 zabbix 数据库用户记录

[root@localhost ~]# mysql -uroot -p -e "select * from zabbix.users\G"
Enter password: 
*************************** 1. row ***************************
        userid: 1
         alias: Admin
          name: Zabbix
       surname: Administrator
        passwd: 5fce1b3e34b520afeffb37ce08c7cd66
     autologin: 1
    autologout: 0
          lang: en_GB
       refresh: 30
          type: 3
         theme: default
attempt_failed: 0
 attempt_clock: 1553099872
 rows_per_page: 50

18.1.2 修改 zabbix 数据库用户信息

[root@localhost ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 82
Server version: 5.6.43 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update users set passwd='5fce1b3e34b520afeffb37ce08c7cd66' where userid='1';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> quit

完成,可使用 用户名:Admin 密码:zabbix 登录 zabbix web。

18.2 登录后务必立即修改默认密码,右上角 —— 用户头像 —— 用户 —— 密码 —— 修改密码。

建议将 /var/www/html/zabbix 目录下的 setup.php 文件重命名备用,否则任意人员都可任意时间访问这个文件来配置 Zabbix。

20、安装客户端 zabbix_agent

[root@localhost ~]# yum -y install http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
[root@localhost ~]# yum install zabbix-agent -y

21、配置客户端 zabbix_agent

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
Server= (服务端 IP)
Server= (服务端 IP)
ServerActive= (服务端 IP)
Hostname=Zabbix server

当前所安装 zabbix 的主机已经默认被添加监测,从 zabbix – 配置 – 主机 – 即可找到 “Zabbix server”,默认状态为 “已停用,需要手动开启”。

1 条评论

  1. Yogurt

    cool guys