For the purposes of this illustration, we will use an extremely simple example configuration, only specifying the name of the replica set and the host entries for each of the members:
doc = {
_id : "learn_mongodb",
members: [
{ _id: 1, host: "member1.biglittle.local" },
{ _id: 2, host: "member2.biglittle.local" },
{ _id: 3, host: "member3.biglittle.local" },
]
}
rs.initiate(doc);
We then connect to one of the member servers, run the mongo shell, and execute the command, as shown here:
After a brief period of time, database synchronization is complete. As we are operating from an empty database directory, only the default databases appear at first. In a later section, we will restore the sample data and observe the replication process.
Only run rs.initiate() or the replSetInitiate database command once!
Now that the replica set has been initiated, let's have a...