操作系统:CentOS 7.2 Zabbix版本:2.4.7


#安装 EPEL 源:

1
yum install epel-release

#添加 Zabbix 仓库: 官方源实在是太慢了,于是用阿里云的镜像

1
2
rpm --import http://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX
rpm -Uv  http://mirrors.aliyun.com/zabbix/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm

#安装 Zabbix

1
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

#安装 MariaDB

1
2
3
4
yum install mariadb-server mariadb
systemctl enable mariadb.service
systemctl start mariadb.service
mysql_secure_installation

#配置数据库 创建一个名为zabbix的数据库,用户名为zabbixuser

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
mysql -uroot -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 45897
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>create database zabbix character set utf8;
Query OK, 1 row affected (0.05 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbixuser'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.21 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

#初始化 Zabbix 数据库

1
2
3
4
cd /usr/share/doc/zabbix-server-mysql-2.4.7/create
mysql -u zabbixuser -p zabbix < schema.sql
mysql -u zabbixuser -p zabbix < images.sql
mysql -u zabbixuser -p zabbix < data.sql

#修改 Apache

1
2
vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
1
2
3
4
5
6
7
vi /etc/php.ini
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Shanghai
1
2
systemctl enable httpd.service
systemctl start httpd.service

#修改 Zabbix 配置

1
2
3
4
5
6
7
8
vi /etc/zabbix/zabbix_server.conf
[...]
DBName=zabbix
[...]
DBUser=zabbixuser
[...]
DBPassword=password
[...]

#配置防火墙 最小化安装默认是没有防火墙的

1
2
3
4
5
firewall-cmd --permanent --zone=public --add-service=mysql
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload

#允许 Apache 和 Zabbix 通信 SELinux 会导致 Zabbix 为服务器未运行状态

1
setsebool -P httpd_can_connect_zabbix=1

#启动与开机自动运行

1
2
3
4
5
6
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl restart httpd
systemctl restart mariadb
systemctl enable zabbix-server
systemctl enable zabbix-agent

#图形化配置 以上操作都配置完成后,访问 http://ip-address/zabbix,完成最终的图形化配置,会检查配置情况,及再输入数据库信息来完成数据库配置。

参考: CentOS 7上使用yum安装zabbix 2.4 How To Install Zabbix Server On CentOS 7