Databases Reference
In-Depth Information
> use local
> config = db.system.replset.findOne()
{
"_id" : "foo",
"version" : 2,
"members" : [
{
"_id" : 0,
"host" : "rs1:5555"
},
{
"_id" : 1,
"host" : "rs2:5555",
"arbiterOnly" : true
},
{
"_id" : 2,
"host" : "rs3:5555"
},
{
"_id" : 3,
"host" : "rs4:5555"
}
]
}
To change our configuration, we need to change the config object to our desired con-
figuration and mark it as “newer” than the configuration that the other servers have,
so that they will pick up the change.
The config above is for a four-member replica set, but suppose we wanted to change
that to a 3-member replica set, consisting of hosts rs1 , rs2 , and rs4 . To accomplish this,
we need to remove the rs3 element of the array, which can be done using JavaScript's
slice function:
> config.slice(2, 1)
> config{
"_id" : "foo",
"version" : 2,
"members" : [
{
"_id" : 0,
"host" : "rs1:5555"
},
{
"_id" : 1,
"host" : "rs2:5555",
"arbiterOnly" : true
},
{
"_id" : 3,
"host" : "rs4:5555"
}
]
}
 
Search WWH ::




Custom Search