Advanced Replication Guide : 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, be sure to set AUTOCOMMIT off so that you can compose multi-statement MESSAGEs. Make sure that you commit or roll back any active transaction. Also, be sure that you have defined a master username and password for registering replicas to the master database, and that you know the name(s) of the catalog(s) in your environment. Also be sure you have defined your replica databases; for details 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 (i.e. it will contain more than one replica), then create a catalog for each replica. For example:
CREATE CATALOG CAT_FOR_REP1; COMMIT WORK;
2 Give this replica catalog a node name that is unique across the replicas of the
master database of this replica. Before you set the node name of the catalog,
you must already have set that catalog to be the current catalog. For example:
SET CATALOG CAT_FOR_REP1; COMMIT WORK;
SET SYNC NODE "REPLICA1"; COMMIT WORK;
If you have many replicas, then we recommend that you name replicas with logical names that are derived, for example, from the server's logical name or location.
Also, note that a catalog in the master and its corresponding node in the master can have different names.
3 Set the master user for replica registration. For example:
SET SYNC USER REG_USER IDENTIFIED BY SECRET;
4 Register the replica to master Master1 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;
When using the REGISTER REPLICA command and registering a replica with a catalog other than the master server's default catalog, you must provide the applicable master node name of the catalog in the MESSAGE BEGIN command. solidDB® can then resolve the correct catalog at the master database for the replica. Following is the syntax:
MESSAGE message_name BEGIN TO master_node_name
The MESSAGE FORWARD command sends the message to the master database after the message is made persistent with the MESSAGE END command. Note that the network listen name of the recipient of the message is specified in the MESSAGE FORWARD command. 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 does not fetch the reply. It must be retrieved with a separate MESSAGE GET REPLY call.
5 Subscribe master username information from the master database using the MESSAGE APPEND SYNC_CONFIG command 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 subscribed the master username 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 commands will typically get the following error message:
User definition not allowed for this operation
See also
Setting up databases for synchronization