...
Copy or move files to new directory (on a production system, you should stop NMIS from polling by editing the crontab and appending a "#" to the lines for NMIS polling). Pick one of these options, C is recommended.
Copy files to a new directory
Code Block cp -rp /usr/local/nmis8/database /opt/nmis8
Move files to a new directory
Code Block mv /usr/local/nmis8/database /opt/nmis8
If you have a large database and copying or moving files takes a significant amount of time then we will prefer to use rsync. In this case do not stop NMIS from polling at this time, it will be done in a later step. We will do a "hot" copy now and follow it with a "cold" copy.
Code Block #do a hot copy where nmis is still updating sudo rsync -av --inplace /usr/local/nmis8 /opt/
Check permissions on the copied files. If you missed the -p option you may need to run these commands: (Not needed if you used rsync as all permissions will be copied with the files)
Code Block The above commands should preserve owners and permissions, but double check anyway
Code Block ls -l /opt # nmis8 should be owned by nmis, group nmis ls -l /opt/nmis8/ # all should be owned by nmis, group nmis #if the have incorrect permissions run these commands: chown -Rv nmis:nmis /opt/nmis8 chmod -Rv g+w /opt/nmis8
If you have a large database, now is the time to stop NMIS from polling. As mentioned previously, the safest way to do this is by commenting out the lines that run NMIS polling, be sure to do all of them, just to be safe. Another option (and not necessarily recommended) is to stop the cron daemon with:
service crond stop #Do Not forget to restart it later
. Now we will run the rsync copy one more time to get any updates:Stop polling. Wait for nmis to stop updating.
Code Block crontab -e #comment out all nmis.pl lines # continue running the following command until you no longer see nmis running ps aux | grep nmis.pl # make sure you don't see a line like this: # /usr/bin/perl ./nmis.pl
Now that NMIS is no longer polling we can run a "cold" copy to get the last updates that NMIS made while we were "hot" copying.
Code Block sudo rsync -av --inplace /usr/local/nmis8 /opt/
Edit config files so that NMIS will write data to our new location, edit /usr/local/nmis8/conf/Config.nmis
Code Block # this line line 13: '<nmis_data>' => '<nmis_base>', # should change to line 13: '<nmis_data>' => '/opt/nmis8',
To test, move the existing data directores to new folders.
Code Block mv /usr/local/nmis8/database /usr/local/nmis8/database_old
Run a manual update, you should see no errors.
Code Block /usr/local/nmis8/bin/nmis.pl type=update debug=1 # you should not see any errors like this: # createRRD, ERROR (localhost) unable to create /opt/nmis8/database/health/server/localhost-reach.rrd: creating '/opt/nmis8/database/health/server/localhost-reach.rrd': No such file or directory
- Open or reload the NMIS web page and everything should still look the same.
After confirming there are no errors you can now safely delete the old database directory.
Code Block theme Emacs rm -rf /usr/local/nmis8/database_old
- Now re-enable your cron jobs. If you commented lines out, remove the comments. If you stopped crond, start it again:
service crond start
...