Understand bootstrapping of replication

Hello Everyone, This question is generic to understand how mongodb bootstrap the replication for the first time to get the clear picture.
In Course : M103 > Chapter 2 (Replication) > [Lecture: Setting Up a Replica Set] > [Time - 3:45 ]
Trainer explains to create one user for replication on primary node where we ran rs.initiate(). Later we have to login to PRIMARY NODE using new created user and eventually add remaining nodes.
Now the questions i have are :

  • How the other nodes get added for the first time without passing authentication details? (since all nodes are started with authorization: enabled, meaning we require credentials to authenticate) though following command doesn’t have any authentication details in it.
    rs.add(“m103.mongodb.university:27012”)
  • What exactly is the role of user being created in replication if not being passed explicitly anywhere? Since we’ve already created openssl key file and placed path on all secondary nodes already. How does authentication happens behind the scene between primary and secondary nodes?
  • How is the existing data shipped from primary node to other nodes once there are added for first time (like snapshot of primary node gets copied to other nodes?) and what is the performance impact on the primary node while at the time of adding secondary nodes if data size is in TBs?

Thanks in Advance.

You have to authenticate (e.g. db.auth("username","password")) before you can add a node

There are two types of authentication mechanisms, client and internal. The user you create is for login into the replica set or node (i.e. client/user authentication) and the keyfile handles the internal authentication between nodes within the same replica set. And you must create the first user using the localhost exception afterwhich the localhost exception is void and new users must be created after login in.

Suggest you complete the course to get some answers to parts of this question. For performance related questions, there’s a MongoDB Performance course on the DBA learning path.

2 Likes