Tuesday, July 28, 2015

Migrating Cacti from One Server to another (Ubuntu 12.04 to Ubuntu 14.04)

You may need to migrate cacti from one server to another due to one reason or another, i did this lab migration from ubuntu server 12.04 to 14.04, i use this HOW TO (http://lifein0and1.com/2008/05/15/migrating-cacti-from-one-server-to-another/), doing some few modification according to need. Below are steps

1. Install Cacti on the New Server
2. Turn Off Cacti at the Old Server
3. Migrate the Database
4. Copy the RRD Files as XML
5.Reconvert the XML back to RRD File
6. Activate the New Cacti


1.  Install Cacti on the New Server
a. 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.

b. 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


2. 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.


3. Migrate the Database
a. 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

b. SCP on the old data and grap the data and move it to new server.

c. On the server run the following
$ sudo mysql -u root -p cacti < ~/cacti.sql


4. Copy the RRD Files as XML
Do the following on the old server

a. Go to the directory
$ cd /var/lib/cacti/rra/

c. Run the script
$ sudo ls -1 *.rrd | awk '{print "rrdtool dump "$1" > "$1".xml"}' | sh -x

d. Tar and Gzip the XML files using the command
$ sudo tar -czvf ~/rrd.tgz *.rrd.xml


5.Reconvert the XML back to RRD File

a. SFTP into the old server and download the ‘rrd.tgz’ created in the step before

b. Move the file to the new directory
/var/lib/cacti/rra/

c. Untar the file
tar -xzvf rrd.tgz

d. Run the command
$ sudo ls -1 *.rrd.xml | sed 's/\.xml//' | awk '{print "rrdtool restore "$1".xml "$1}' | sh -x

e. Change ownership of all RRD files to www-data by running the command:
$ sudo chown www-data:www-data *.rrd


6. Activate the New Cacti

a. Visit the new site and set the mode to ‘Upgrade’
b. 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


Enjoy!