solidDB Help : Replication : Advanced Replication : Using Advanced Replication with applications : Setting up databases for synchronization : Registering replicas with the master database
  
Registering replicas with the master database
Before you begin registering replica databases, complete the following tasks:
Commit or roll back any active transaction, and then turn off AUTOCOMMIT so that you can compose multi-statement messages.
Define a master user name and password for registering replicas to the master database.
Define your replica databases, see Defining master and replica databases.
In each replica database, perform the following steps:
1 If a local database will synchronize data with multiple master databases (that is, the local database will contain more than one logical replica database), create a catalog for each logical replica database. For example:
CREATE CATALOG CAT_FOR_REP1; COMMIT WORK;
2 Set the catalog to be the current catalog and assign the catalog a server name that is unique across the replica databases of the master database. For example:
SET CATALOG CAT_FOR_REP1; COMMIT WORK;
SET SYNC NODE "REPLICA1"; COMMIT WORK;
Note If you have many replicas, then it is recommended that you name replicas with logical names that are derived, for example, from the server logical name or location.
Also, note that a catalog in the master and its corresponding server in the master can have different names.
3 Set the master user for replica database registration. For example:
SET SYNC USER REG_USER IDENTIFIED BY SECRET;
4 Register the replica database with the master database by sending a registration message. For example:
MESSAGE CFG1 BEGIN TO "MASTER";
MESSAGE CFG1 APPEND REGISTER REPLICA;
MESSAGE CFG1 END;
COMMIT WORK;
MESSAGE CFG1 FORWARD TO 'tcp 1315' TIMEOUT FOREVER;
COMMIT WORK;
Note When using the REGISTER REPLICA task and registering a replica with a catalog other than the master server default catalog, you must provide the applicable master server name of the catalog in the MESSAGE BEGIN statement. solidDB can then resolve the correct catalog at the master database for the replica. For the syntax, see MESSAGE BEGIN.
The MESSAGE FORWARD statement sends the message to the master database after the message is made persistent with the MESSAGE END statement. Note that the network listen name of the recipient of the message is specified in the MESSAGE FORWARD statement. This is necessary only when the first message from a new replica to the master database is sent. If a TIMEOUT is not defined, the replica database does not automatically get a reply. The reply must be retrieved by using a separate MESSAGE GET REPLY call.
5 Subscribe master user name information from the master database by using the MESSAGE APPEND SYNC_CONFIG statement in a separate message. In this example the SQL wildcard % is used to request that all user names are sent from the master database:
MESSAGE CFG2 BEGIN;
MESSAGE CFG2 APPEND SYNC_CONFIG('%');
MESSAGE CFG2 END;
COMMIT WORK;
MESSAGE CFG2 FORWARD TIMEOUT FOREVER;
COMMIT WORK;
6 When you have downloaded the master user name information successfully, reset the sync user to NONE so the registration user is no longer active in the replica database connection. For example:
SET SYNC USER NONE;
The registration user has no rights other than registration. If the registration user is still active, subsequent statements will typically get the following error message:
User definition not allowed for this operation
Go up to
Setting up databases for synchronization