一、官网查询zabbix5.0 升级7.0需要逐步升级

1 官网地址:

https://www.zabbix.com/documentation/current/en/manual/installation/upgrade

Ubuntu20.04  Zabbix5.0升级7.0历程(mariadb+Nginx+php)_Zabbix

2 查看zabbix各个版本对mariadb、Nginx、php版本的最低需求(升级前需先确认mariadb、Nginx、php版本是否满足需求,如不满足请先升级官方建议版本,升级方法后面介绍)

https://www.zabbix.com/documentation/current/en/manual/installation/requirements

二、zabbix5.0升级至5.2(注意所有更新前请确保系统时间正确)

1 Stop Zabbix processes

Stop Zabbix server to make sure that no new data is inserted into database.

# service zabbix-server stop

If upgrading Zabbix proxy, stop proxy too.

# service zabbix-proxy stop
2 Back up the existing Zabbix database

This is a very important step. Make sure that you have a backup of your database. It will help if the upgrade procedure fails (lack of disk space, power off, any unexpected problem).

3 Back up configuration files, PHP files and Zabbix binaries

Make a backup copy of Zabbix binaries, configuration files and the PHP file directory.

Configuration files:

mkdir /opt/ /etc/zabbix/nginx.confzabbix-backup/
cp /etc/zabbix/zabbix_server.conf /opt/zabbix-backup/
cp /etc/zabbix/nginx.conf /opt/zabbix-backup/

PHP files and Zabbix binaries:

cp -R /usr/share/zabbix/ /opt/zabbix-backup/
cp -R /usr/share/doc/zabbix-* /opt/zabbix-backup/
4 Update repository configuration package

To proceed with the update your current repository package has to be uninstalled.

rm -Rf /etc/apt/sources.list.d/zabbix.list

Then install the new repository configuration package.

On Debian 10 run:

wget https://repo.zabbix.com/zabbix/5.2/debian/pool/main/z/zabbix-release/zabbix-release_5.2-1+debian10_all.deb
dpkg -i zabbix-release_5.2-1+debian10_all.deb

On Debian 9 run:

# wget https://repo.zabbix.com/zabbix/5.2/debian/pool/main/z/zabbix-release/zabbix-release_5.2-1+debian9_all.deb# dpkg -i zabbix-release_5.2-1+debian9_all.deb

On Debian 8 run:

# wget https://repo.zabbix.com/zabbix/5.2/debian/pool/main/z/zabbix-release/zabbix-release_5.2-1+debian8_all.deb# dpkg -i zabbix-release_5.2-1+debian8_all.deb

On Ubuntu 20.04 run:

# wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu20.04_all.deb# dpkg -i zabbix-release_5.2-1+ubuntu20.04_all.deb

On Ubuntu 18.04 run:

# wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu18.04_all.deb# dpkg -i zabbix-release_5.2-1+ubuntu18.04_all.deb

On Ubuntu 16.04 run:

# wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu16.04_all.deb# dpkg -i zabbix-release_5.2-1+ubuntu16.04_all.deb

On Ubuntu 14.04 run:

# wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu14.04_all.deb# dpkg -i zabbix-release_5.2-1+ubuntu14.04_all.deb

Update the repository information.

# apt-get update
5 Upgrade Zabbix components

To upgrade Zabbix components you may run something like:

# apt-get install --only-upgrade zabbix-server-mysql zabbix-frontend-php zabbix-agent
6 Review component configuration parameters

See the upgrade notes for details on mandatory changes.

For new optional parameters, see the What's new section.

7 Start Zabbix processes

Start the updated Zabbix components.

service zabbix-server start
service zabbix-proxy start
8 Clear web browser cookies and cache

After the upgrade you may need to clear web browser cookies and web browser cache for the Zabbix web interface to work properly.


三、zabbix5.2 ->5.4 ->6.0 ->6.2 ->6.4 ->7.0,二步骤,只是需在第4小点更新存储库配置包, 其余操作相同

1 zabbix5.4

On Ubuntu 20.04 run:

wget https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb
2 zabbix6.0

On Ubuntu 20.04 run:

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
3 zabbix6.2

On Ubuntu 20.04 run:

wget https://repo.zabbix.com/zabbix/6.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.2-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_6.2-1+ubuntu20.04_all.deb
4 zabbix6.4

On Ubuntu 22.04 run:

wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
5 zabbix7.0

On Ubuntu 24.04, run:

wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu24.04_all.deb
dpkg -i zabbix-release_latest+ubuntu24.04_all.deb

On Ubuntu 22.04, run:

wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu22.04_all.deb
dpkg -i zabbix-release_latest+ubuntu22.04_all.deb


四、mariadb升级方法

1 、备份zabbix数据库,历史数据除外
mysqldump -uroot -pzabbix --databases zabbix \
  --ignore-table=zabbix.history \
  --ignore-table=zabbix.history_uint \
  --ignore-table=zabbix.history_str \
  --ignore-table=zabbix.history_text \
  --ignore-table=zabbix.trends \
  > zabbix_backup.sql
2、停止运行数据库
sytemctl stop mariadb
3、卸载当前版本MariaDB
remove mariadb mariadb-server
4、添加MariaDB的apt源,到官网查询相关原地址

https://mariadb.org/download/?t=repo-config&d=20.04+%22focal%22&v=10.5&r_m=aliyun

Ubuntu20.04  Zabbix5.0升级7.0历程(mariadb+Nginx+php)_ubuntu_02

Here are the commands to run to import the MariaDB repository key on your Ubuntu system:


sudo apt-get install apt-transport-https curl
sudo mkdir -p /etc/apt/keyrings
sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'

Once the key is imported, copy and paste the following into a file under /etc/apt/sources.list.d (for instance /etc/apt/sources.list.d/mariadb.sources):


# MariaDB 10.5 repository list - created 2024-07-25 04:00 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/10.5/ubuntu
URIs: https://mirrors.aliyun.com/mariadb/repo/10.5/ubuntu
Suites: focal
Components: main main/debug
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp

You can now install MariaDB 10.5 from the MariaDB repository with:


sudo apt-get update
sudo apt-get install mariadb-server
5、升级完成以后启动数据库,设置开机启动数据库
systemctl start mariadb
systemctl enable mariadb.service


五、Nginx升级方法

1、备份配置文件


cp /etc/nginx/nginx.conf /backup
2、停止nginx服务器
systemctl stop nginx.service
3、卸载旧nginx版本
apt-get --purge remove nginx
4、Nginx官网

https://nginx.org/en/download.html

Mainline version:正在开发阶段的版本,可能会有bug。

Stable version:稳定版

Legacy versions: 历史版本

本次安装1.18.0的稳定版本

5、Nginx安装

安装或升级,需要添加源才能下载 Nginx 的稳定版本,首先输入以下两条命令:

sudo wget http://nginx.org/keys/nginx_signing.key
 sudo apt-key add nginx_signing.key

在 `/etc/apt/sources.list` 文件中加入下面两行:


deb http://nginx.org/packages/ubuntu/ code nginx
deb-src http://nginx.org/packages/ubuntu/ code nginx

其中code 要根据系统来选择,20.04环境code=focal

deb http://nginx.org/packages/ubuntu/  nginx
deb-src http://nginx.org/packages/ubuntu/ code nginx

https://nginx.org/en/linux_packages.html#Ubuntu

Ubuntu20.04  Zabbix5.0升级7.0历程(mariadb+Nginx+php)_nginx_03

运行如下命令

sudo apt-get update
sudo apt-get install nginx

最后查看版本是否升级成功


root@zabbix-01:~# nginx -v
nginx version: nginx/1.24.0 (Ubuntu)


六、PHP升级方法

1、修改系统为正确时间
date -s "2024-07-24 14:43:25"
2、安装扩展及更新源
apt install -y software-properties-common
add-apt-repository ppa:ondrej/nginx-mainline(根据自己装Apache或Nginx调整)
apt update

Ubuntu20.04  Zabbix5.0升级7.0历程(mariadb+Nginx+php)_php_04

3、查看php扩展
dpkg -l | grep php | tee packages.txt
4、安装php8.3及扩展
apt-get install php8.3
apt-get install php8.3-fpm php8.3-bcmath php8.3-xml php8.3-mbstring php8.3-mysql  php8.3-ldap php8.3-opcache
apt-get isntall php8.3-json
5、注册php路径


update-alternatives --install /usr/bin/php php /usr/bin/php8.3 83
update-alternatives --config php
6、查看路径


ls -al /etc/alternatives/php-fpm.sock

Ubuntu20.04  Zabbix5.0升级7.0历程(mariadb+Nginx+php)_ubuntu_05

7、修改Nginx配置文件
vim /etc/zabbix/nginx.conf
fastcgi_pass    unix:/var/run/php/zabbix.sock;(将zabbix.sock修改为php-fpm.sock)

Ubuntu20.04  Zabbix5.0升级7.0历程(mariadb+Nginx+php)_nginx_06


8、重启Nginx


systemctl restart nginx.service

七、Zabbix小版本升级

It is possible to upgrade minor versions of 7.0.x (for example, from 7.0.1 to 7.0.3)

To upgrade Zabbix minor version please run:

sudo apt-get install --only-upgrade 'zabbix.*'

To upgrade Zabbix server minor version please run:

sudo apt-get install --only-upgrade 'zabbix-server.*'

To upgrade Zabbix agent minor version please run:

sudo apt-get install --only-upgrade 'zabbix-agent.*'

or, for Zabbix agent 2:

sudo apt-get install --only-upgrade 'zabbix-agent2.*'