This isn’t really a straight forward task. From what I know in 1.7 there is a command but that is development only. So I’m running 1.6 and to see the config for my replica set I run
rs.conf();
I get the following output
> rs.conf();
{
"_id" : "core",
"version" : 3,
"members" : [
{
"_id" : 0,
"host" : "mongo1.domain.com:27017"
},
{
"_id" : 1,
"host" : "mongo2.domain.com"
},
{
"_id" : 2,
"host" : "mgmt1.domain.com",
"arbiterOnly" : true
}
]
}
Now I have two members to my replica set plus my arbiter. So I want to remove that so I can add another one. So I run the following
> use admin;
> cfg = rs.conf();
> cfg.members.splice(2,1);
> cfg['version'] = 4
> db.runCommand({replSetReconfig: cfg});
Then it will be removed. You can see my version was at 3 so I upped it to 4 so mongo will know there was a change. Now if I check the config I get the following
> rs.conf()
{
"_id" : "core",
"version" : 4,
"members" : [
{
"_id" : 0,
"host" : "mongo1.domain.com:27017"
},
{
"_id" : 1,
"host" : "mongo2.domain.com"
}
]
}