Zabbix6.2.3安装部署

该文档仅用于指导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秒。
依赖关系解决。
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

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

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

# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix


配置数据库

    为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

版本查看

# zabbix_server -V
zabbix_server (Zabbix) 6.2.3
Revision 98ee88fc19d 21 September 2022, compilation time: Sep 21 2022 10:26:52

Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.1.1k  FIPS 25 Mar 2021
Running with OpenSSL 1.1.1c FIPS  28 May 2019
# php-fpm -v

PHP 7.4.19 (fpm-fcgi) (built: May  4 2021 11:06:37)
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 45

Server version: 8.0.26 Source distribution

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> exit
Bye

 

错误处理

问题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.

# 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秒。
依赖关系解决。
…………………………………………

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值