Database Reference
In-Depth Information
"stateStr" : "ARBITER",
"uptime" : 721,
"lastHeartbeat" : ISODate("2013-06-07T11:21:01Z"),
"lastHeartbeatRecv" : ISODate("2013-06-07T11:21:00Z"),
"pingMs" : 0
}
You may have recognized a problem here; we have four nodes now. That's an even number, and even is bad! If we
continue to run like this, your MongoDB nodes will start logging the following:
[rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
To fix that, we know that we need to have an odd number of members; so one potential solution is to add another
arbiter as the log message suggests, but that's not strictly elegant as we add extra complexity that isn't required. The
best solution is to stop one of the existing nodes from voting and being viewed as a member of the quorum. We can do
this by setting votes to zero for our hidden secondary. We do this in the same manner as we did to set the hidden and
priority values.
conf = rs.conf()
conf.members[2].votes = 0
rs.reconfig(conf)
And that's it. We have now set our passive node to be truly passive: it will never become primary; it is viewed
as part of the replica set by clients; and it cannot participate in elections or be counted toward a majority. To test
this, you can try shutting down the passive node, and the arbiter and your other two nodes will continue on primary
unchanged; whereas before, the primary would have stepped down, citing that it could not see a majority of nodes.
Replica Set Chaining
You have seen that normally a member of a replica set will attempt to sync data from the primary of that set. But that
is not the only place replica set secondaries can sync from; they can also sync-from other secondaries. In this manner
your secondaries can form a “sync-chain,” in which each one syncs the latest data from other secondaries in your
replica set.
Managing Replica Sets
MongoDB provides a number of commands for managing the configuration and status of a replica set. Table 11-2
shows the available commands that you can use to create, manipulate, and inspect the state of a cluster in a
replica set.
 
Search WWH ::




Custom Search