-
Notifications
You must be signed in to change notification settings - Fork 41
Replicaset Config
Eduardo edited this page Sep 12, 2013
·
1 revision
Run the following command in local
mongod --replSet sdrepl --logpath "log/1.log" --dbpath data/rs1 --port 27017
mongod --replSet sdrepl --logpath "log/2.log" --dbpath data/rs2 --port 27018
mongod --replSet sdrepl --logpath "log/3.log" --dbpath data/rs3 --port 27019
Connect to the first local instance
mongo --port 27017
Create the following javascript object in mongo shell:
rsconfig = { _id: "sdrepl", members:[
{ _id : 0, host : "localhost:27017"},
{ _id : 1, host : "localhost:27018"},
{ _id : 2, host : "localhost:27019"} ]
}
Issue the command:
rs.initiate(rsconfig)
Check the status of the replicaset by issuing:
rs.conf()
The configuration is stored locally (after 1 minute) and you can start the replicaset every time with the same command you run at the beginning of this snippet
This info has been taken from http://docs.mongodb.org/manual/tutorial/deploy-replica-set/