Zabbix 7.0
进行了全新升级,本文讲解如何从 6.0 版本升级至最新版本 7.2。在CentOS 8
上通过RPM
方式安装Zabbix
服务
一、环境信息
我是
CentOS 7
安装的服务端,在该机器在通过源码去安装Zabbix 7.0
版本的话,会比较费劲,因为有很多依赖包要去逐一解决,索性我们用CentOS 8
来做Zabbix-Sever
服务端,并且CentOS 8
支持RPM
方式来安装,会更加的方便。
1. 版本要求
2. 版本信息
环境 | 升级前 | 升级后 |
---|---|---|
操作系统 | CentOS 7.3 | CentOS 8.4 |
MySQL | 8.0.28 | 8.0.40 |
PHP | 7.4.30 | 8.2 |
Zabbix-Server-MySQL | 6.0.8 | 7.2.20 |
Zabbix-Web-MySQL | 6.0.8 | 7.2.20 |
具体数据库升级,请参考: 这篇文章内容有如何进行数据库升级
二、安装PHP
必须要先安装好
PHP
相关软件,后续安装Zabbix
相关软件时会依赖于PHP
包,但是系统自带默认的PHP
是7.2, 不满足要求。
1. 安装基础软件
# dnf install epel-release
# dnf install glib* gcc* libxml* libxml2* OpenIPMI*
2. 安装PHP 8.2
这个 remi
直接下载后强制安装,在线安装会一直弹依赖问题,导致安装不了。
# rpm -ivh remi-release-8.rpm --nodeps --force
# dnf module list php
# dnf module reset php -y
# dnf module install php:remi-8.2 -y
# dnf install php82-php-fpm -y
# php -v
PHP 8.2.27 (cli) (built: Dec 17 2024 11:39:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.27, Copyright (c) Zend Technologies
三、安装Zabbix 软件
1. 软件安装
# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
2. 修改配置
# 修改 Nginx 配置文件
# cat /etc/nginx/conf.d/zabbix.conf
server {
listen 8080;
server_name xxx.xxx.xxx.xxx;
......
3. 服务启动
# systemctl start zabbix-server
# systemctl start php-fpm
# systemctl start nginx
查看 Zabbix 升级成功日志
# tailf /tmp/zabbix-server.log
3322:20241219:170512.116 completed 72% of database upgrade
3322:20241219:170516.011 slow query: 3.823381 sec, "update items set lifetime='7d' where flags in (0,2,4)"
3322:20241219:170516.268 completed 73% of database upgrade
3322:20241219:170516.565 completed 74% of database upgrade
3322:20241219:170516.575 completed 75% of database upgrade
3322:20241219:170516.602 completed 76% of database upgrade
3322:20241219:170516.612 completed 77% of database upgrade
3322:20241219:170516.646 completed 78% of database upgrade
3322:20241219:170516.691 completed 79% of database upgrade
3322:20241219:170516.725 completed 80% of database upgrade
3322:20241219:170516.850 completed 81% of database upgrade
3322:20241219:170517.127 completed 82% of database upgrade
3322:20241219:170517.223 completed 83% of database upgrade
3322:20241219:170517.278 completed 84% of database upgrade
3322:20241219:170517.353 completed 85% of database upgrade
3322:20241219:170517.412 completed 86% of database upgrade
3322:20241219:170517.438 completed 87% of database upgrade
3322:20241219:170517.485 completed 88% of database upgrade
3322:20241219:170518.185 completed 89% of database upgrade
3322:20241219:170518.188 completed 90% of database upgrade
3322:20241219:170518.194 completed 91% of database upgrade
3322:20241219:170518.233 completed 92% of database upgrade
3322:20241219:170518.238 completed 93% of database upgrade
3322:20241219:170518.243 completed 94% of database upgrade
3322:20241219:170520.911 completed 95% of database upgrade
3322:20241219:170520.926 completed 96% of database upgrade
3322:20241219:170521.239 completed 97% of database upgrade
3322:20241219:170521.244 completed 98% of database upgrade
3322:20241219:170521.247 completed 99% of database upgrade
3322:20241219:170521.252 completed 100% of database upgrade
3322:20241219:170522.053 database upgrade fully completed
4. 前端配置
通过浏览器输入 IP:Port
访问前端界面进行配置。
四、处理报错
查看 服务端日志,会有一个 不能更新数据库 组件的提示。
database could be upgraded to use primary keys in history tables
1. 报错原因
Zabbix历史的数据和趋势数据的数值(浮点型)数据类型支持的精度更高,需要手动更新数据库补丁。
处理补丁的地址: https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/database/mysql/double.sql
2. 解决方式
#进入zabbix库执行命令
> ALTER TABLE trends
MODIFY value_min DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
MODIFY value_avg DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
MODIFY value_max DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;
ALTER TABLE history MODIFY value DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;
> ALTER TABLE history MODIFY value DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;
执行了上面的操作之后,依旧会报 database could be upgraded to use primary keys in history tables
,猜测可能是里面有数据导致,清空数据重新创建表则不会报这个提示了。不改也不影响使用,后续随着历史数据的自动清理就慢慢恢复正常。
处理的这个问题的 SQL
在前端文件里面有这个,路径如下:
[root@10-10-83-202 option-patches]# pwd
/usr/share/zabbix/sql-scripts/mysql/option-patches
[root@10-10-83-202 option-patches]# cat history_upgrade_prepare.sql |grep -i DOUBLE
`value` DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
Reference:
https://www.zabbix.com/cn/whats_new_7_2
https://www.zabbix.com/documentation/current/zh/manual/installation/requirements
https://www.zabbix.com/documentation/current/en/manual/appendix/install/db_primary_keyshttps://www.myfreax.com/how-to-install-php-8-2-on-centos-8/amp/