-1

I have 2 servers where the MongoDB database is installed. Both servers have enabled database access control by creating users. Now, I need to make replication for these servers. One for primary and the other for secondary.

I followed https://docs.mongodb.com/manual/tutorial/deploy-replica-set/

But above reference URL steps have been for when access control is disabled.

Need MongoDB replication steps when access control is already enabled.

Prashant G Patil
  • 927
  • 1
  • 8
  • 22

1 Answers1

1

Actually nothing changes. You only have to provide username/password when you connect to the database, the rest is identical.

However, you may follow Deploy Replica Set With Keyfile Authentication. Just go from item 1 up to 5, then it should be done.

Anyway, for me it is not clear what you try to do. You write you have 2 existing MongoDB servers. Are they different?

Do you like to put these two different databases into one new Replica Set? In a Replica Set the SECONDARY is an exact copy of the PRIMARY, so you cannot push data from 2 different sources into PRIMARY and SECONDARY.

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • When auth is enabled, the nodes must authenticate to each other if I am remembering correctly (e.g. via key file). – D. SM Feb 03 '21 at 19:05
  • @WernfriedDomscheit I have 2 mongodb servers. Both are different. I have 1 database, and need to replicate dat between these 2 servers. – Prashant G Patil Feb 08 '21 at 09:13