Member-only story

Setup MongoDb ReplicaSet with Authentication enabled, using docker-compose.

Prasanth Kanikicherla
6 min readMay 23, 2020

--

The solution is intentionally toned down to a basic POC (proof of concept) style to fit for all kinds of users. Please do not use my solutions as it is in production.

mongoDB

Introduction

A replica set; is nothing but a group of mongodprocesses maintaining the same data set. These instances provides us with redundancy and high availability and there by; a great solution for production deployments. More information on replication in MongoDb → https://docs.mongodb.com/manual/replication/

In MongoDb replica sets; only one node will be elected as PRIMARY and others are considered SECONDARY nodes. Not my favourite option, but PRIMARY is responsible for all writes and replicates the data into the SECONDARY nodes. There are multiple options for you to consider, to base; when to consider a ‘write’ is completed. Most popular option is {w: majority}, meaning majority of the data bearing nodes have received the ‘write’. More information on this → https://docs.mongodb.com/manual/reference/write-concern/#writeconcern.%22majority%22

RS sample architecture.

--

--

Prasanth Kanikicherla
Prasanth Kanikicherla

Responses (3)