该文档仅用于Zabbix6的环境准备和测试学习,在安装过程如有问题请参考官方手册。下载Zabbix
环境准备
Red Hat Enterprise Linux 8.2、Mysql8、Zabbix6.2、php-fpm-7.4
操作系统
# hostnamectl status
Static hostname: zbserver
Icon name: computer-vm
Chassis: vm
Machine ID: 85d7d85a9ae6470392b4c5fb5ba4b489
Boot ID: 927ee4f64e554b629c23b780d9ce612a
Virtualization: vmware
Operating System: Red Hat Enterprise Linux 8.2 (Ootpa)
CPE OS Name: cpe:/o:redhat:enterprise_linux:8.2:GA
Kernel: Linux 4.18.0-193.el8.x86_64
Architecture: x86-64
关闭防火墙及SELINUX
# systemctl stop firewalld.service
# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
# cat /etc/selinux/config #修改该文件,SELINUX=disabled ,永久关闭SELINUX
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
注意:修改后需重启后生效,临时关闭SELINUX命令为:setenforce 0
配置yum源
# wget -O /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-8.repo
--2022-10-15 09:51:48-- http://mirrors.aliyun.com/repo/Centos-8.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 240e:95c:2002:6:3::3fd, 240e:95c:2002:6:3::3fe, 121.14.152.236, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|240e:95c:2002:6:3::3fd|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2590 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/redhat.repo”
/etc/yum.repos.d/redhat.repo 100%[===========================================================>] 2.53K --.-KB/s 用时 0.001s
2022-10-15 09:51:48 (2.27 MB/s) - 已保存 “/etc/yum.repos.d/redhat.repo” [2590/2590]
# rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/8/x86_64/zabbix-release-6.2-3.el8.noarch.rpm
获取https://repo.zabbix.com/zabbix/6.2/rhel/8/x86_64/zabbix-release-6.2-3.el8.noarch.rpm
警告:/var/tmp/rpm-tmp.nIiNko: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-6.2-3.el8 ################################# [100%]
更新yum源
# dnf clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
0 文件已删除
# yum makecache
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
CentOS-8 - Base - mirrors.aliyun.com 1.3 MB/s | 4.6 MB 00:03
CentOS-8 - Extras - mirrors.aliyun.c 39 kB/s | 10 kB 00:00
CentOS-8 - AppStream - mirrors.aliyu 2.7 MB/s | 8.4 MB 00:03
Zabbix Official Repository (Agent2 P 803 B/s | 1.3 kB 00:01
Zabbix Official Repository - x86_64 27 kB/s | 58 kB 00:02
Zabbix Official Repository (non-supported) - x86_64 758 B/s | 1.2 kB 00:01
元数据缓存已建立。
应用及数据库安装
安装yum-utils包
# yum install yum-utils
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:00:59 前,执行于 2022年10月15日 星期六 10时00分55秒。
依赖关系解决。
………………………………
Zabbix应用安装
# dnf module switch-to php:7.4
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:07:16 前,执行于 2022年10月15日 星期六 10时00分55秒。
依赖关系解决。
Mysql数据库安装
# yum -y install mysql-server
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:03:35 前,执行于 2022年10月15日 星期六 10时00分55秒。
依赖关系解决。
………………………………
# mysqld --initialize –console #初始化数据库
# chown -R mysql:mysql /var/lib/mysql #授权
# systemctl start mysqld #启动数据库
# cat /var/log/mysql/mysqld.log | grep localhost #查看数据库初始化密钥
2022-10-15T14:45:19.126155Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: SibBrDvq1D&a
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user 'root'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.01 sec)
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)
mysql> create user zabbix@localhost identified by 'password';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
配置数据库
为Zabbix server配置数据库,编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password
服务启动
启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fp
访问web前端
连接到新安装的Zabbix前端: http://IP/zabbix。根据个人习惯选择语言,我这里选择中文,点击下一步。
确保下图值都是“OK”
输入数据库配置密码,其他保持默认即可,该测试环境仅一台系统。
zabbix的名称输入系统主机名即可。
至此安装完成,下图登录验证即可。默认用户名及密码:user:Admin ps: zabbix
错误处理
问题1zabbix-server启动报错
# systemctl start zabbix-server
Job for zabbix-server.service failed because the control process exited with error code.
See "systemctl status zabbix-server.service" and "journalctl -xe" for details.
[root@zbserver zabbix]# journalctl -xe
-- Support: https://access.redhat.com/support
--
-- zabbix-server.service 单元已失败。
--
-- 结果为“failed”。
解决:升级net-snmp到高版本
# yum localinstall -y net-snmp-5.8-22.el8.x86_64.rpm
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:02:18 前,执行于 2022年10月15日 星期六 10时59分11秒。
依赖关系解决。
…………………………………………