Sync or copy NMIS data between two NMIS servers

Overview

You problem is that you have some nodes managed on server1 and you would like to move those nodes to be managed by server2 or do some redundant polling from server2 as well.

This page will summarise the steps to sync the data between the two servers and have server2 start managing those nodes.

This document assumes you are using NMIS 8.5.8G or later using the new database scheme where node performance data is stored under /usr/local/nmis8/database/nodes

Process to Synchronise the Data

  1. Get a list of nodes you want to synchronise between the two servers.
  2. Export the nodes from one server to the second server
  3. Copy the performance data and other data between servers

The list just needs to be ready to use in a script.

NMIS includes CLI tools to automate node CRUD (create, read, update, delete)

You will need to copy the RRD files between the servers, this can take some time, and it is highly recommended to use rsync, this will need to be installed on the servers if it is not already installed, this can be done using yum or apt-get depending on your Linux distribution.

Script to Automate the Data Sync

The following script relies on SSH keys being shared between the source and the TARGET server.  This script will be run locally from the source server.

#!/bin/sh
TARGET=SERVER2
NODEDATA=/data/nmis8/nodes
for NODE in node1 node2 node3
do
	# create a directory to store the node export JSON files.
	install -d $NODEDATA

	# export the node records from NMIS
	/usr/local/nmis8/admin/node_admin.pl act=export node=$NODE file=$NODEDATA/$NODE.json


	# get the node data to the target server
	rsync -avz -e ssh $NODEDATA/* $TARGET:$NODEDATA/
	rsync -avz -e ssh /usr/local/nmis8/database/nodes/$NODE $TARGET:/usr/local/nmis8/database/nodes
	scp /usr/local/nmis8/var/$NODE* $TARGET:/usr/local/nmis8/var


	# remotely add the nodes to the TARGET server
	ssh -t $TARGET "/usr/local/nmis8/admin/node_admin.pl act=create node=$NODE file=$NODEDATA/$NODE.json"
done
# Update the group list with any new groups
ssh -t $TARGET "/usr/local/nmis8/admin/grouplist.pl patch=true"