As we develop OpenDJ, we spend a lot of time testing, whether it’s a new feature or a correction to an existing one. We usually write some unit tests to validate the code and then some functional tests to check the feature from a “user” point of view. While the unit tests are typically run with a single server, the functional or integration tests are run with configurations that match our customers deployment. And one of the given fact for any directory service deployment with OpenDJ that I’m aware of, is that the service is made of two or more OpenDJ directory servers with Multi-Master Replication enabled between them.
Setting up Multi-Master Replication with OpenDJ is quite easy and I’m going to demonstrate it here:
Lets assume we want to install 2 OpenDJ servers on the following hosts : ldap1.example.com and ldap2.example.com. For simplicity and because for test we avoid running tests with root privileges, we will configure the server to use port 1389 and 1636 for LDAP and LDAPS respectively.
$ unzip OpenDJ-2.4.2.zip $ cd OpenDJ-2.4.2 $ ./setup -i -n -b "dc=example,dc=com" -d 20 -h ldap1.example.com -p 1389 \ --adminConnectorPort 4444 -D "cn=Directory Manager" -w "secret12" -q -Z 1636 \ --generateSelfSignedCertificate
Do the same on ldap2.example.com, the parameters being the same except for the -h option that should be ldap2.example.com
Now, you have 2 instances of OpenDJ configured and running with 20 sample entries in the suffix “dc=example,dc=com”. Let’s enable replication:
$ bin/dsreplication enable --host1 ldap1.example.com --port1 4444\ --bindDN1 "cn=directory manager" \ --bindPassword1 secret12 --replicationPort1 8989 \ --host2 ldap2.example.com --port2 4444 --bindDN2 "cn=directory manager" \ --bindPassword2 secret12 --replicationPort2 8989 \ --adminUID admin --adminPassword password --baseDN "dc=example,dc=com" -X -n
And now make sure they both have the same data:
$ bin/dsreplication initialize --baseDN "dc=example,dc=com" \ --adminUID admin --adminPassword password \ --hostSource ldap1.example.com --portSource 4444 \ --hostDestination ldap2.example.com --portDestination 4444 -X -n
For my daily tests I’ve put the commands in a script that I can run and will deploy 2 servers, enable replication between them and initialize them, all on a single machine (using different ports for LDAP and LDAPS).
Now if you want to add a 3rd server in the replication topology, install and configure it like the first 2 ones. And join it to the replication topology by repeating the last 2 commands above, replacing ldap2.example.com with the hostname of the 3rd server. Need a 4th one ? Repeat again, keeping ldap1.example.com as the server of reference.