A Step-by-Step Guide to Moving a Zabbix Database

Nikunj Patel
2 min readMay 5, 2024

--

Moving a Zabbix database to a new environment, such as AWS RDS, requires careful planning and execution to ensure a smooth transition with minimal disruption. This guide outlines the step-by-step process to successfully move a Zabbix database, along with considerations for testing and troubleshooting.

Step 1: Dumping the Current Database

The first step involves creating a backup of the current Zabbix database. This is achieved by executing the following command:

mysqldump — single-transaction zabbix | gzip > /mnt/zbx-dump.sql.gz

Step 2: Preparing the New Database and User Access

Before importing the database to AWS RDS, it is essential to set up the new database and user access. This includes creating a new database, username, and password to provide database access to newly created users.

Upon connecting to the database, execute the following commands:

mysql -h <AWS RDS SITE> -u <master user> -pCREATE DATABASE zabbix;SHOW DATABASES;GRANT ALL PRIVILEGES ON zabbix.* TO ‘<Set Your Username>’@’%’ IDENTIFIED BY ‘<Set your Password>’;FLUSH PRIVILEGES;SHOW GRANTS FOR ‘<Your Username>’@’%’;

Step 3: Importing the Database on AWS RDS

Next, the database backup is imported to the AWS RDS using the following command:

mysql -h <AWS RDS Site> -u <UserName> -p zabbix < /mnt/zbx-dump.sql

Step 4: Reconfiguring Zabbix to Use the New Database

It is crucial to update the Zabbix configuration to point to the new database server address. This involves editing the configuration files and restarting the Zabbix and Apache services:

Edit zabbix_server.conf:

Set DBHost to the new database server address.

Restart Zabbix server:

sudo systemctl restart zabbix-server

Edit zabbix.conf.php:

Set $DB[‘SERVER’] to the new database server address.

Restart Apache:

sudo systemctl restart apache2

Step 5: Testing and Troubleshooting

After the migration, it is important to thoroughly test the Zabbix frontend and review the server logs for any anomalies. In case of unexpected issues, the server and database logs should be checked for errors. If necessary, reverting to the previous database is an option, as the existing data in the old database remains intact.

If troubleshooting takes an extended period and the interval for lost data needs to be minimized, restarting from Step 1 may be necessary. It is crucial to remember to drop the new Zabbix database on AWS RDS to avoid errors during the re-creation process.

By following these steps and being diligent in testing and troubleshooting, the process of moving a Zabbix database can be carried out smoothly and effectively.

--

--

Nikunj Patel

Tech enthusiast & writer simplifying complex concepts. Empowering readers to navigate the digital landscape confidently. Join me in exploring tech trends!