How to migrate to another database

From NetXMS Wiki
Jump to: navigation, search

NetXMS database manager (nxdbmgr) provides database migration option. To perform database migration follow these steps:

1. Create a copy of existing netxmsd.conf (netxmsd_old.conf in this example).

2. Create new database.

3. Adjust netxmsd.conf - change DBDriver, DBName, etc. to match new database.

4. Initialize new database:

 nxdbmgr init /opt/netxms/share/netxms/sql/dbinit_pgsql.sql

Please note, that there are different files for different database types, in this example - dbinit_pgsql.sql is for PostgreSQL.

5. (optional) Run "nxdbmgr check" to verify connectivity to new database.

6. Stop NetXMS server.

7. Run

 nxdbmgr migrate netxmsd_old.conf

This will load data from old database (using credentials in netxmsd_old.conf) and migrate it into new one (as configured in netxmsd.conf).

8. Start NetXMS server - it should run on new database.

Migration Options

There are few options for nxdbmgr migrate command that can alter migration process:

Option Description
-D Migrate only collected data. If this option given, only content of idata_* and tdata_* tables will be migrated. This option could be useful if migration done in two steps - configuration without data (option -s) on first step and data on second step.
-s Skip collected data. If this option given, collected data will not be migrated (but existing data collection tables will be deleted from target database and empty data collection tables will be created as needed). Collected data can be migrated separately later using -D option.
-S Skip collected data and left data collection tables in target database intact. This option can be useful when there are need to redo configuration migration after full migration but collected data already migrated and there are no need to migrate it again.
-T count Number of records within one transaction. During migration nxdbmgr groups INSERTs into transactions to increase performance. Default is to run up to 4096 INSERTs before issuing COMMIT. This option can be used to change commit threshold.