Database Reference
In-Depth Information
Now that your configuration document is loaded you need to modify it. We want to set the node to be hidden and
have a priority of 0, so it will not be elected to be the primary. Notice that the document has a members array, which
contains a document for each member of the replica set. You need to pick the member you wish to access using the
array operator []. So to create a value of hidden : true for the third member, we need to update the array element at 2
(remember, arrays start at 0). Run the following:
> conf.members[2].hidden = true
true
Now we can set a priority value of 0 using the same commands:
> conf.members[2].priority = 0
0
You can output this config document by simply executing the name of the variable you placed the config
document into:
> conf
{
"_id" : "testset",
"version" : 3,
"members" : [
{
"_id" : 0,
"host" : "[hostname]:27021"
},
{
"_id" : 1,
"host" : "[hostname]:27022"
},
{
"_id" : 2,
"host" : "[hostname]:27023",
"hidden" : true,
"priority" : 0
}
]
}
As you can see, this member now has the hidden value set and a priority of 0. Now all we need to do is update
the replica set configuration to use this document. We do this by issuing the rs.reconfig ( ) command with our new
config document as an argument.
> rs.reconfig(conf)
Tue Jun 4 20:01:45.234 DBClientCursor::init call() failed
Tue Jun 4 20:01:45.235 trying reconnect to 127.0.0.1:27021
Tue Jun 4 20:01:45.235 reconnect 127.0.0.1:27021 ok
reconnected to server after rs command (which is normal)
Your whole replica set lost connectivity and then reconnected! This happens because of the reconfiguration. Any
changes to a replica set will potentially cause a replica set to reconfigure itself and have a new election, which under
Search WWH ::




Custom Search