Copy Zabbix Server From One Server to Another
Video Lecture
Description
Move Zabbix Server from One Cloud Provider to Another.
In my case, it was Digital Ocean to Hetzner
My Zabbix Server configuration is using Ubuntu 18.04 and MySQL
TODO:
- Reinstall Zabbix Server Code (server processes and PHP front end code)
- Database (MySQL, Create a SQL dump file and copy to new server)
- Custom Scripts (Alertscripts, and CheckSSL script)
- Repoint the domains A name record to the new IP from the new cloud provider
- Get a new SSL cert
- Reinstall Postfix
Reinstall Zabbix Server
Server Processes
wget https://repo.zabbix.com/zabbix/4.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.4-1+bionic_all.deb
dpkg -i zabbix-release_4.4-1+bionic_all.deb
apt update
Front End PHP
apt -y install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent
Configs
sudo nano /etc/zabbix/zabbix_server.conf
In server config file Set,
DBPassword=password
sudo nano /etc/zabbix/apache.conf
In apache config change to your region. I changed Riga to London,
php_value date.timezone Europe/Riga
Restart and Enable After Reboot
$ systemctl restart zabbix-server zabbix-agent apache2 $ systemctl enable zabbix-server zabbix-agent apache2
Copy Custom Scripts
Copy the secret.psk, and checkssl.sh scripts. Give the checkssl.sh script execute permissions (0755)
sudo chmod a+x checkssl.sh
Copy alert scripts sendsms.sh and slackalert.sh anb give execute permissions (0755)
sudo chmod a+x sendsms.sh
sudo chmod a+x slackalert.sh
Setup and Copy Database
On new server ensure mysql is already installed.
sudo apt-get install mysql-server
On old server create a snapshot of the DB.
mysqldump --quick zabbix | gzip > zabbix.gz
mysqladmin -uroot create zabbix
gunzip < zabbix.gz | mysql -uroot zabbix
Copy the file zabbix.gz to new server
Create User on new Server
mysql
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
QUIT;
Repoint Domain Name
Log onto your domain name provider and update your domain name A name record to the new ip address.
Install SSL Certificate
sudo apt-get install certbot
sudo apt-get install python-certbot-apache
sudo certbot --apache -d zabbix.seanwasere.com
Install Postfix
sudo apt install mailutils
sudo nano /etc/postfix/main.cf
Change value
...
inet_interfaces = loopback-only
inet_protocols = ipv4
...
Restart
sudo service postfix reload
Reconfigure the Zabbix Agent which is also running on the new server.
sudo nano /etc/zabbix/zabbix_agentd.conf
Since I also use scripts, I need to enable remote commands, and to update the agent to require PSK encryption, and then restart.
sudo service zabbix-agent restart