Priority settings for replica set members

MongoDB allows us to set different priority levels for each member. This allows for some interesting applications and topologies to be implemented.

To change the priority after we have set up our cluster, we have to connect to our primary using the mongo shell and get the configuration object (in this case, cfg):

> cfg = rs.conf()

Then, we can change the members sub-document priority attribute to the value of our choice:

> cfg.members[0].priority = 0.778
> cfg.members[1].priority = 999.9999
The default priority is 1 for every member. The priority can be set from 0 (never become a primary) to 1000, in floating-point precision.

Higher priority members will be the first to call an election when the primary steps down, and are also the most likely to win the election.

Custom priorities should be configured with consideration of the different network partitions. Setting priorities the wrong way may lead to elections not being able to elect a primary, thus stopping all writes to our MongoDB replica set.

If we want to prevent a secondary from becoming a primary, we can set its priority to 0, as we will explain in the following section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset