In the world of replication between nodes across data centers, there are chances of having some node failures due to power outages, disk issues or for several other reasons. These issue might result in the data going out of sync between the nodes.
So how do we fix it ???
There are several approaches that we usually take depending on the amount of data lost, data quality etc and several other factors.. Now in this post we are going to sync the data using the Manual approach assuming there is only minor loss of data which can be fixed manually...
Below are the high level steps which we are going to take in order to fix this data inconsistency.
So how do we fix it ???
There are several approaches that we usually take depending on the amount of data lost, data quality etc and several other factors.. Now in this post we are going to sync the data using the Manual approach assuming there is only minor loss of data which can be fixed manually...
Below are the high level steps which we are going to take in order to fix this data inconsistency.
- Find the OUD server which is stable. In this post, referring as oud1 in the post.
- Find the OUD server which is out of sync with stable server. refering as oud2.
- Export entries from oud1 and oud2 and compare
- Export missing entries and data from oud1
- Import the missing entries and data into oud2
- OUD 11.1.2.3
- RHEL 6
- Export entries from oud1 using ldapsearch
ldapsearch -h <oud1_hostName> -p <Port> -D "cn=Directory Manager" -j <Password_File> -b "dc=base,dc=com" "objectclass=*" dn | sort > oud1_entries.txt
Sample:-(oud1_entries.txt):-
dc=com
dc=base,dc=com
dn: cn=group1,ou=users,dc=base,dc=com
dn: cn=group2,ou=users,dc=base,dc=com
dn:.....
dn:.....
dn: cn=Test User1,ou=users,dc=base,dc=com
dn: cn=Test User2,ou=users,dc=base,dc=com
dn:.....
dn:.....
P.S: When you open a file it might look empty but please scroll down and verify entries are available.
- Export entries from oud2 using ldapsearch
Sample:-(oud2_entries.txt):-
dc=com
dc=base,dc=com
dn: cn=group1,ou=users,dc=base,dc=com
dn:.....
dn:.....
dn: cn=Test User1,ou=users,dc=base,dc=com
dn:.....
dn:.....
P.S: When you open a file it might look empty but please scroll down and verify entries are available.
- Compare two files from oud1 and oud2
diff oud1_entries.txt oud2_entries.txt > missing_entries.txt
Sample:-(missing_entries.txt):-
dn: cn=group2,ou=users,dc=base,dc=com
dn:.....
dn:.....
dn: cn=Test User2,ou=users,dc=base,dc=com
dn:.....
dn:.....
Use grep or other tools to remove first two lines (dn:) in missing_entries.txt and sample file should looks like below.
Sample:-(missing_entries.txt):-
cn=group2,ou=users,dc=base,dc=com
cn=....
cn=Test User2,ou=users,dc=base,dc=com
cn=....
- Export ldif data (with attributes) from oud1 for the missing entires.
cat missing_entries.txt | while read LINE
do
echo "Processing $LINE" <oud_instance>/bin/ldapsearch -h <oud1_hostname> -p <port> -D "cn=Directory Manager" -j <password_file> -b "$LINE" -s base "objectclass=*" dn "*" + >> export_missing_dns.ldif
done
Run export_missing_dn.sh, it should create a file with name, export_missing_dns.ldif. Open the file and make sure there format of ldif is correct before importing.
- Import the ldif into oud2
ldapmodify -J 1.3.6.1.4.1.26027.1.5.2 -h <oud2_hostname> -p <port> -D "cn=Directory Manager" -j <pwd_file> -f export_missing_dns.ldif
That's all. Now your instances are in sync..
Thank you for visiting.