How can I use LDIFDELTA to resynchronize two data-stores?

Document ID : KB000053531
Last Modified Date : 14/02/2018
Show Technical Document Details

Description

LDIFDELTA is a DXtool that can be used to determine differences between two replica data-stores. Any differences detected can be written out to file in LDIF format so that it can be applied to the out of sync peer.

Solution

scenario:
There are two multi-write DSA's that have gone out of sync. The aim of this tech-doc is to demonstrate how to get the two peer data-stores synchronized again. The two DSA's are called:

  1. DSA_OLD
  2. DSA_NEW

Scenario Solution:

The first task is to stop both DSA's and dump them to LDIF file. To do this type the following commands on the directory hosts where the DSA's are running:

  1. dxserver stop DSA_OLD
  2. dxserver stop DSA_NEW
  3. For r12.0SP1:
    dxdumpdb -f old.ldif DSA_OLD
    dxdumpdb -f new.ldif DSA_NEW
  4. For r8.1:
    dxdumpdb -S DSA_OLD -p {DSA-prefix} -f old.ldif {DSA_OLD_DatabaseName}
    dxdumpdb -S DSA_NEW -p {DSA-prefix} -f new.ldif {DSA_NEW_DatabaseName}

Please Note: You will need to sort the LDIF files prior to running LDIFDELTA. To do this type the following commands on the directory hosts where the DSA's are running:

  • ldifsort old.ldif old-sort.ldif
  • ldifsort new.ldif new-sort.ldif

When the sort is complete, delete the original LDIF files then rename the sorted LDIF files back to the original LDIF filenames of "old.ldif" and "new.ldif" respectively.

An example of the dumped and sorted LDIF files is below as a reference:

DSA_OLD Sorted dump

dn: o=Democorp,c=auobjectclass: organization     dn: ou=Corporate,o=Democorp,c=auobjectclass: organizationalUnit     dn: cn=Joe Bloggs,ou=Corporate,o=Democorp,c=auobjectclass: inetOrgPersonsn: BloggsuserPassword: passwordgivenName: Joe

DSA_NEW Sorted dump

dn: o=Democorp,c=auobjectclass: organization dn: ou=Corporate,o=Democorp,c=auobjectclass: organizationalUnit dn: cn=Joe Bloggs,ou=Corporate,o=Democorp,c=auobjectclass: inetOrgPersonsn: BloggsuserPassword: passwordgivenName: Joedescription: This is a test dn: cn=Dobby Bloggs,ou=Corporate,o=Democorp,c=auobjectclass: inetOrgPersonsn: BloggsuserPassword: passwordgivenName: Dobbydescription: This is a test

The next task is to run the LDIFDELTA utility to determine the differences between the two data-stores. Before you can do this, you will need to copy both LDIF files to one of the directory servers. I have copied the "old.ldif" to server2 where the DSA_NEW DSA and the "new.ldif" file reside. To do this type the following commands on the server where DSA_NEW is running and where both the files reside:

  1. ldifdelta -x -S DSA_NEW old.ldif new.ldif old-to-new.ldif
    Please Note: The "-S" parameter specifies a running DSA on the local machine. When ldifdelta executes it will source the same schema that that DSA uses in order to parse the attributes and their values listed in each LDIF file.

    The "-x" parameter indicates to ldifdelta that all operational attributes are to be ignored when comparing the two LDIF files.

The resulting file "old-to-new.ldif" contains the all the changes required to synchronize the DSA_OLD data-store, so that it is the same as the DSA_NEW data-store. The contents of the "old-to-new.ldif" file are as follows:


old-to-new.ldif file contents

dn: cn=Joe Bloggs,ou=Corporate,o=Democorp,c=AUchangetype: modifyreplace: descriptiondescription: This is a test- 
dn: cn=Dobby Bloggs,ou=Corporate,o=Democorp,c=AUchangetype: adddescription: This is a testgivenName: DobbyobjectClass: inetOrgPersonsn: BloggsuserPassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=

The last step is to apply these changes to the DSA_OLD DSA to synchronize it with the DSA_NEW DSA. To do this type the following commands on the directory hosts where the DSA's are running:

  1. dxserver start DSA_OLD
  2. dxserver start DSA_NEW


Copy the "old-to-new.ldif" file to the DSA_OLD server ready to execute the following command:

  • dxmodify -r -c -h {DSA_OLD_HOSTNAME} -p {DSA_OLD_ADDRESS_PORT} -f old-to-new.ldif
  • The dxmodify DXtool will apply the changes in the LDIF file to the DSA_OLD DSA. The act of modifying the operations will result in these modifications being multi-written to the DSA_NEW DSA, but don't worry about these multi-write operations; they won't be applied to DSA_NEW as the values are already the same. The multi-write operations will be rejected.

    At the end of this process you will find that the DSA_OLD and DSA_NEW data-stores will be fully synchronized. If you want to confirm that the data-stores are fully synchronized, perform this process again, and you will see the following results which indicate there are no differences between the two data-stores:

    1. ldifdelta -x -S DSA_NEW new.ldif old.ldif

      ldifdelta summary:
                 4 entries in old file
                 4 entries in new file
      Produced:
                 0 add entry records
                 0 delete entry records
                 0 modify entry records



  • ldifdelta -x -S DSA_NEW old.ldif new.ldif

    ldifdelta summary:
               4 entries in old file
               4 entries in new file
    Produced:
               0 add entry records
               0 delete entry records
               0 modify entry records