Upgrade Zabbix (5.0, 5.2, 5.4) to 6.0 like a Pro [+6.0 to 6.4 guide]

In this tutorial I will show you how to upgrade almost any Zabbix version (3.0, 3.2, 3.4, 4.0, 4.2, 4.4, 5.0, 5.2, 5.4) to 6.0 LTS or 6.4 Standard version using official packages from repo.zabbix.com. This is all-in-one Zabbix upgrade guide for Ubuntu, CentOS, RHEL, Oracle/Rocky/Alma Linux, Debian, and Rasbian (Raspberry Pi) that takes into consideration any webserver (Apache or NGINX) and database (MySQL, MariaDB, or PostgreSQL).

Already on Zabbix 6.0 or 6.2? Jump to Step 10: How to upgrade Zabbix to 6.4?

Zabbix 6.0 Dashboard
Zabbix 6.0 Dashboard

Zabbix 6 brings a lot of new features, you can read about them on the official site so I won’t write about it. However, I have to mention the new changes in PHP and database requirements that should be taken into account.

Zabbix 6.0 will no longer support PHP versions older than 7.2.5. Newer operating systems support PHP 7.2.5 so you can upgrade to 6.0 without any difficulties on these Linux distributions:

  • Ubuntu 22.04 LTS (Jammy Jellyfish) / Ubuntu 20.04 (Focal)
  • CentOS 8 or 9 / RHEL 8 or 9 / Oracle Linux 8 or 9 / Alma Linux 8 or 9 / Rocky Linux 8 or 9
  • Debian 11 (Bullseye) / Debian 10 (Buster)
  • Rasberry Pi OS (Debian 11 / 10)

In addition to dropping support for older PHP versions, Zabbix 6.0 has tightened requirements for the database. Here are the minimum database versions that new Zabbix supports:

  • MySQL/Percona 8.0+
  • MariaDB 10.5+
  • PostgreSQL 13+
  • Oracle 19c+
  • TimescaleDB 2.0.1+
  • SQLite 3.3.5+

Check your database version and if it does not meet the requirements, you will first need to upgrade it before continuing with this guide or use override by setting AllowUnsupportedDBVersions=1 in Zabbix server configuration file at your own risk.

Note, this guide is for upgrading Zabbix while guides for installing Zabbix 6.0 or 6.4 from scratch on various Linux distribution can be found on these links: CentOS, RHEL, Oracle/Alma/Rocky LinuxUbuntuDebianRasbian (Raspberry Pi).

Note: You need to log in as a root user on your Linux server with “su -” or use “sudo” to successfully execute commands used in this tutorial.

Table of Contents

Step 1: Stop Zabbix Server

We must first stop the Zabbix server so that the database does not receive any data as we perform the upgrade:

systemctl stop zabbix-server

Step 2: Backup Zabbix components

Zabbix upgrade should go smoothly with no problems but there is that famous saying “better safe than sorry” or how I like to put it “better backup than spend all day in a linux terminal”.

Therefore, back up your data and copy all relevant Zabbix files to your backup directory! This will give you the option to restore the old version of Zabbix if something goes wrong with the upgrade. The procedure for restoration is described in Step 9: Restore procedure (if Zabbix upgrade fails).

a) Create directories for backup files

Create backup directories for binary, configuration, doc, web and database files.

mkdir -p /opt/zabbix_backup/bin_files /opt/zabbix_backup/conf_files /opt/zabbix_backup/doc_files
mkdir -p /opt/zabbix_backup/web_files /opt/zabbix_backup/db_files

b) Backup Zabbix binary, doc and conf files

Next, copy Zabbix binary, doc and configuration files. Some files will not exits, depending on what webserver you are using (Apache or NGINX), so I will use “2>/dev/null” to ignore copy errors.

cp -rp /etc/zabbix/zabbix_server.conf /opt/zabbix_backup/conf_files
cp -rp /usr/sbin/zabbix_server /opt/zabbix_backup/bin_files
cp -rp /usr/share/doc/zabbix-* /opt/zabbix_backup/doc_files
cp -rp /etc/httpd/conf.d/zabbix.conf /opt/zabbix_backup/conf_files 2>/dev/null
cp -rp /etc/apache2/conf-enabled/zabbix.conf /opt/zabbix_backup/conf_files 2>/dev/null
cp -rp /etc/zabbix/php-fpm.conf /opt/zabbix_backup/conf_files 2>/dev/null

c) Backup Zabbix web files (frontend)

Backup Zabbix frontend files.

cp -rp /usr/share/zabbix/ /opt/zabbix_backup/web_files

d) Backup Zabbix database

Note: This guide is tailored for Zabbix installation in combination with MySQL / MariaDB, and if you are using PostgreSQL, please google how to backup PostgreSQL!

Make sure you have enough free disk space on “/opt” or use another dictionary path for database backup.

This command will make a full backup of the Zabbix database on MySQL/MariaDB instance (change hostname, user, password and db name to match your environment):

mysqldump -h localhost -u'root' -p'rootDBpass' --single-transaction 'zabbix' | gzip > /opt/zabbix_backup/db_files/zabbix_backup.sql.gz

Note that this backup process can take anywhere from few minutes to hours, depending on the database size.

Step 3: Upgrade Zabbix Server and Frontend

Select the appropriate OS repository and upgrade the Zabbix server and frontend using the provided instructions.

Note: If using PostgreSQL, replace “mysql” with “pgsql” in the upgrade command.

a) Ubuntu 22.04 & Ubuntu 20.04

Please delete old Zabbix repository so that we can install the new one:

dpkg --purge zabbix-release

Upgrade Zabbix and when prompted what to do with Zabbix configuration file, just press enter to keep the current version of “zabbix_server.conf“:

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu$(lsb_release -rs)_all.deb
sudo dpkg -i zabbix-release_6.0-4+ubuntu$(lsb_release -rs)_all.deb
apt update
apt install -y --only-upgrade zabbix-server-mysql zabbix-frontend-php

And if you are using Apache server (httpd) install “zabbix-apache-conf“:

apt-get install -y zabbix-apache-conf

b) RHEL 8/9 & CentOS 8/9 & Oracle/Alma/Rocky Linux 8/9

Upgrade Zabbix and when prompted what to do with Zabbix configuration file, just press enter to keep the current version of “zabbix_server.conf

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/$(rpm -E %{rhel})/x86_64/zabbix-release-6.0-4.el$(rpm -E %{rhel}).noarch.rpm
dnf clean all
dnf upgrade -y zabbix-server-mysql zabbix-web-mysql

And if you are using Apache server (httpd) install “zabbix-apache-conf“:

dnf install -y zabbix-apache-conf

c) Debian 11 & Debian 10

Please delete old Zabbix repository so that we can install the new one:

dpkg --purge zabbix-release

Upgrade Zabbix and when prompted what to do with Zabbix configuration file, just press enter to keep the current version of “zabbix_server.conf“:

wget https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-4+debian$(cut -d"." -f1 /etc/debian_version)_all.deb
dpkg -i zabbix-release_6.0-4+debian$(cut -d"." -f1 /etc/debian_version)_all.deb
apt update
apt install -y --only-upgrade zabbix-server-mysql zabbix-frontend-php 

And if you are using Apache server (httpd) install “zabbix-apache-conf“:

apt-get install -y zabbix-apache-conf

d) Rasbian 11 & Rasbian 10

Please delete old Zabbix repository so that we can install the new one:

dpkg --purge zabbix-release

Upgrade Zabbix and when prompted for Zabbix configuration file, just press enter to keep the current version of “zabbix_server.conf“:

wget https://repo.zabbix.com/zabbix/6.0/raspbian/pool/main/z/zabbix-release/zabbix-release_6.0-4+debian$(cut -d"." -f1 /etc/debian_version)_all.deb
dpkg -i zabbix-release_6.0-4+debian$(cut -d"." -f1 /etc/debian_version)_all.deb
apt update
apt install -y --only-upgrade zabbix-server-mysql zabbix-frontend-php 

And if you are using Apache server (httpd) install “zabbix-apache-conf“:

apt-get install -y zabbix-apache-conf

Step 4: Start Zabbix service and database upgrade

Great job! Zabbix server and frontend are successfully upgraded! However, the Zabbix database is still on the old version because we didn’t upgrade it. This is especially evident when connecting to a frontend because you would be greeted with the message “The frontend does not match Zabbix database“.

Luckily, upgrade of the Zabbix database is the easy part, just start the Zabbix service and it will automatically do the upgrade:

systemctl start zabbix-server

Database upgrade can last from 1 minute to hours depending on database size. Check the upgrade progress with the command “cat /var/log/zabbix/zabbix_server.log | grep database“:

# cat /var/log/zabbix/zabbix_server.log | grep database
1794:20200408:200607.700 current database version (mandatory/optional): 05040000/05040002
1794:20200408:200607.700 starting automatic database upgrade
1794:20200408:200607.706 completed 1% of database upgrade
1794:20200408:200608.804 completed 10% of database upgrade
                            .....
1794:20200408:200613.111 completed 98% of database upgrade
1794:20200408:200613.123 completed 100% of database upgrade
1794:20200408:200613.123 database upgrade fully completed
1794:20200408:200613.136 database could be upgraded to use primary keys in history tables

Database upgrade is completed successfully when you receive the message “database upgrade fully completed” in the Zabbix server log file.

Check out section “Learn about common upgrade errors” if you receive error “[Z3005] query failed: [1118] Row size too large“.

Step 5: Clear browser cache and check Zabbix version

NOTE: If you get an error saying that the minimum required version of php is 7.4, upgrade your PHP using these commands:

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php -y
sudo dnf module install php:remi-7.4 -y

Zabbix frontend may look pretty weird after the upgrade because you haven’t deleted the cache on your browser! Clear the browser cache and log in to the Zabbix.

And if you still receive the error “The frontend does not match Zabbix database” check out step 11: Learn about common upgrade errors

One more thing to do! On the server, check if the upgrade was successful with the command “zabbix_server -V“:

# zabbix_server -V
zabbix_server (Zabbix) 6.0.0

And on the frontend, check if the correct Zabbix version (6.0.x) is displayed on the bottom of the page:

Checking Zabbix version on the frontend
Checking Zabbix version on the frontend

Step 6: Database upgrade to primary keys

As of Zabbix 6.0, primary keys are used for all tables in new installations. Unfortunately there is no automation here, we have to manually upgrade the history tables in existing installations to primary keys.

Before proceeding, make sure to backup your database using Step 2!

I will run the demonstration on MariaDB 10.6, and if you are using another type of database (MySQL, PostGreSQL, TimeScaleDB, Oracle) then check out the official Zabbix guide.

a. Create new history tables and rename old ones

First, install “zabbix-sql-scripts” package:

CentOS, REHEL, Oracle/Alma/Rocky Linux
dnf install -y zabbix-sql-scripts

             OR

Ubuntu/Debian/Rasperry Pi OS
apt-get install -y zabbix-sql-scripts

Then run “history_pk_prepare.sql” script to rename old history tables and create new ones with the new primary key:

 mysql -uroot -prootDBpass zabbix < /usr/share/zabbix-sql-scripts/mysql/history_pk_prepare.sql

b. Migrate data from old history tables to new ones

Note that this step is optional if you do not need the old data from the history tables (you always have data from the trends tables).

Create a temporary directory to use to export and import history data (delete it after the import):

mkdir /var/lib/mysql-files && chmod 777 /var/lib/mysql-files

Connect to the MySQL/MariaDB server:

mysql -uroot -prootDBpass zabbix 

Tweak DB performance to speed up data migration and avoid timeout errors:

SET SESSION SQL_LOG_BIN=0;SET SESSION bulk_insert_buffer_size= 1024 * 1024 * 256;SET MAX_STATEMENT_TIME=0;

Migrate history data from old tables to new ones:

SELECT * INTO OUTFILE '/var/lib/mysql-files/history.csv' FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n' FROM history_old;
LOAD DATA INFILE '/var/lib/mysql-files/history.csv' IGNORE INTO TABLE history FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n';

SELECT * INTO OUTFILE '/var/lib/mysql-files/history_uint.csv' FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n' FROM history_uint_old;
LOAD DATA INFILE '/var/lib/mysql-files/history_uint.csv' IGNORE INTO TABLE history_uint FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n';

SELECT * INTO OUTFILE '/var/lib/mysql-files/history_str.csv' FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n' FROM history_str_old;
LOAD DATA INFILE '/var/lib/mysql-files/history_str.csv' IGNORE INTO TABLE history_str FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n';

SELECT * INTO OUTFILE '/var/lib/mysql-files/history_log.csv' FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n' FROM history_log_old;
LOAD DATA INFILE '/var/lib/mysql-files/history_log.csv' IGNORE INTO TABLE history_log FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n';

SELECT * INTO OUTFILE '/var/lib/mysql-files/history_text.csv' FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n' FROM history_text_old;
LOAD DATA INFILE '/var/lib/mysql-files/history_text.csv' IGNORE INTO TABLE history_text FIELDS TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n';

If everything works correctly, then delete the old history tables from the Zabbix database:

DROP TABLE history_old;
       DROP TABLE history_uint_old;
       DROP TABLE history_str_old;
       DROP TABLE history_log_old;
       DROP TABLE history_text_old;

CONGRATULATIONS!
You have successfully upgraded Zabbix to version 6!
No need to change anything else as other steps are optional.

CONTINUE TO LEARN MORE:
How to do a minor upgrade of Zabbix (6.0.x to 6.0.y) ?
How to upgrade Zabbix-proxy or Zabbix-Agent?
Did something go wrong? Learn how to restore Zabbix to a previous version.
How to upgrade Zabbix 6.0 to 6.4 using a script?
Learn about common upgrade errors

Step 7: Upgrade between minor versions

Zabbix team works non-stop like a bee and every couple of weeks it releases a smaller upgrade that fixes bugs and brings new functionalities, so it is necessary to do the minor upgrade at least once a month. A minor upgrade is pretty safe, no need for backup, because you can easily upgrade minor versions of 6.0.x (for example, from 6.0.0 to 6.0.4) with this commands:

a) Ubuntu/Debian/Rasbian

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

b) CentOS / RHEL / Oracle / Alma/ Rocky Linux

dnf upgrade 'zabbix-*'

Restart Zabbix server afterward:

systemctl restart zabbix-server

Step 8: Upgrade Zabbix-Proxy or Zabbix-Agent

If you need to upgrade the proxy server, just repeat steps from “Step 3: Upgrade Zabbix Server, Frontend” but use “apt install -y --only-upgrade zabbix-proxy” for Ubuntu/Debian/Rasbian or “dnf upgrade -y zabbix-proxy” on RHEL insted of “zabbix-server-mysql zabbix-frontend-php” and restart service afterward with “systemctl restart zabbix-proxy“.

Procedure for Zabbix-Agent upgrade is similar – repeat the instruction for proxy, but replace “zabbix-proxy” with “zabbix-agent“.

Step 9: Restore procedure (if Zabbix upgrade fails)

Something went wrong? You can follow this step only if you have done everything from the Step 2: Backup Zabbix components. Make sure to change db name, db root user and db Zabbix user with yours, and if your database is on another dedicated server then change localhost also.

a) Stop Zabbix server

systemctl stop zabbix-server

b) Delete database and create a new one with the right permissions

mysql -u'root' -p'rootDBpass' -e "drop database zabbix"
mysql -u'root' -p'rootDBpass' -e "create database zabbix character set utf8mb4 collate utf8mb4_bin;"
mysql -u'root' -p'rootDBpass' -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixDBpass';"

c) Import database from the backup

zcat /opt/zabbix_backup/db_files/zabbix_backup.sql.gz | mysql -h localhost -u'root' -p'rootDBpass' 'zabbix'

d) Remove Zabbix web and bin files

rm -rf /usr/sbin/zabbix_server /usr/share/zabbix

e) Restore files from the backup

cp -rp /opt/zabbix_backup/conf_files/zabbix_server.conf /etc/zabbix/zabbix_server.conf
cp -rp /opt/zabbix_backup/bin_files/zabbix_server /usr/sbin/zabbix_server
cp -rp /opt/zabbix_backup/doc_files/zabbix-* /usr/share/doc/
cp -rp /opt/zabbix_backup/web_files/zabbix /usr/share/zabbix
cp -rp /opt/zabbix_backup/conf_files/zabbix.conf /etc/httpd/conf.d/zabbix.conf 2>/dev/null
cp -rp /opt/zabbix_backup/conf_files/zabbix.conf /etc/apache2/conf-enabled/zabbix.conf 2>/dev/null
cp -rp /opt/zabbix_backup/conf_files/php-fpm.conf /etc/zabbix/php-fpm.conf  2>/dev/null

f) Start Zabbix server

systemctl start zabbix-server

Delete your browser cache and you are done! Zabbix is now on an old version.

Step 10: How to upgrade Zabbix 6.0 to 6.4?

You’re probably wondering why I didn’t write about the Zabbix 6.4 upgrade instructions at the beginning of this tutorial? The answer is simple, I m not fond of the Zabbix standard release!

Zabbix 6.4 standard release brings new features but at the cost of stability (more bugs) and support is limited to only 6 months! On the other hand, the Zabbix LTS release, like 6.0, is supported for 5 years and it’s much more stable. You can find more information about Zabbix’s life cycle and release policies on the official website.

However, if you don’t care about bugs and just want to try the new features – here are the instructions just for you! Before proceeding, consider backing up your Zabbix database by following the instructions from the step 2.

a) Upgrade Zabbix to 6.4 using a bash script

Download the script “upgrade_zabbix.sh” from my site and set executable permissions:

wget https://bestmonitoringtools.com/dl/upgrade_zabbix.sh
chmod +x upgrade_zabbix.sh

Upgrade Zabbix 6.0 or 6.2 to 6.4 using the script and when prompted what to do with the Zabbix configuration file, just press enter to keep the current version of “zabbix_server.conf“.

sudo ./upgrade_zabbix.sh mysql 6.4 1

As you may have noticed, the script has 3 arguments: type of database, upgrade version, and packet version. Those arguments enable us to use the same script for various Zabbix upgrades (6.0 to 6.4, and some day 7.0 to 7.2 or 7.0 to 7.4). In the case of PostgreSQL, just replace mysql input parameter with pgsql.

b) Restart Zabbix server and upgrade the database

Upgrade of the Zabbix database is the easy part, just start the Zabbix service and it will automatically do the upgrade:

systemctl restart zabbix-server

Database upgrade can last from 1 minute to hours depending on database size. Check the upgrade progress with the command “cat /var/log/zabbix/zabbix_server.log | grep database“:

# cat /var/log/zabbix/zabbix_server.log | grep database
  1869:20220705:142803.646 current database version (mandatory/optional): 06000000/06000000
  2144:20220705:144215.172 current database version (mandatory/optional): 06000000/06000000
  2144:20220705:144215.173 starting automatic database upgrade
  2144:20220705:144215.200 completed 1% of database upgrade
  2144:20220705:144215.221 completed 2% of database upgrade
                 ....
  2144:20220705:144223.158 completed 98% of database upgrade
  2144:20220705:144223.159 completed 100% of database upgrade
  2144:20220705:144223.160 database upgrade fully completed
  13760:20220705:144235.266 current database version (mandatory/optional): 06020000/06020000

Database upgrade is completed successfully when you receive the message “database upgrade fully completed” in the Zabbix server log file.

Zabbix frontend may act weird after the upgrade if you don’t delete the cache on your browser. Clear the browser cache and log in to the Zabbix and you are done with the Zabbix upgrade!

Step 11: Learn about common upgrade errors

How to fix error “Unable to start Zabbix server due to unsupported XY database server version

Zabbix does not support some older versions of the database, you may recive a error like this:

Unable to start zabbix server due to unsupported mariadb database server version 

Don’t worry, you have two options to resolve this problem:

  • Upgrade you database
  • Ignore this error by override by setting “AllowUnsupportedDBVersions=1” in Zabbix server configuration file /etc/zabbix/zabbix_server.conf

How to fix error “[Z3005] query failed: [1118] Row size too large.

Some readers have reported upgrade failure because of the error in the log “[Z3005] query failed: [1118] Row size too large“.

[Z3005] query failed: [1118] Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs ...

If you recive error above try to disable “innodb_strict_mode“.

a) Disable innodb strict mode:

mysql -uroot -p'rootDBpass' zabbix -e "set global innodb_strict_mode='OFF';"

b) Restart Zabbix server:

systemctl restart zabbix-server 

And check if upgrade was successful with the command “cat /var/log/zabbix/zabbix_server.log | grep database“.

c) Enable innodb strick mode back:

mysql -uroot -p'rootDBpass' zabbix -e "set global innodb_strict_mode='ON';"

How to fix error “The frontend does not match Zabbix database

Error “The frontend does not match Zabbix database” can happen because of two reasons.

a) Zabbix frontend is upgraded but Zabbix database is not

This happens when you upgrade the frontend but not the Zabbix database. Error messages on frontend may look something like this:

The zabbix database version does not match current requirements. your database version: 5040000. required version: 6000000. please contact your system administrator.
The zabbix database version does not match current requirements. your database version: 5000000. required version: 6000000. please contact your system administrator.
The frontend does not match zabbix database. current database version (mandatory/optional): 5040000/5040002. required mandatory version: 6000000. contact your system administrator.
The frontend does not match Zabbix database. Current database version (mandatory/optional): 6000000/6000001. Required mandatory version: 6020000. Contact your system administrator.

First, check out Zabbix log file because database upgrade may still be in progress, in that case, you just need to wait until the upgrade is finished (do not restart Zabbix service):

# cat /var/log/zabbix/zabbix_server.log | grep database
1794:20200408:200613.123 completed 3% of database upgrade
                       ...
1794:20200408:200613.123 completed 97% of database upgrade
1794:20200408:200613.123 completed 100% of database upgrade
1794:20200408:200613.123 database upgrade fully completed
1794:20200408:200613.136 database is not upgraded to use double precision values

However, if your database is not upgrading then try to start the Zabbix service to initiate database upgrade (check the progress in the log file):

systemctl restart zabbix-server

b) Zabbix database is upgraded but Zabbix frontend is not

This happens when you upgrade the database but not the Zabbix frontend. Error messages may look something like this:

The frontend does not match Zabbix database. Current database version (mandatory/optional): 6000000/6000002. Required mandatory version: 5040000. Contact your system administrator.

Try to upgrade frontend again (Step 3), but upgrade only “zabbix-frontend-php” on Ubuntu/Debian/Rasbian or “zabbix-web-mysql” if your Zabbix is on CentOS/RHEL/Oracle/Alma/Rocky Linux.

Note, if you have not used the official Zabbix package installation procedure (or my guide), then there is a chance that your frontend files are located elsewhere – in that case, you are on your own.

How to fix error “database is not upgraded to use double precision values

You may notices red “No” for “Database history tables upgraded” status on “System information” widget. What is that? If you are upgrading an older Zabbix instance, prior to 5.0 then you must apply database patch.

“Database history tables upgraded” set to “No”

With Zabbix 5.0 float data type supports precision of approximately 15 digits and bigger range. This is by default for new installations, but if you are upgrading then a manual database upgrade patch must be applied.

Before we apply the patch let’s check current table description (make sure to change db name, user and password with yours):

mysql -u'zabbix' -p'zabbixDBpass' zabbix -e "show create table history;"
| history | CREATE TABLE history (
itemid bigint(20) unsigned NOT NULL,
clock int(11) NOT NULL DEFAULT '0',
value double(16,4) NOT NULL DEFAULT '0.0000',
ns int(11) NOT NULL DEFAULT '0',
KEY history_1 (itemid,clock)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |

Download the MySQL/MariaDB patch “double.sql” and apply it (PostGreSql users need to change “mysql” with “postgresql” in the URL path):

wget https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/database/mysql/double.sql
mysql -u'zabbix' -p'zabbixDBpass' zabbix < double.sql

Check the new table description:

mysql -u'zabbix' -p'zabbixDBpass' zabbix -e "show create table history;"
history | CREATE TABLE history (
itemid bigint(20) unsigned NOT NULL,
clock int(11) NOT NULL DEFAULT '0',
value double NOT NULL DEFAULT '0',
ns int(11) NOT NULL DEFAULT '0',
KEY history_1 (itemid,clock)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |

Now we need to add the line bellow to “zabbix.conf.php” with the text editor (“nano /etc/zabbix/web/zabbix.conf.php“) to remove warning message from the frontend:

$DB['DOUBLE_IEEE754'] = 'true';

How to fix error “cannot start HA manager: timeout while waiting for HA manager registration

This error appears on RHEL, CentOS, Oracle/Alma/Rocky Linux and it is SELinux related. You need to install a new SELinux policy:

dnf -y install zabbix-selinux-policy

And enable daemons_enable_cluster_mode with this command

setsebool -P daemons_enable_cluster_mode on

Thank you for reading.

Please share your experience with the Zabbix upgrade in the comment section. What errors did you have and how did you resolve them?

60 thoughts on “Upgrade Zabbix (5.0, 5.2, 5.4) to 6.0 like a Pro [+6.0 to 6.4 guide]”

    • Yes, the query is very slow when you use user permissions or filters. Use the Zabbix super admin account, and it should be faster. The Zabbix team is working on the problem. Regards.

      Reply
  1. Hello Aldin,
    If I have version 3.0.9 of Zabbix, would this description help me then? My server is Centos7…
    In step 7 B shouldn’t you indicate in the command the higher version of Zabbix that you want? If I want version 6.0 of Zabbix then would it be enough for me to just follow point 7 in its entirety?
    Thank you very much.

    Reply
  2. Ubuntu 22.04 trying to upgrade to Zabbix 6.4 when I run the commands I get redirection unexpected. I type in DIR and the script is there, not sure why I am getting the error. advice?

    Reply
  3. Hi. Thank you for this detailed guide. I was wondering wonder if you could give me your impressions before I go with the upgrade of my Zabbix 6.0 (I need to upgrade it to 6.4).

    My Zabbix installation has been provided with High-Availability, that is, two Zabbix Server nodes configured with HA and the database runs in a three-node Maxscale Cluster (one master, two slaves). Each Maxscale node is a separated server and all the nodes are synced and running. I’m thinking in follow your guide to upgrade my zabbix but having in mind this:

    1. Stop Zabbix Server service in both Zabbix Server nodes
    2. Apply the procedure you share with us in both Zabbix Server nodes but without starting Zabbix Server service.
    3. Start zabbix server service in just one of the zabbix server nodes and wait to succesfully finish the database upgrade. Once I get the message “database upgrade fully completed”, I can start the zabbix server service in the second zabbix server node and everything should be fine. I’m trusting the database upgrade would be replicated automatically across the three database nodes.

    Do you think my plan is going to work straightforward as I am imaging? Is there something I could be missing?

    Thanks a lot for your thoughts!

    Reply
  4. Thank you for all your contribution, I have the following doubt, how would I execute your script if I had the zabbix server on one server and mysql on another server?

    Reply
  5. Hi I upgraded from 5.2 to 6.0 and Im getting this error

    The job identifier is 10061.
    Feb 20 15:09:24 srvmonkode systemd[1]: zabbix-server.service: Can’t open PID file /run/zabbix/zabbix_server.pid (yet?) after start: No such file or directory
    Feb 20 15:09:24 srvmonkode systemd[1]: zabbix-server.service: Failed with result ‘protocol’.
    — Subject: Unit failed
    — Defined-By: systemd
    — Support: https://www.debian.org/support

    Reply
      • Edit /etc/zabbix/zabbix_server.conf and add the following line then Save

        AllowUnsupportedDBVersions=1

        Then start the Zabbix Service again it should start without error
        sudo systemctl start zabbix-server

        Check the Database Upgrade is happening with

        sudo cat /var/log/zabbix/zabbix_server.log | grep database

        Reply
  6. Hi, first of all I wanna say thanks because I’ve followed your tutorial many times to upgrade my Zabbix versions.
    Secondly, I need some guidance now. I’ve upgraded to Zabbix 6.0 without problems in my Ubuntu 18 but I’ve tried to upgrade to Ubuntu 20 and now I’ve got the error:
    The server does not match Zabbix database. Current database version (mandatory/optional): 06000000/06000000. Required mandatory version: 04000000.
    Any tips?
    Thanks.

    Reply
    • Did you try to resolve that error using instructions from Step 10? You need to upgrade the frontend.

      Reply
  7. I’d followed your instruction to install Zabbix 5.0 LTS with partitions, now I just built another test Zabbix server 5.0 with mariaDB10.3. I managed to upgrade using your tutorial to 6.0 and mariaDB10.6 but on Zabbix documentation says it uses Primary keys for history tables, I tried to follow but there is no zabbix-sql-scripts directory (I know you have it on your installing Zabbix 6.0 tutorial), is it OK to leave it like that?
    Just in case if you give direction to add the script, how about the partition?
    Thanks,

    Reply
    • I have just updated the tutorial, check out Step 6: Database upgrade to primary keys. I think partitioning should work, I’ll check that later because I’m not 100% sure

      Reply
  8. First and foremost Great Tutorial!

    All going smoothly until apache upgrade:

    root@zabbix:~# apt-get install -f zabbix-apache-conf
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    The following packages were automatically installed and are no longer required:
    linux-headers-4.15.0-66 linux-headers-4.15.0-66-generic
    linux-image-4.15.0-66-generic linux-modules-4.15.0-66-generic
    linux-modules-extra-4.15.0-66-generic
    Use ‘apt autoremove’ to remove them.
    The following NEW packages will be installed:
    zabbix-apache-conf
    0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
    Need to get 0 B/5,828 B of archives.
    After this operation, 18.4 kB of additional disk space will be used.
    (Reading database … 146425 files and directories currently installed.)
    Preparing to unpack …/zabbix-apache-conf_1%3a5.0.14-1+bionic_all.deb …
    Unpacking zabbix-apache-conf (1:5.0.14-1+bionic) …
    dpkg: error processing archive /var/cache/apt/archives/zabbix-apache-conf_1%3a5.0.14-1+bionic_all.deb (–unpack):
    trying to overwrite ‘/etc/zabbix/apache.conf’, which is also in package zabbix-frontend-php 1:4.2.4-1+bionic
    Errors were encountered while processing:
    /var/cache/apt/archives/zabbix-apache-conf_1%3a5.0.14-1+bionic_all.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    Any ideas on how to get around this would be much appreciated.

    Reply
  9. Hi
    Everything is updated but i still got that issue :
    The frontend does not match Zabbix database. Current database version (mandatory/optional): 5040000/5040000. Required mandatory version: 5000000. Contact your system administrator.

    Reply
  10. starting automatic database upgrade
    [Z3005] query failed: [1832] Cannot change column ‘scriptid’: used in a foreign key constraint ‘c_opcommand_2’ [alter table opcommand modify `scriptid` bigint unsigned not null]
    database upgrade failed

    systemctl stop zabbix_server.service
    mysql -u root
    show columns from zabbix.opcommand;
    ALTER TABLE zabbix.opcommand DROP FOREIGN KEY c_opcommand_2;
    systemctl start zabbix_server.service
    tail -f /var/log/zabbix/zabbix_server.log

    Reply
  11. Hi , thank you for the guide. What about the case where the DB is located in separate server than the zabbix server ?

    Reply
    • In that case, you need to point the Web server and Zabbix server to the DB server. Change default IP address (localhost) to the IP address of the DB server and make sure that the firewall doesn’t block the DB port.

      Reply
  12. To apply the fix to the DB, my CentOS 7 show me:
    ERROR 1045 (28000): Access denied for user ‘zabbix’@’localhost’ (using password: YES)
    Any idea?

    Reply
    • MySQL user or password is wrong. Check what password did you put in zabbix_server.conf file for the Zabbix database or use the root password.

      Reply
      • Hi
        First of all great tutorial.
        I’m using vmware appliance version of zabbix.

        I’m bit confused about connecting to mysql.
        In your tutorial you are using ‘root’ and ‘rootDBpass’ – terms ?
        Should it really be root account ? i’m not able connect using root. I was getting 1045 error
        But i was able to connect using DBuser account defined in zabbix_server.conf
        The only thing is, I was forced to use ‘–no-tablespaces’ option because DBuser did’t had all privilages to do DBDump.
        So my general question is: Should i use DBuser to connect do database ?

        Reply
        • In general, it’s best to avoid using the root user for everyday tasks due to security reasons. The tutorial used root for simplicity, but in production, it’s recommended to create and use dedicated DB users. Using the ‘DBuser’ account should work if you can perform necessary tasks like mysqldump and database restoration. Just ensure that this user has the required privileges.

          Reply
  13. Hello!

    I have the Zabbix 4.0 installed on CentOS 7. Do I need to do steps 1 and 2 and follow to step 10?

    Thank you,
    Fernando

    Reply
  14. Hello, I managed to do the procedure to upgrade from zabbix 4.0 to 0 5.0 without errors. I cleared the browser cache and accessed the zabbix page. The zabbix 4.0 welcome screen is still showing, and I upgraded it. What do I do? Did I forget something?

    Reply
  15. Hallo I have this problem,

    query failed: [1054] Unknown column ‘name’ in ‘field list’ [insert into events (eventid,source,object,objectid,clock,ns,value,name,severity) values (49157,0,0,19219,1600277944,695523406,0,’Zabbix agent on XXX is unreachable for 5 minutes’,0);

    in Graph I can see the dater, but Last check say
    2022-04-03 00:00:00

    Reply
    • Looks like some column is missing. Use the last backup or make a new one and then drop the DB and recreate it using a clean 5.x schema and load the backup again. However, I can’t guarantee this will work, there might be other problems too.

      Reply
  16. The Patch DB for Postgres DB is not clear.. if you can assist pls.

    Current command for MySQL
    mysql -u’zabbix’ -p’zabbixDBpass’ zabbix < double.sql

    What is the command for Postgres after wget pls?

    Reply
      • Hello

        I can’t alter table ‘history’ (on PostgreSQL):

        zabbix=# ALTER TABLE ONLY history
        ALTER COLUMN value TYPE DOUBLE PRECISION;
        ERROR: could not create temporary file “base/pgsql_tmp/pgsql_tmp21429.5”: No such file or directory
        zabbix=#

        There is another way to do it?

        Reply
  17. Bless you, man! This guide very-very helpful. Thanks a lot!
    Zabbix have removed compatibility with zabbix-proxy v.4 and in our case for some reasons proxy was installed on CentOS 6 (support of it deprecated also). So we got a double-stuck on this 😀
    As far our FE is on CentOS 7.5 – priceless step 10 have been finded. I think, it’s time to migrate to CentOS 8.
    I’ve used this script to solve issue with encoding:
    SELECT CONCAT(‘ALTER TABLE ‘, table_name, ‘ CHARACTER SET utf8 COLLATE utf8_bin; ‘,
    ‘ALTER TABLE ‘, table_name, ‘ CONVERT TO CHARACTER SET utf8 COLLATE utf8_bini; ‘)
    FROM information_schema.TABLES AS T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` AS C
    WHERE C.collation_name = T.table_collation
    AND T.table_schema = ‘zabbix’
    AND
    (C.CHARACTER_SET_NAME != ‘utf8’
    OR
    C.COLLATION_NAME not like ‘utf8%’);
    It takes all tables from zabbix-schema and in output we getting queries for each table. Then I’ve just applied this queries and changed DB charset and collation.
    like: ALTER TABLE lld_override_optrends CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin
    Hope, it will not fail, at least FE started and feeling well for an hour now 🙂
    Then I’ve updated frontend and now we are on 5.
    Thank you, sir!

    Reply
  18. Hello,

    I am facing one of the same issues here but not being fixed with the innodb fix.
    The following is the error:

    The frontend does not match Zabbix database. Current database version (mandatory/optional): 5000000/5000000. Required mandatory version: 4040000. Contact your system administrator.

    And be below is a sample of the logs related to zabbix-server.log:

    4477:20200521:063253.068 Starting Zabbix Server. Zabbix 4.4.7 (revision 77fb8c7ee0).
    4477:20200521:063253.068 ****** Enabled features ******
    4477:20200521:063253.068 SNMP monitoring: YES
    4477:20200521:063253.068 IPMI monitoring: YES
    4477:20200521:063253.068 Web monitoring: YES
    4477:20200521:063253.068 VMware monitoring: YES
    4477:20200521:063253.068 SMTP authentication: YES
    4477:20200521:063253.068 ODBC: YES
    4477:20200521:063253.068 SSH support: YES
    4477:20200521:063253.068 IPv6 support: YES
    4477:20200521:063253.068 TLS support: YES
    4477:20200521:063253.068 ******************************
    4477:20200521:063253.068 using configuration file: /etc/zabbix/zabbix_server.conf

    any help is greatly appreciated.

    Reply
    • Hi,
      On what OS are you upgrading Zabbix?
      Your frontend is on the old Zabbix version. Zabbix server and database are ok, but you need to check steps for frontend upgrade. Try to upgrade only the frontend – check out step 3.

      Regards

      Reply
    • I don’t think so. The new menu is more practical, at least for me. Maybe you need more time to get used to it 🙂

      Reply
  19. Great tutorial dude! You pointed out every possible errors and scenarios, with very good explanation how to fix them.

    Reply
  20. Hi, and thank you very much.

    With Step 1)/3) i had problems first, but with step by step it works:
    sudo mysql -uroot -p zabbix
    SET GLOBAL innodb_strict_mode=OFF;
    quit;

    Thank you very much.

    Greets

    Reply
  21. Hi,

    i have some problems with the DB upgrade!
    I use a Raspbian and MariaDB 10.3.

    15648:20200515:092700.660 database upgrade failed
    15655:20200515:092710.986 Starting Zabbix Server. Zabbix 5.0.0 (revision 9665d62db0).
    15655:20200515:092710.986 ****** Enabled features ******
    15655:20200515:092710.986 SNMP monitoring: YES
    15655:20200515:092710.986 IPMI monitoring: YES
    15655:20200515:092710.986 Web monitoring: YES
    15655:20200515:092710.986 VMware monitoring: YES
    15655:20200515:092710.986 SMTP authentication: YES
    15655:20200515:092710.986 ODBC: YES
    15655:20200515:092710.986 SSH support: YES
    15655:20200515:092710.986 IPv6 support: YES
    15655:20200515:092710.986 TLS support: YES
    15655:20200515:092710.986 ******************************
    15655:20200515:092710.986 using configuration file: /etc/zabbix/zabbix_server.conf
    15655:20200515:092710.993 current database version (mandatory/optional): 04050130/04050130
    15655:20200515:092710.993 required mandatory version: 05000000
    15655:20200515:092710.993 starting automatic database upgrade
    15655:20200515:092710.994 [Z3005] query failed: [1118] Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs [alter table `hosts` add `discover` integer default ‘0’ not null]
    15655:20200515:092710.995 database upgrade failed

    Do you have any idea whats wrong?

    Reply
    • Hello,

      can you please try this:

      1) Disable innodb strict mode:
      mysql -uroot -p’rootDBpass’ zabbix -e “set global innodb_strict_mode=’OFF’;”

      2) Restart Zabbix server: systemctl restart zabbix-server and check if upgrade was successful.

      3) Enable innodb strick mode back: mysql -uroot -p’rootDBpass’ zabbix -e “set global innodb_strict_mode=’ON’;”

      Comment please if this helps.

      Reply
  22. The last line of the data base upgrade logs says “database is not upgraded to use double precision values” and there is an upgrade note mentioned in the zabbix docs.

    However, I am unable to find the patch file in my case (postgres on CentOS 8)

    Can you please include where I can get the patch file or where it is located?

    Reply

Leave a Comment