Ярлыки

Memories ( 25 ) Unix ( 14 ) FreeBSD ( 8 ) www ( 4 ) Scripts ( 3 ) GEOM ( 2 ) PART ( 2 ) smtp ( 2 ) Cacti ( 1 ) Jabber ( 1 ) KVM ( 1 ) Kohana ( 1 ) RAID ( 1 ) Sip ( 1 ) Ubuntu ( 1 ) Zyxel ( 1 ) nginx ( 1 ) php-fpm ( 1 ) portwfd ( 1 ) rewrite ( 1 ) security ( 1 )

Поиск по этому блогу

среда, 22 сентября 2010 г.

Cacti: migrating settings and RRD history

I was having a hard time figuring out how to migrate Cacti from one box to another, or more specifically I could do the migration by the book but nothing was working, so after much head scratching and googling I’m going to collate my notes here. This assumes Debian to Debian, and we’ll call the boxes oldcacti and newcacti.

Step 1 is to setup Cacti, RRDTool, SNMP etc on newcacti. This is outside the scope of this post.

Step 2 is to migrate your database, so dump it, scp it to newcacti:

oldcacti:/etc/cacti# mysqldump -u cacti -p > cacti.sql

Enter password:

oldcacti:/etc/cacti# scp cacti.sql root@newcacti:/etc/cacti/

root@newcacti's password:

cacti.sql 100% 463KB 462.5KB/s 00:00

oldcacti:/etc/cacti#

and restore it:

newcacti:/etc/cacti# mysql -u cacti -p < cacti.sql

Enter password:

newcacti:/etc/cacti#

Step 3 All of your settings should now be across, but you'll likely want to keep your RRD history too. Unfortunately you cannot just scp the files across as you'll likely get complaints about the RRD files being created on a different arch:

COMMENT:From 2008/06/18 14:05:32 To 2008/06/19 14:05:32\c

ERROR: Garbage ':05:32 To 2008/06/19 14:05:32\c' after command:

COMMENT:From 2008/06/18 14:05:32 To 2008/06/19 14:05:32\c

ERROR: This RRD was created on other architecture

ERROR: This RRD was created on other architecture

ERROR: This RRD was created on other architecture

ERROR: This RRD was created on other architecture

ERROR: Garbage ':05:41 To 2008/06/19 14:05:41\c' after command:

COMMENT:From 2008/06/18 14:05:41 To 2008/06/19 14:05:41\c

ERROR: Garbage ':05:41 To 2008/06/19 14:05:41\c' after command:

So we need to export the files to xml and then reimport them:

rrdtool dump filename.rrd > filename.xml

rrdtool restore filename.xml > filename.rrd

But if you’ve got dozens, hundreds or even thousands of RRD files, doing them one by one is going to get tired, very quickly. So here we go:

oldcacti:/usr/share/cacti/site/rra/# ls -1 *.rrd | awk '{print "rrdtool dump "$1" > "$1".xml"}' | sh -x

scp *.xml root@newcacti:/usr/share/cacti/site/rra/

followed by:

newcacti:/usr/share/cacti/site/rra/# rm *.rrd

newcacti:/usr/share/cacti/site/rra/# ls -1 *.rrd.xml | sed 's/\.xml//' | awk '{print "rrdtool restore "$1".xml "$1}' | sh -x

newcacti:/usr/share/cacti/site/rra/# rm *.xml

newcacti:/usr/share/cacti/site/rra/# chown www-data:www-data *

That should be it, the final chown ensures that Apache can actually open the files and present them. Assuming Cacti et al is configured right on newcacti, you should be seeing some pretty graphs :)


(С) http://www.rawiriblundell.com/

Комментариев нет :

Отправить комментарий