Transferring Zabbix to another server

It took one time to transfer Zabbix server version 4.4.10 running on Ubuntu Server 14.04 to a new server running Ubuntu Server 20.04 and at the same time I updated Zabbix to version 5.2

On the old system, I stopped the zabbix server and made a backup of the database:

service zabbix-server stop
mysqldump -u root zabbix > zabbix.sql

When creating a backup, you can compress it:

mysqldump -u root zabbix | gzip -c > zabbix.sql.gz

If important processes are running on the server, for example, in my case, the server also had telephony Asterisk, Samba, and other services, then in order not to overload the server, we will start creating a database dump with the lowest priority for the CPU and disk system:

nice -n 19 ionice -c2 -n7 mysqldump -u root zabbix > zabbix.sql

On a new server, if the database size is very large and the import process will take a long time, then you can install screen:

apt-get install screen

Screen allows you to create a session with the specified name and disconnect from it using the Ctrl+a d keys, and you can also disconnect from the server while the database is being imported:

screen -S zabbix

To then reconnect to the session:

screen -r zabbix

An example of creating a database and importing:

mysql -u root -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'password.ixnfo.com';
quit;
mysql -u root zabbix < zabbix.sql

If the database was previously packed, then unpack it first:

gzip -d zabbix.sql.gz

If the database is large, you can see the import process using pv:

apt install pv
pv zabbix.sql | mysql -u root zabbix

We transferred the database, now it remains to install a clean Zabbix server, for example, as I described in the article:
Zabbix installation on Ubuntu from distribution packages

After installation, in the files /etc/zabbix/zabbix_server.conf and /etc/zabbix/web/zabbix.conf.php we will specify the username and password to connect to the database and also configure it as on the old server.

Then we start Zabbix server and wait until it automatically updates our database to the current version (this can be a long process):

service zabbix-server start

In the logs /var/log/zabbix/zabbix_server.log, you can see the process of updating the database, after the update is completed, check whether the Zabbix server is running and, if necessary, run it again:

service zabbix-server status

Since I already had a web server configured, we will create a symbolic link to www Zabbix files in any convenient place, for example:

sudo ln -s /usr/share/zabbix/ /var/www/html/

See also my articles:

Leave a comment

Leave a Reply