In this post I will show how to migrate and update Cacti from an old server to a new server. In my case, old server platform was Red Hat 5 and Cacti was 0.8x version. As Red Hat 5 is old and you can't really upgrade it, I needed to migrate Cacti installation to a new Redhat 7.7 server. Besides that, Cacti was planned to be upgraded to 1.x version.
Process is actually quite simple - you need a new Cacti installation and there are many instructions for that. I installed Cacti 1.2.11 version using MariaDB 5.6.x and PHP 5.4.
Second step is to migrate existing configuration and possible graphs and plugins.
1. Install Fresh Cacti
As there are several installation instructions available, I don't go those over here. Do not run the installer using browser before migrating DB
2. Move DB Configuration
Database is actually quite simple to clone to a different server - mysqldump and mysql are your friends here. You can dump the values to an sql file and then import it in a similar way:
[root@localhost ~]$ mysqldump cacti -u root -p > old_cacti_db.sql - command will dump DB "cacti" through stdout
[root@localhost ~]$ mysql -u root -p cacti < cacti.sql - command will import cacti.sql to DB "cacti" throush stdin
You can log in to mysql to manually browse or modify something:
[root@localhost ~]$ mysql -u root -p
It must be noted that if you migrate to a different OS or server platorm, you may need to change the paths in the database. That was not needed in my case as Cacti installation was in /usr/share/cacti for both servers, but if you have different you must change these values in the DB.
To fix the paths in DB, you can either edit it manually using some SQL browser or then using mysql, you can use the REPLACE command for settings:
UPDATE settings SET VALUE = REPLACE(VALUE, '/old/path/to/cacti', '/usr/share/cacti')
Finish Cacti installation
After you have migrated the DB, launch Cacti installer using browser to your server server-ip/cacti. Setup is pretty simple and I won't go the steps here. However I would like to point that in my case, PHP and MariaDB settings needed to be optimized. Cacti installer will automatically show these and you can edit them in below files:
php.ini - Main PHP Configuration file
etc/my.cnf.d/server.cnf - MariaDB custom config file
I needed to tweak many MariaDB settings that go under [mysql] section in the file. Following values have been stable for me.
After successfull installation, it is time to move the graph files. You can find those from old server in rra folder under Cacti folder path/to/cacti/rra/. You can export the graphs using rrdtool, however as my Cacti settings (poller, polling time etc.) were identical, I just moved the files manually to destination server /usr/share/cacti/rra folder.
If you upgrade cacti from 0.8x to 1.x, some plugins may not work. It is feasible to install all plugins manually and not moving the files as that will guarantee that everything is working.