How to Upgrade to Ubuntu 20.04 without breaking Zabbix

Recently I ran into a raft of issues when I upgraded from Ubuntu 18.04 to 20.04 on my Zabbix server.
My reasons for doing this was because Apache had several CVE’s and wouldn’t upgrade to the latest version using the default Ubuntu repo’s, whereas upgrading to 20.04 got me on the latest Apache2 version.

Firstly before you start any of this I cannot stress enough the importance of taking a backup of your Zabbix server as well as your Zabbix database and testing the backups too before starting any of the upgrade. I usually just take a snapshot of the VM running my Zabbix server. If you get into hot water then you can simply roll back to the point that you took the snapshot. But in this instance I have a sandbox environment setup and I simply cloned my zabbix server and database server into my sandbox first and did a dry run in there of the upgrade and only once I had tested it fully did I then perform the upgrade on my production zabbix server. If people are interested in how to simply setup a sandbox environment, then let me know and i’ll post up a separate topic on how to do that too. It’s actually easier than you might think :slight_smile:

Step 1 - Install any outstanding Updates on your Ubuntu server
apt-get update && apt-get upgrade

Step 2 - Upgrade to the latest zabbix version
rm -Rf /etc/apt/sources.list.d/zabbix.list
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb
dpkg -i zabbix-release_5.0-1+bionic_all.deb

Say Yes to overwriting your /etc/apt/sources.list file
apt-get update
apt-get install --only-upgrade zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-apache-conf
service zabbix-server start
service zabbix-agent start

Next log in to your Zabbix UI using a web browser. If you are quick to do this you will get a notice saying your Zabbix database is not on the correct version. Do not panic. Zabbix will be doing a silent upgrade in the background. Be patient and the page will refresh and eventually give you the login screen.
Once logged in you might find the interface looks a little different since version 5 now has the menu on the left instead of the top. And no I also coulnd;t find an option to move it back either, but bare with it, you’ll get used to it :slight_smile:
Once logged in, just go through and make sure everything is still working as expected.

Step 3 - Do the release upgrade for Ubuntu
apt update && apt upgrade -y
sudo apt --purge autoremove
sudo apt install update-manager-core

This next bit is best done via the console or be sure to run “tmux” first so that if you get disconnected, then you can reconnect back to your session without loosing it.
sudo do-release-upgrade -d

  • Say Yes to begin the upgrade and work through all the prompts.
  • Say Y to removing any obsolete programs etc
  • Say Yes to restarting services automatically
  • If you get asked to replace any config files, choose the default option of “No”. aka just hit Enter.
  • Choose LXD 4.0 snap track, which is recommended
  • Say yes to removing obsoleted software
  • Then at the end simply say Yes to reboot your server.

Step 4 - Don’t Panic
At this stage your Zabbix will be broken. Don’t panic. This is why I’ve written this topic, because if anyone arrives here these are the steps I took to get it working again.
The reason why it’ll appear broken is that hte upgrade firstly uninstalls the MySQL libraries and if your like me and use MySQL as your database backend then you’ll need to do these steps to put it back. If you use Postgres then you may need to substitute my mysql commands for the equivelant postgres ones.

First we need to put hte correct repo in for Zabbix and Ubuntu 20.04
rm -Rf /etc/apt/sources.list.d/zabbix.list
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
dpkg -i zabbix-release_5.0-1+focal_all.deb

Now update
apt-get update

Lastly install the missing components needed to run Zabbix again
apt-get install --only-upgrade zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-apache-conf
apt-get install zabbix-server-mysql
apt install php
apt install php-gd php-ldap openipmi fping php-mbstring php-bcmath

At this point it’s probably best to just reboot and then you should be back up and running again.

5 Likes

Hey… I appreciate you allowing me in here. This particular scenario is plaguing me. I have used Zabbix for MANY years and now I find myself on ubuntu 18.04 with Zabbix 6.0. I use your steps and I get successfully to this line

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

How can I help you help me? Thanks in advance.

hi @JoeAshley , you mention you sucessfully get to that line, so I presume the next step which is to start the services doesn’t work ??
Are you able to share any output you get or if the services fail to start, can you try running:

journalctl -u zabbix-server

and share the output you get from that ??

Thanks for the reply…I ended up building a new OS and moving the DB. I guess I accomplished the same thing and was probably better to do but I sure would have liked to see it work… I am not new to Ubuntu by any means but my day job is Windows so I guess I just wanted to see it work like you were able to. I have a Zimbra server I need to do the same thing to :frowning:

The joys of being in IT.

I’m doing it to myself. These are both personal servers :smiley: