Database Reference
In-Depth Information
"uptime" : 264,
"optime" : {
"t" : 1370258919,
"i" : 1
},
"optimeDate" : ISODate("2013-06-03T11:28:39Z"),
"self" : true
}
],
"ok" : 1
}
The output here indicates that all is OK: you've successfully configured, set up, and initialized a new replica set.
Remember that you should use the name of your own machine in place of [hostname] because neither “localhost”
nor “127.0.0.1” will work.
Adding a Server to a Replica Set
Now that you have started your new replica set, you need to start adding members to it. Let's start by adding your first
secondary. You can do this by simply adding the rs.add() command and providing the hostname and port of this
instance. To add that, connect to your primary and run the following:
$ mongo [hostname]:27021
> rs.add("[hostname]:27021")
{ "ok" : 1 }
You will need to wait a minute or two as this node brings itself online, creates its own oplog, and readies itself.
You can monitor the progress with rs.status() while waiting till this node comes online as a secondary:
>use admin
>rs.status() {
"set" : "testset",
"date" : ISODate("2013-06-03T11:36:37Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "[hostname]:27021",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 723,
"optime" : {
"t" : 1370259331,
"i" : 1
},
"optimeDate" : ISODate("2013-06-03T11:35:31Z"),
"self" : true
},
 
Search WWH ::




Custom Search