10. Replication
Activity 10.01: Testing a Disaster Recovery Procedure for a MongoDB Database
Solution:
Perform the following steps to complete the activity:
- Create the directories as follows:
C:\sale\sale-prod
,C:\sale\sale-dr
,C:\sale\sale-ab
, andC:\sale\log
.Note
For Linux and macOS, the directory names would be like
/data/sales/sale-prod
,/data/sales/sale-dr…
- Start the cluster nodes as follows:
start mongod --port 27001 --bind_ip_all --replSet sale-cluster --dbpath C:\sale\sale-prod --logpath C:\sale\log\sale-prod.log --logappend --oplogSize 50 start mongod --port 27002 --bind_ip_all --replSet sale-cluster --dbpath C:\sale\sale-dr --logpath C:\sale\log\sale-dr.log --logappend --oplogSize 50 start mongod --port 27003 --bind_ip_all --replSet sale-cluster --dbpath C:\sale\sale-ab --logpath C:\sale\log\sale-ab.log --logappend --oplogSize 50
- Connect with mongo shell:
mongo mongodb://localhost:27001/?replicaSet=sale-cluster
- Create and activate the cluster...