Welcome to docs.opsview.com

Differences

This shows you the differences between two versions of the page.

opsview4.6:dbs-on-diff-server [2014/09/09 12:19] (current)
Line 1: Line 1:
 +====== Databases on a different server ======
 +This document details how to set up Opsview to use databases on a different database server, rather than running the database on the Opsview master server.
 +
 +There will be an outage to the Opsview server during the backup and the restore. The majority of the time will be in the restore of the ODW database server - we recommend you perform a test restore to get timings before you follow this process on your production system.
 +
 +===== Setup mysql on database server =====
 +The database server only requires MySQL (and its dependencies) to be installed (the opsview-agent package can optionally be installed if not using SNMP to monitor the database server).
 +
 +Make sure mysql is listening on the appropriate interfaces.
 +
 +Make sure other Opsview specific configuration changes have been made - see [[opsview4.6:prereqs#mysql|MySQL prerequisites]].
 +
 +===== Stop Opsview =====
 +You will need to stop Opsview to get a consistent snapshot of the database:
 +<code>
 +/etc/init.d/opsview stop
 +/etc/init.d/opsview-web stop
 +</code>
 +
 +===== Backup databases =====
 +These instructions assume you will do a full database export, although you may use any technology to backup the mysql databases. Be aware that if the new database server is on a different architecture, you will need to do a database export.
 +<code>
 +mysqldump -u root -p --opt --databases opsview runtime odw dashboard| gzip -c > databases.sql.gz
 +</code>
 +
 +===== Restore databases =====
 +On the new server, restore the databases:
 +<code>
 +gunzip -c databases.sql.gz | mysql -u root -p
 +</code>
 +
 +<note>
 +Check that the character set for the databases are the same as previous, otherwise you may have issues when [[opsview4.6:upgrading#database_schema_changes|upgrading]]:
 +<code>
 +mysql> show create database opsview;
 ++----------+--------------------------------------------------------------------+
 +| Database | Create Database                                                    |
 ++----------+--------------------------------------------------------------------+
 +| opsview  | CREATE DATABASE `opsview` /*!40100 DEFAULT CHARACTER SET latin1 */ |
 ++----------+--------------------------------------------------------------------+
 +</code>
 +</note>
 +
 +===== Setup access controls =====
 +On Opsview master, update ''/usr/local/nagios/etc/opsview.conf'' with the new host information:
 +<code>
 +$dbhost = "hostname";
 +$odw_dbhost = "hostname";
 +$runtime_dbhost = "hostname";
 +$reports_dbhost = "hostname";
 +$dashboard_dbhost = "hostname";
 +</code>
 +
 +**Note**: Runtime (''$runtime_dbhost'') and Opsview (''$dbhost'') need to be on the same host due to cross joins.
 +
 +You will need to setup the access controls on the new database server to allow Opsview master to connect. From Opsview master, run:
 +<code>
 +/usr/local/nagios/bin/db_mysql -t > opsview_access.sql
 +</code>
 +
 +This file contains all the access credential information. Transfer this file to the new database server and run:
 +<code>
 +mysql -u root -p < opsview_access.sql
 +</code>
 +
 +For extra security, you may limit the access to only come from Opsview master.
 +
 +===== Restart Opsview =====
 +On Opsview master, restart Opsview Web and regenerate the configuration for Opsview (this is required to update 3rd party software such as NDOUtils and Nagvis with the new connection information):
 +<code>
 +/usr/local/nagios/bin/rc.opsview gen_config
 +/etc/init.d/opsview-web start
 +</code>
 +
 +===== Cleanup =====
 +Drop the old databases on the Opsview master server
 +<code>
 +mysql -u root -p
 +drop database opsview;
 +drop database odw;
 +drop database runtime;
 +drop database reports;
 +drop database dashboard;
 +</code>
Navigation
Print/export
Toolbox