How To Upgrade Zabbix Server 4.0.X To 5.0.X On Centos 7?
In this lab, I will show you how to upgrade Zabbix server 4.0.x to 5.0.x on CentOS 7. This is All-In-One Zabbix Server running with MySQL Database.
Before we start, let’s check Zabbix components version:
yum list installed | grep zabbix

1. Stop Zabbix Server Daemon
Stop Zabbix server to make sure that no new data is inserted into database.
systemctl stop zabbix-server
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).
Create a directory where we will backup the Zabbix Server database and configuration Files:
mkdir -p /opt/zabbix-backup/db-files/
– Use the following command to backup the Zabbix Server database, replace zabbixdb with the name of your Zabbix Server database:
mysqldump -h localhost -u'zabbix_user' -p'StrongPassword' --single-transaction 'zabbix_db' | gzip > /opt/zabbix-backup/db-files/zabbix_backup.sql.gz
-u’zabbix_user‘: This is db user.
-p’StrongPassword‘: This is db password.
‘zabbix_db‘: This is mysql database name.
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:
cp /etc/zabbix/zabbix_server.conf /opt/zabbix-backup/
cp /etc/httpd/conf.d/zabbix.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. UPGRADE ZABBIX COMPONENTS
Remove old frontend
Existing Zabbix frontend must be removed before starting an upgrade. Old configuration file will be moved to /etc/httpd/conf.d/zabbix.conf.rpmsave
by rpm.
yum remove zabbix-web-*
Install SCL repository
On CentOS
run
yum install centos-release-scl
Install Zabbix 5.0 release package and enable zabbix-frontend repository
Install zabbix-release-5.0
package.
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
Edit /etc/yum.repos.d/zabbix.repo
file. Replace enabled=0
with enabled=1
.
vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend] ... enabled=1 ...
Install new frontend packages
yum install zabbix-web-mysql-scl
Official Zabbix 5.0 frontend packages use php-fpm. Update timezone in /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
file.
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Africa/Nairobi
Update remaining packages and restart Zabbix server
yum update zabbix-*
Restarting Zabbix server will upgrade the database. Make sure the database is backed up.
systemctl restart zabbix-server
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

Update remaining services
Start and enable php-fpm service.
systemctl start rh-php72-php-fpm
systemctl enable rh-php72-php-fpm
Restart Apache.
systemctl restart httpd
If you see this front end problem after upgraded. Please restore the zabbix.config from backup folder to /etc/httpd/conf.d/

cp /opt/zabbix-backup/zabbix.conf /etc/httpd/conf.d/
systemctl restart httpd
5. START ZABBIX PROCESSES
Start the updated Zabbix components.
systemctl start zabbix-server
systemctl start zabbix-proxy
systemctl start zabbix-agent
6. Patch DB and fix warning “Database history tables upg”
You may notices red “No” for “Database history tables upgraded” status on “System information” widget. What is that?

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_user' -p'StrongPassword' zabbix_db -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_user' -p'StrongPassWord' zabbix_db < double.sql
Check the new table description:
mysql -u'zabbix_user' -p'StrongPassword' zabbix_db -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 in the end of “zabbix.conf.php
”
vi /etc/zabbix/web/zabbix.conf.php
$DB['DOUBLE_IEEE754'] = 'true';
Check zabbix compenent version after upgraded
yum list installed | grep zabbix

And we are done with the Upgrade Zabbix from 4.0.x to 5.0.x process !