Sun ONE Directory Server Resource Kit 5.2 Tools Reference |
Chapter 22
The LDIF Merge ToolThe mmldif tool combines multiple LDIF (LDAP Data Interchange Format) files into a single directory hierarchy. The result is the union of all input files. This chapter provides instructions on how to use the mmldif tool. It contains the following sections:
OverviewThe mmldif tool merges multiple LDIF files into a single directory hierarchy. The result is one output file, containing any entry whose DN appears in one or more of the input files. In a typical usage scenario, mmldif can be used to create an authoritative database for servers cooperating in a multi-master replication agreement. If for some reason all masters are no longer able to synchronize, the mmldif tool can be used to generate the master database manually.
Command UsageThe mmldif tool unites all input files, based on the DNs they contain: entries that exist in one or more input files are added to the hierarchy of the final output. When the same DN appears in multiple files, the tool will verify that all attribute values are identical. If the attribute values differ, the conflict is resolved by choosing the entry with the most recent time stamp. The time stamp is defined by one of the following attributes: modifyTimestamp, createTimestamp, or deleteTimestamp. mmldif also recognizes deleted entries by the objectclass: nsTombstone attribute and handles them accordingly. For LDIF files to contain these special attributes, you must use the db2ldif -r option when extracting the entries from your directories. For more information, see “db2ldif (Export Database Contents to LDIF)” in Chapter 2 of the Sun ONE Directory Server Reference Manual.
Syntax
The syntax of the mmldif tool on the command-line takes the following form:
mmldif [-c] [-o output.ldif] input1.ldif input2.ldif ...
Where:
Options
The mmldif options and parameters are described in Table 22-1. The mmldif -h command will display a usage help text that briefly describes all options.
Command-Line ExamplesThe examples in this section demonstrate different types of output from the mmldif tool. They use as input two LDIF files: one.ldif and two.ldif. Both files are reproduced in Table 22-2 with the differences between the two formatted in bold.
Merge Statistics
The mmldif tool always displays merge statistics to the standard output. The -o outputFile parameter may be omitted when you are interested only in the number of differences between input files as in this command:
$ mmldif one.ldif two.ldif
The output reproduced inCode Example 22-1 confirms the differences between the two input files.
Code Example 22-1 Merge Statistics Output
start time Wed Jul 11 12:34:56 2001
entry counts: unchanged=1 changed=2 new=1 total=4
end time Wed Jul 11 12:34:56 2001
differencing took <= 1 second
By inspecting the LDIF files in Table 22-2, we can see the following (also detailed in Code Example 22-1):
Merge Output File
Running the command detailed in Merge Statistics with the -o outputFile parameter will allow us to see the result of the merge.
$ mmldif -o merge.ldif one.ldif two.ldif
The output reproduced inCode Example 22-2 details the result of the union between the two input files.
- The first entry, sn=Jensen, remains unchanged.
- Only the telephone number is modified in the second entry, sn=Minsky.
- The third entry, sn=Morris, is counted as new because it was not present in one.ldif.
- The deleted entry, sn=Rose, is not included, although it is tallied as a change in the entry counts.
Produce Change Files
To see how each input relates to the merge result, mmldif can generate change files. Change files contain LDIF update statements that represent the difference between the corresponding input and the merged result. Applying the change file to the directory of the corresponding input will make the directory contents equivalent to the contents of the merged result. To do this, the change file can be used as input to the ldapmodify command. (See Chapter 4, "The ldapmodify Tool" for more information.) LDIF update statements showing the difference between each input file and merge result can be generated by running the following command:
$ mmldif -o merge.ldif -c one.ldif two.ldif
The output reproduced inCode Example 22-3 details the changes between the two input files.
Code Example 22-3 Output of Changes
start time Wed Jul 11 12:34:56 2001
entry counts: unchanged=1 changed=2 new=1 total=4
end time Wed Jul 11 12:34:56 2001
differencing took <= 1 second
Code Example 22-4 shows how to bring the contents of one.ldif up to date with the result of the merge. The changes detailed are:
In addition to one.ldif.delta, the file two.ldif.delta is also generated but it is empty (zero length) because two.ldif contains all of the most recent modifications between the two input files.
Code Example 22-4 one.ldif.delta
$ cat one.ldif.delta
dn: sn=Minsky,dc=siroe,dc=com
changetype: modify
delete: createTimestamp
-
replace: telephoneNumber
telephoneNumber: 555-5559
-
dn: sn=Rose,dc=siroe,dc=com
changetype: delete
dn: sn=Morris,dc=siroe,dc=com
changetype: add
cn: Ted Morris
createTimestamp: 200
objectclass: person
objectclass: top
sn: Morris
telephoneNumber: 555-5558
Supposing that one.ldif represents the contents the directory on host one, port 389, the following command will update those contents so that they are equivalent to merge.ldif:
$ ldapmodify -h one -D "bindDN" -w bindPassword \
-f one.ldif.deltaThis command uses the credentials of the bindDN to access the directory and assumes that user has permission to modify entries. See Chapter 4, "The ldapmodify Tool," for more information.