Today I've solved the problem of one server being to slow to handle the growth of my zabbix configuration. I'm using zabbix-server 2.2.2 with MySQL/Debian backend and around 20 zabbix-agents with Debian installed.
Let's say old Zabbix server IP is: A.B.C.D and new is: U.X.Y.Z. The domain name for the instalation will be: http://zbx.newmachine.com
Below you will find all steps to migrate your configuration:
Ensure all agents will accept connections from the new IP Modify each agent configuration file (in debian: /etc/zabbix/zabbix_agentd.conf) and add new IP
Server=127.0.0.1,A.B.C.D,U.X.Y.Z
You can leave the old one for now.
Restart all agents so you can forget about them. Run on all agent server:
/etc/init.d/zabbix-agent restart
It's time to install zabbix on the new machine:
apt-get install zabbix-server-mysql zabbix-frontend-php
Do not start the server for now.
Stop zabbix-server on the old machine:
/etc/init.d/zabbix-server stop
Dump zabbix DB on the old machine. I'm using zabbix mysql user - change it if needed to suit your configuration:
mysqldump -u zabbix -p zabbix > /tmp/zabbix_db_dump
I can take a while - mine was around 1,5GB
In the meantime you can prepare mysql user on the new machine. Login to mysql as root and run:
create database zabbix
Now you can use the old zabbix user password - you will find it in: /etc/zabbix/zabbix.conf.php on the old machine
create user 'zabbix'@'localhost' identified by 'PASSWORD';
use zabbix;
grant all privileges on zabbix.* to 'zabbix'@'localhost';
Copy database to the new machine using compression:
scp -C /tmp/zabbix_db_dump [email protected]:/tmp
Import zabbix db on the new machine:
mysql -u zabbix -p zabbix < /tmp/zabbix_db_dump
Now you can setup DNS and virtual host for the new installation. After that run:
http://zbx.newmachine.com in your browser
to check whether all web server requirements for zabbix are fullfilled.
Proceed with zabbix instalation until the end. After that you sould be able to login:
http://zbx.newmachine.com with your old credentials
Overwrite zabbix configuration with the old one if you use the same version on both machines or just setup database password in file (/etc/zabbix/zabbix_agentd.conf):
DBPassword=PASSWORD
Switch zabbix-server to on in /etc/default/zabbix-server:
START=yes
Start new zabbix server:
/etc/init.d/zabbix-server start
Check if everything is running fine :)
Extra steps: If you're running a smtp relay for zabbix email notifications, don't forget to adjust your MTA configuration to relay from IP: U.X.Y.Z You can now modify agents configuration to stop answering to the old IP and remove old zabbix setup.