Darshan Hiranandani : Assistance Needed for Master-Slave Setup in MongoDB Across Two Servers

Hi Team,

We’re currently setting up MongoDB on two Rocky Linux servers for our application and need to configure a master-slave setup. Specifically, I need guidance on:

Synchronizing Database Files: What is the best process for syncing the database files between the two servers to ensure data consistency?
Primary & Secondary Configuration: How should we configure MongoDB to establish one server as the primary and the other as secondary?

If anyone has experience with setting up master-slave configurations or can provide detailed steps on how to achieve this, your support would be greatly appreciated.

Looking forward to your suggestions and guidance.

Thanks in advance!

Best regards,
Darshan Hiranandani

The terms master and slave are not appropriate anymore.

Deploying an even number of nodes is not a recommended setup.

Please read the fine documentation about replication.

There is also a tutorial at