CentOS 8.1安装Zabbix 5.0或5.4

最后更新于:2023-04-14 11:15:52

【一】CentOS最小安装环境如图

【二】安装前配置

//关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

//关闭selinux

setenforce 0
sed -i "/^SELINUX/s/enforcing/disabled/" /etc/selinux/config

//安装 epel

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

//mysql 安装

CentOS 8

dnf -y install wget
yum -y install https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
yum install mysql-server -y
systemctl start mysqld && systemctl status mysqld
systemctl enable mysqld
mysql -uroot -p

CentOS 7

yum -y install wget
wget http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
sudo yum install mysql-server --nogpgcheck
systemctl start mysqld && systemctl status mysqld
systemctl enable mysqld
mysql -uroot -p

空密码,直接回车
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
quiit

【三】Zabbix 安装

//安装 Zabbix 仓库

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
dnf clean all

//安装Zabbix server,Web前端,agent

dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-agent
如有需要
按y继续

//创建初始数据库

mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;

//导入初始架构和数据,系统将提示您输入新创建的密码

Zabbix 5.0版本
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
password
Zabbix 5.4版本
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p zabbix
password

//配置 zabbix_server.conf

vim /etc/zabbix/zabbix_server.conf

DBPassword=password

//为Zabbix前端配置PHP

vim /etc/nginx/conf.d/zabbix.conf              //取消这两行注释
        listen          80;
        server_name     域名或者IP地址;

vim /etc/php-fpm.d/zabbix.conf        //取消注释,并修改时区

php_value[date.timezone] = Asia/Shanghai

//启动服务

systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm

【四】Zabbix 配置

访问地址:http://域名或者IP地址

//确保所有的要求都 ok

//配置数据库

//配置当前 Zabbix Server 的信息

//登录

默认用户名密码:Admin/zabbix

//修改为中文语言

【生产服务器网络设置】

vim /etc/sysconfig/network-scripts/ifcfg-ens32

注:
网关设置10.4.0.11  检测分行