CentOS 8安装部署Zabbix 6.4【超级详细】

部署环境及版本说明

操作系统:CentOS Linux release 8.5.2111
Zabbix:Zabbix 6.4 for CentOS 8 (组件包含:Server,Frontend,Agent)数据库(Mysql)WEB SERVER(Apache)
链接: Zabbix官网
Mysql数据库:mysql Ver 8.0.30以上
PHP:PHP 7.4
Httpd:Apache/2.4.37 (centos)

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

配置YUM源

备份YUM源文件

cd /etc/yum.repos.d/
mkdir bak
mv C* ./bak/
wget -O /etc/yum.repos.d/CentOS-Linux-BaseOS.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all
yum makecache

安装Mysql数据库

下载Mysql数据安装包,这里下载的是8.0.32

wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.32-1.el8.x86_64.rpm-bundle.tar

解压安装包

tar -xf mysql-8.0.32-1.el8.x86_64.rpm-bundle.tar

[root@Zabbix src]# ls
mysql-8.0.32-1.el8.x86_64.rpm-bundle.tar
mysql-community-client-8.0.32-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.32-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.32-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.32-1.el8.x86_64.rpm
mysql-community-common-8.0.32-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.32-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.32-1.el8.x86_64.rpm
mysql-community-devel-8.0.32-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm
mysql-community-libs-8.0.32-1.el8.x86_64.rpm
mysql-community-libs-debuginfo-8.0.32-1.el8.x86_64.rpm
mysql-community-server-8.0.32-1.el8.x86_64.rpm
mysql-community-server-debug-8.0.32-1.el8.x86_64.rpm
mysql-community-server-debug-debuginfo-8.0.32-1.el8.x86_64.rpm
mysql-community-server-debuginfo-8.0.32-1.el8.x86_64.rpm
mysql-community-test-8.0.32-1.el8.x86_64.rpm
mysql-community-test-debuginfo-8.0.32-1.el8.x86_64.rpm

查看mariadb并删除包,无则不返回

rpm -qa|grep mariadb

删除mariadb-connector-c-config-3.1.11-2.el8_3.noarch

rpm -e --nodeps mariadb-connector-c-config-3.1.11-2.el8_3.noarch

安装Mysql相关程序

rpm -ivh mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm mysql-community-libs-8.0.32-1.el8.x86_64.rpm mysql-community-common-8.0.32-1.el8.x86_64.rpm mysql-community-client-plugins-8.0.32-1.el8.x86_64.rpm mysql-community-client-8.0.32-1.el8.x86_64.rpm mysql-community-server-8.0.32-1.el8.x86_64.rpm

[root@Zabbix src]# rpm -ivh mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm mysql-community-libs-8.0.32-1.el8.x86_64.rpm mysql-community-common-8.0.32-1.el8.x86_64.rpm mysql-community-client-plugins-8.0.32-1.el8.x86_64.rpm mysql-community-client-8.0.32-1.el8.x86_64.rpm mysql-community-server-8.0.32-1.el8.x86_64.rpm
警告:mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying… ################################# [100%]
准备中… ################################# [100%]
正在升级/安装…
1:mysql-community-client-plugins-8.################################# [ 17%]
2:mysql-community-common-8.0.32-1.e################################# [ 33%]
3:mysql-community-libs-8.0.32-1.el8################################# [ 50%]
4:mysql-community-client-8.0.32-1.e################################# [ 67%]
5:mysql-community-icu-data-files-8.################################# [ 83%]
6:mysql-community-server-8.0.32-1.e################################# [100%]
[/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.

安装报错了,需要去修改一个配置文件

vim /usr/lib/tmpfiles.d/pesign.conf

将/var/run/pesign 改为/run/pesign

再次安装

rpm -ivh mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm mysql-community-libs-8.0.32-1.el8.x86_64.rpm mysql-community-common-8.0.32-1.el8.x86_64.rpm mysql-community-client-plugins-8.0.32-1.el8.x86_64.rpm mysql-community-client-8.0.32-1.el8.x86_64.rpm mysql-community-server-8.0.32-1.el8.x86_64.rpm

[root@Zabbix src]# rpm -ivh mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm mysql-community-libs-8.0.32-1.el8.x86_64.rpm mysql-community-common-8.0.32-1.el8.x86_64.rpm mysql-community-client-plugins-8.0.32-1.el8.x86_64.rpm mysql-community-client-8.0.32-1.el8.x86_64.rpm mysql-community-server-8.0.32-1.el8.x86_64.rpm
警告:mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying… ################################# [100%]
准备中… ################################# [100%]
软件包 mysql-community-client-plugins-8.0.32-1.el8.x86_64 已经安装
软件包 mysql-community-common-8.0.32-1.el8.x86_64 已经安装
软件包 mysql-community-libs-8.0.32-1.el8.x86_64 已经安装
软件包 mysql-community-client-8.0.32-1.el8.x86_64 已经安装
软件包 mysql-community-icu-data-files-8.0.32-1.el8.x86_64 已经安装
软件包 mysql-community-server-8.0.32-1.el8.x86_64 已经安装

安装成功,启动Mysql数据并检查运行状态

systemctl start mysqld
systemctl status mysqld
netstat  -nlpt | grep mysqld
systemctl enable mysqld

查看mysql初始化密码

cat /var/log/mysqld.log  | grep password

2024-02-04T11:17:16.150618Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: HrHXL90:KcKp

登录数据库并修改初始化密码

mysql -uroot -pHrHXL90:KcKp
mysql> alter user 'root'@'localhost'  identified by 'Root123..';
mysql> flush privileges; 
mysql> select user,host from mysql.user;
mysql> quit;

安装Httpd服务

yum install httpd -y
systemctl start httpd
systemctl status httpd
systemctl enable httpd

安装PHP服务并将版本升级成7.4

yum install php -y
dnf module switch-to php:7.4

检查PHP版本

php -v
PHP 7.4.19 (cli) (built: May 4 2021 11:06:37) ( NTS )
Copyright © The PHP Group
Zend Engine v3.4.0, Copyright © Zend Technologies
with Zend OPcache v7.4.19, Copyright ©, by Zend Technologies

安装 Zabbix

rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm
dnf clean all
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

创建初始数据库

mysql -uroot -p
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;

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

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

Disable log_bin_trust_function_creators option after importing database schema.

# mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;

为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf

vim  /etc/zabbix/zabbix_server.conf

DBPassword=password

启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:

systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值