InterviewSolution
| 1. |
The oplog.rs collection in MongoDB stores the log of operations (in a replica set). This means that this collection should not grow infinitely and there should be a rolling mechanism where in as new documents(logs) are inserted, the older ones are automatically removed? How does MongoDB achieve this? |
|
Answer» The first requirement eliminates any five-node replica set where one node is an arbiter, as arbiters do not have a COPY of the DATA. The second requirements eliminate setting Priority of 0 for dc1-01, dc1-02 or dc2-01, dc2-02. They can be assigned any positive integer, or the default VALUE of 1 to be electable as Primary. As per the THIRD requirement, dc3-01 can never be primary so its priority has to be set 0. Finally, as per the fourth dc3-01 configuration cannot be listed as hidden, as this will prevent READING from this replica member. So below will be the config file meeting all the requirements. { "_id" : "rs0", "version" : 1, "members" : [ { "_id" : "dc1-01", "host" : "mongodb0.example.net:27017" }, { "_id" : "dc1-02", "host" : "mongodb1.example.net:27017" }, { "_id" : "dc2-01", "host" : "mongodb2.example.net:27017"}, { "_id" : "dc2-02", "host" : "mongodb3.example.net:27017"}, { "_id" : "dc3-01", "host" : "mongodb4.example.net:27017","priority" : 0 } ] } |
|