1、环境检查

cat /etc/redhat-release centos linux release 7.4.1708 uname -r getenforce systemctl status firewalld.service

2、设置解析,自建yum源(可选) /etc/hosts

#!/bin/bash #clsn #设置解析 注意:网络条件较好时,可以不用自建yum源 # echo '10.0.0.1 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com'

3、安装zabbix源 aliyun yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo  rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm

4、安装zabbix

yum install -y zabbix-server-mysql zabbix-web-mysql

5、安装mariadb或mysql数据库(仅可创建一个)

yum install -y mariadb-server systemctl start mariadb.service //启动

6、创建数据库

mysql> create database zabbix character set utf8 collate utf8_bin;

7、创建zabbix用户并授权

mysql> create user 'zabbix'@'192.168.191.%' identified by '111111'; mysql> grant all privileges on zabbix.* to 'zabbix'@'192.168.191.%' with grant option; mysql> flush privileges;

8.导入zabbix压缩包内带的create文件(注意版本号和用户名密码是否正确)

zcat /usr/share/doc/zabbix-server-mysql-3.0.28/create.sql.gz|mysql -uroot -p111111 zabbix

9、配置zabbix(/etc/zabbix/zabbix_server.conf)

DBHost=localhost //数据库地址 DBName=zabbix //数据库名称 DBUser=zbxuser //数据库登录用户 DBPassword=1111111 //数据库登录密码 DBPort=3306 //端口

10、配置时区(/etc/httpd/conf.d/zabbix.conf) 18行添加

php_value data.timezone Asia/Shanghai

11、解决中文乱码(可选)

yum -y install wqy-microhei-fonts \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

12、启动服务

systemctl start zabbix-server systemctl start httpd