Upgrading Zabbix 3.2 to 4.2 on Ubuntu

In the test, I’ll upgrade Zabbix Server 3.2 to version 4.2, running on the Ubuntu Server 14.04 operating system, similarly, I can upgrade to version newer 4.2, as well as upgrade older versions of Zabbix, for example 2.0, as well as on the Ubuntu 16.04 and Ubuntu 18.04 operating systems.

Immediately switch to the root user:

sudo -i

Stop Zabbix (and also disable if there are any watchdog scripts so that they do not run it):

service zabbix-server stop
service zabbix-agent stop
service zabbix-proxy stop

Save the templates, network maps, network nodes.

Create a directory for backups:

mkdir /opt/zabbix-backup/

Just in case, we’ll back up the database without history:

mysqldump --ignore-table=zabbix.history --ignore-table=zabbix.history_uint --ignore-table=zabbix.trends --ignore-table=zabbix.trends_uint -u USERNAME -h localhost -pPASSWORD zabbix | gzip -c > /opt/zabbix-backup/zabbix_nohistory_`date +%Y-%m-%d`.sql.gz

Or with a story:

mysqldump -u USERNAME -h localhost -pPASSWORD zabbix | gzip -c > /opt/zabbix-backup/zabbix_full_`date +%Y-%m-%d`.sql.gz

As well as directories with Zabbix files:

tar -cvpzf /opt/zabbix-backup/usr_share_zabbix_`date +%Y-%m-%d`.tar.bz2 /usr/share/zabbix/
cp /etc/zabbix/ /opt/zabbix-backup/etc/
cp /etc/apache2/conf-enabled/zabbix.conf /opt/zabbix-backup/
cp -R /usr/share/zabbix/ /opt/zabbix-backup/zabbix/
cp -R /usr/share/doc/zabbix-* /opt/zabbix-backup/doc/

Delete the repository with the old version of Zabbix:

cp /etc/apt/sources.list.d/zabbix.list /opt/zabbix-backup/
rm -Rf /etc/apt/sources.list.d/zabbix.list

And add with a new one, for example for Ubuntu 14.04 (Trusty):

wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-2+trusty_all.deb
dpkg -i zabbix-release_4.2-2+trusty_all.deb
apt update

Or for Ubuntu 16.04 (Xenial):

wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-2+xenial_all.deb
dpkg -i zabbix-release_4.2-2+xenial_all.deb
apt update 

Or for Ubuntu 18.04 (Bionic):

wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-2+bionic_all.deb
dpkg -i zabbix-release_4.2-2+bionic_all.deb
apt update

Links to other versions can be found on the official website https://www.zabbix.com/download

Launch the Zabbix update process:

apt-get install --only-upgrade zabbix-server-mysql zabbix-frontend-php zabbix-agent

Then run Zabbix:

service zabbix-server start
service zabbix-proxy start
service zabbix-agent start

After the zabbix-server is started, it will start the database update process, so you have to wait about 10 minutes, it will not be possible to open this panel, for example, I had an error:

Database error
The frontend does not match Zabbix database. Current database version (mandatory/optional): 3030018/3030018. Required mandatory version: 4020000. Contact your system administrator.

Logs can be viewed in the directory /var/log/zabbix/.

Check whether the processes will start after the system is restarted and, if necessary, will activate autorun:

systemctl is-enabled zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2
systemctl restart zabbix-server zabbix-agent apache2

After the update, I recommend that you clear your browser cache.

See my other Zabbix related articles
How to Update Zabbix Agent on Ubuntu

Leave a comment

Leave a Reply

Discover more from IT Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading