質問

To elect a primary in an replication election, a majority of members need to be available. Does this mean majority of total members (including votes=0, hidden, delayed etc) or a majority of voting members?

What I need is a system like this

                     possible 
                 netw. partition
 _______    _______    |    _______    _______     _______    _______         
|   A   |  |       |   |   |   C   |  |   D   |   |   E   |  |   F   |   
|Primary|  |Arbitr.|   |   |Slave  |  |Backup |   |Backup |  |Backup |    
|_______|  |_______|   |   |_______|  |_______|   |_______|  |_______|

I want A to be master even in the case of possible network partition between A+Arbit. and the rest of the set. Can this be achieved? Like setting D,E,F to have votes=0 or making them hidden etc?

It would be nice to have D, E and F also supporting read operations, but not absolutely necessary.

役に立ちましたか?

解決

The majority criteria is for the number of votes available within the replica set, not the number of members. Non-voting members are not included in the calculation:

A replica set member cannot become primary unless it can connect to a majority of the members in the replica set. For the purposes of elections, a majority refers to the total number of votes, rather than the total number of members.

from http://docs.mongodb.org/manual/core/replica-set-elections/

so yes you should be able to do this although mongodb does recommend against it:

IMPORTANT Do not alter the number of votes to control which members will become primary. Instead, modify the priority option. Only alter the number of votes in exceptional cases. For example, to permit more than seven members.

In your diagram D, E and F can be non-voting members that still have the full data set and can be queried against for query operations.

You should be okay as long as the Primary A, the Arbiter and the Slave C are the only voting members.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top