- Start the first node in the replica set:
mongod --dbpath /data/server1/db --replSet MyReplicaSet
- Open a new Terminal window, connect to the replica set node using the MongoDB shell, and check the replica set's status:
rs.status(){ "info" : "run rs.initiate(...) if not yet done for the set", "ok" : 0, "errmsg" : "no replset config has been received", "code" : 94, "codeName" : "NotYetInitialized"}
- Initialize the replica set:
rs.initiate(){ "info2" : "no configuration specified. Using a default configuration for the set", "me" : "vagrant-ubuntu-trusty-64:27017", "ok" : 1}
- Check the replica set's status again:
rs.status(){ "set" : "MyReplicaSet", "date" : ISODate("2017-08-20T05:28:26.827Z"), "myState" : 1, "term" : NumberLong(1), ...