一、环境配置
- 安装 mysql 数据库
- 关闭 防火墙
firewall-cmd --state // 查看防火墙状态
systemctl stop firewalld.service // 临时关闭防火墙
systemctl disable firewalld.service // 开机禁止启动防火墙
- 关闭 SELINUX
setenforce 0 // 临时关闭selinux
vim /etc/sysconfig/selinux
SELINUXTYPE=disabled // 永久关闭selinux
二、安装 Zabbix4.2
- 添加 zabbix 软件仓库
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm
- 更换 zabbix 源
vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.2/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.2/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
- 安装 zabbix server 、agent
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
- 创建数据库
mysql -u root -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> flush privileges;
- 导入初始数据
rpm -ql zabbix-server-mysql
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
- zabbix server 配置数据库
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
- httpd 配置时区
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
- 启动 zabbix serve 、agent 和 httpd 进程
systemctl start zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
- 检查服务状态
netstat -ntpl
systemctl status zabbix-server zabbix-agent httpd