1

I have two data bases for one system. One is OpenLDAP and another one is MongoDB. To be specific this OpenLDAP is used by Atlassian Crowd that is used by us. I need to synchronize users in these two databases. That is,

  1. If I create a user it will be defaultly created in the OpenLDAP and it has to be created in the MongoDB as well.
  2. In past there were issues in handling this and there may be users who are in OpenLDAP but not in MongoDB. I need to find these users also.
  3. If I delete or update a user from one I need the delete or operation to happen in both DBs.

I am going to have a cache copy of LDAP using Redis. What is the best way to synchronize data between these two databases to match the above expectations?

If it helps I am using Java in backend.

Community
  • 1
  • 1

1 Answers1

1

2 possible ways:

  1. (Preferred) Design your code in a way you can "plug" database operators to handle the different databases, so you access them from a facade code that lets you access it without worriying the underlaying databases. , so creating an user, for example, would be something like this:

createUser() -> foreach dbhandle do dbhandle->createUser() forend

The same applies to delete or update any data. This approache should also solve the problem 2.

  1. You can just update one database and have a script that runs in background updating the databases. This approach will let you work just with 1 database, letting the script handle the rest of the databases, but it is way more expensive and less reliable (as you might access 1 database that has not been updated from the master database yet)
Nadir
  • 1,799
  • 12
  • 20
  • Thank you very much for the answer. Scripting was the first thing that also occured to me at once. The facade pattern is more attractive and reliable as a longterm solution. Thanks again. – Hareendra Chamara Philips Mar 15 '16 at 01:53
  • "as you might access 1 database that has not been updated from the master database yet" this problem exists in both solutions. – GManNickG Jul 30 '17 at 05:21