9.3.2. Initializing Replicas

You can initialize replication between servers by performing initialization over the network after you have enabled replication, or by importing the same LDIF data on all servers and then enabling replication. You can also add a new server by restoring a backup from an existing replica onto the new server and then enabling replication with an existing replica.

Procedure 9.1. To Initialize Replication Over the Network

Initialization over the network while the server is online works well when you have no initial data, or when your network bandwidth is large compared to the initial amount of data to replicate.

  1. Enable replication on all servers.

    See Section 9.3.1, “Enabling Replication” for instructions.

  2. Start replication with the dsreplication initialize-all command.

    $ dsreplication
     initialize-all
     --adminUID admin
     --adminPassword password
     --baseDN dc=example,dc=com
     --hostname opendj.example.com
     --port 4444
     --trustAll
     --no-prompt
    
    Initializing base DN dc=example,dc=com with the contents from
     opendj.example.com:4444: 160 entries processed (100 % complete).
    Base DN initialized successfully.
    
    See
    /var/.../opends-replication-5020375834904394170.log
    for a detailed log of this operation.

Procedure 9.2. To Initialize All Servers From the Same LDIF

This procedure can be useful when you are starting with a large amount of directory data that is available locally to all directory servers.

  1. Import the same LDIF on all servers as described in the procedure, To Import LDIF Data.

    Do not yet accept updates to the directory data. Section 9.3.6, “Read-Only Replicas” shows how to prevent replicas from accepting updates from clients.

  2. Enable replication for all servers.

    See Section 9.3.1, “Enabling Replication” for instructions.

  3. Allow updates to the directory data by setting writability-mode:enabled using a command like the one you found in Section 9.3.6, “Read-Only Replicas”.

Procedure 9.3. To Create a New Replica From Existing Backup

You can create a new replica from a backup of a server in the existing topology.

  1. Install a new server to use as the new replica.

  2. Backup the database on an existing server as described in Backing Up Directory Data.

    At this point, other servers in the topology can continue to process updates.

  3. Enable replication on the new replica.

    $ dsreplication
     enable
     --adminUID admin
     --adminPassword password
     --baseDN dc=example,dc=com
     --host1 opendj.example.com
     --port1 4444
     --bindDN1 "cn=Directory Manager"
     --bindPassword1 password
     --replicationPort1 8989
     --host2 opendj3.example.com
     --port2 4444
     --bindDN2 "cn=Directory Manager"
     --bindPassword2 password
     --replicationPort2 8989
     --trustAll
     --no-prompt
    
    Establishing connections ..... Done.
    Checking registration information ..... Done.
    Updating remote references on server opendj.example.com:4444 ..... Done.
    Configuring Replication port on server opendj3.example.com:4444 ..... Done.
    Updating replication configuration for baseDN dc=example,dc=com on server
     opendj.example.com:4444 ..... Done.
    Updating replication configuration for baseDN dc=example,dc=com on server
     opendj3.example.com:4444 ..... Done.
    Updating replication configuration for baseDN dc=example,dc=com on server
     opendj2.example.com:4444 ..... Done.
    Updating remote references on server opendj2.example.com:4444 ..... Done.
    Updating registration configuration on server
     opendj.example.com:4444 ..... Done.
    Updating registration configuration on server
     opendj3.example.com:4444 ..... Done.
    Updating registration configuration on server
     opendj2.example.com:4444 ..... Done.
    Updating replication configuration for baseDN cn=schema on server
     opendj.example.com:4444 ..... Done.
    Updating replication configuration for baseDN cn=schema on server
     opendj3.example.com:4444 ..... Done.
    Updating replication configuration for baseDN cn=schema on server
     opendj2.example.com:4444 ..... Done.
    Initializing registration information on server opendj3.example.com:4444 with
     the contents of server opendj.example.com:4444 ..... Done.
    
    Replication has been successfully enabled.  Note that for replication to
     work you must initialize the contents of the base DN's that are being
     replicated (use dsreplication initialize to do so).
    
    See
    /var/.../opends-replication-1672058070147419978.log
    for a detailed log of this operation.

    Contrary to the message from the command, you do not need to use the dsreplication initialize command at this point.

  4. On the new server, restore the database from the backup archive as described in the procedure, To Restore a Replica.

    As long as you restore the database on the new replica before the replication purge delay runs out, updates processed by other servers after you created the backup are replicated to the new server after you restore the data.