Migrating Cacti from one server to another

You may need to migrate cacti from one server to another due to one reason or another. This guide was used to migrate cacti from ubuntu server 12.04 to 14.04. The steps below are modifications of the guide

Below are steps;

  • Install Cacti on the New Server
  • Turn Off Cacti at the Old Server
  • Migrate the Database
  • Copy the RRD Files as XML
  • Reconvert the XML back to RRD File
  • Activate the New Cacti

Install Cacti on the New Server

  • Use the following link (http://www.unixmen.com/install-cacti-ubuntu-14-04/), after finishing installation on command line, don’t go to browser until step 6 when activating the new cacti.
  • Turn-off the poller
  • Run the command $ sudo vim /etc/cron.d/cacti
  • Disable the poller by putting the character ‘#’ in front of the crontab entry then save & quit

Turn Off Cacti at the Old Server

  • Run the command $ sudo vim /etc/cron.d/cacti
  • Disable the poller by putting the character ‘#’ in front of the crontab entry then save & quit.

Migrate the Database

  • At the old server run the command $ sudo mysqldump -u root  -p  cacti > ~/cacti.sql
  • When it asks for the password, enter the password for mysql database
  • SCP on the old data and grap the data and move it to new server.
  • On the server run the following $ sudo mysql -u root -p cacti < ~/cacti.sql

Copy the RRD Files as XML

Do the following on the old server

  • Go to the directory $ cd /var/lib/cacti/rra/
  • Run the script $ sudo ls -1 *.rrd | awk ‘{print “rrdtool dump “$1” > “$1″.xml”}’ | sh -x
  • Tar and Gzip the XML files using the command $ sudo tar -czvf ~/rrd.tgz *.rrd.xml

Reconvert the XML back to RRD File

  • SFTP into the old server and download the ‘rrd.tgz’ created in the step before
  • Move the file to the new directory  /var/lib/cacti/rra/
  • Untar the file tar -xzvf rrd.tgz
  • Run the command
    $ sudo ls -1 *.rrd.xml | sed ‘s/\.xml//’ | awk ‘{print “rrdtool restore “$1”.xml “$1}’ | sh -x
  • Change ownership of all RRD files to www-data by running the command:
    $ sudo chown www-data:www-data *.rrd

Activate the New Cacti

  • Visit the new site and set the mode to ‘Upgrade’
  • Reactivate the Poller
  • Run the command $ sudo vi /etc/cron.d/cacti
  • Enable the poller by removing the character ‘#’ in front of the crontab entry then save & quit

All the best, Enjoy!

Leave a Reply