Tutorial on how to create a development mongodb cluster. Based on: https://docs.mongodb.com/manual/tutorial/deploy-replica-set-for-testing/
mongod --config d:\data\mongodb\mongod-cluster1.cfg
mongod --config d:\data\mongodb\mongod-cluster2.cfg
- connect to mongo1, inside the shell type:
rsconf = {
_id: "rs-test",
members: [
{
_id: 0,
host: "localhost:28001"
},
{
_id: 1,
host: "localhost:28002"
}
]
}
rs.initiate(rsconf)
mongodb://localhost:28001,localhost:28002?replicaset=rs-test
https://docs.mongodb.com/manual/tutorial/configure-secondary-only-replica-set-member/
cfg = rs.conf()
cfg.members[1].priority = 0
rs.reconfig(cfg)
Now you can stop the primary to simulate a failover and a secondary only access...