Introduction:

A replica set in MongoDB is a group of MongoDB processes that maintain the same data set with a designated primary node and one or more secondary nodes. Replica sets provide redundancy and high availability, forming the foundation for robust production deployments

Prerequisites:

  1. SSH Login details
  2. Database user credentials

Implementation

Step 1: Open the MongoDB Compass

Step 2: Click on Advanced Connection Options > General > Host.
Provide the IP of the replication set servers and the port number of the MongoDB service in the format
IP: port

Step 3: Select the Authentication option and choose the Username/Password method.
Provide the Database access credentials in the respective field

Step 4: Click on Advanced Connection Options and select the Proxy/SSH option

Step 5: Choose the “SSH with Password” method if the server is accessible with a password, else select “SSH with identity file” if the server is accessible with a key-pair and provide the server access details in the respective fields

Step 6: [Optional] Navigate to Advanced Connection Options > Advanced, provide the replica set name, Default Authentication Database name

Step 7: Finally click on connect to establish the connection and note down the connection string from the Mongo compass URI as shown in the snapshot

Leave a Reply