There wasn’t an official guide on how to migrate Zabbix, but I did find this guide very useful! Debian Jessie is end of life middle of next year, so being proactive, I wanted to migrate it over to a fresh Debian Stretch server. The below steps will showcase set up and cutover to the new server. I wanted to keep the IP address on the new server the same as the old one so I won’t have to bother changing all our Zabbix agents.
- Create new Debian Stretch server and install Zabbix server and MySQL
- Perform remote MySQL dump from original server to new server, set up new MySQL database
- Copy configurations over to new server,
- Switch over IP addressing and DNS configuration
New server set up
With new Debian Stretch server, install Zabbix from packages, following these instructions.
Setup database for migration:
mysql> create user 'zabbix'@'localhost' identified by '<password>'; mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>'; mysql> quit;
Run the below command on existing Zabbix server to migrate database over to new server. The migration took about 1-2 hours to finish (20 GB database)
# systemctl stop zabbix-server.service # ssh -l root <new server IP> "mysqldump -u <mysqluser> -p | gzip -9" > /pathto/zabbixdb.sql.gz # pv /pathto/zabbixdb.sql.gz | gunzip | mysql -u zabbix -p zabbix
You can run the below mysql command on another ssh session to view progress. The resulting database size on new server was about 17GB:
SELECT table_schema AS "zabbix", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size in (MB)" FROM information_schema.TABLES GROUP BY table_schema;
I wanted to keep the configurations the same, so copied the below files over to the new server:
I set up SSL, and created temporary DNS records to point to https://newzabbixserver.domain.com
I then ran through the front-end installation steps to connect to the mysql database. All your previous configuration on the server should be retained. At this point it would be good to check hosts, reports, graphs etc. to confirm all your data migrated correctly.
I then perform the cutover by shutting off the old machine. On the new server, I change the IP address and DNS records to point to the old server. I make sure the apache2 configuration file also points to the new server
Once the above is done, I start the zabbix-server service, and if all is well, it should start chugging on as normal!
# service zabbix-server start # update-rc.d zabbix-server enable
This issue may not crop up during your own migration process but I included it anyway.
Zabbix-server.service would constantly crash when hitting a max poller of 151 connections (this is the default setting upon installation). This may not be an issue for your server if you have less than 151 Zabbix pollers. I increased the maximum to 500 with the below command:
mysql> set global max_connections = 500; mysql> show variables like "max_connections";
Overall it was a pretty seamless process. I hadn’t done a Debian server migration with mysql before so that was pretty fun!