Get the App
SLTechnology News&Howtos  ›  Database  › 

How MongoDB modifies the priority value of a replica set node

Shulou Source: shulou.com Published: 2022-05-31 15:17:15 10月03日 Update

This article mainly introduces how MongoDB modifies the priority value of the replica set node, which is very detailed and has certain reference value. Friends who are interested must read it!

The priority of the replication set node affects the results of the elections. We can improve the possibility of some nodes becoming master nodes by setting different priorities, and we can also prevent some nodes from becoming master nodes.

The specific settings are as follows:

Log in to the main node:

Test:PRIMARY > cfg = rs.conf ()

{

"_ id": "test"

"version": 4

"protocolVersion": NumberLong (1)

"members": [

{

"_ id": 0

"host": "192.168.0.51 purl 27017"

"arbiterOnly": false

"buildIndexes": true

"hidden": false

"priority": 1

"tags": {

}

"slaveDelay": NumberLong (0)

"votes": 1

}

{

"_ id": 1

"host": "192.168.0.52 purl 27017"

"arbiterOnly": false

"buildIndexes": true

"hidden": false

"priority": 1

"tags": {

}

"slaveDelay": NumberLong (0)

"votes": 1

}

{

"_ id": 2

"host": "192.168.0.53 virtual 27017"

"arbiterOnly": false

"buildIndexes": true

"hidden": false

"priority": 1

"tags": {

}

"slaveDelay": NumberLong (0)

"votes": 1

}

{

"_ id": 3

"host": "192.168.0.52 purl 27019"

"arbiterOnly": true

"buildIndexes": true

"hidden": false

"priority": 1

"tags": {

}

"slaveDelay": NumberLong (0)

"votes": 1

}

]

"settings": {

"chainingAllowed": true

"heartbeatIntervalMillis": 2000

"heartbeatTimeoutSecs": 10

"electionTimeoutMillis": 10000

"catchUpTimeoutMillis": 60000

"getLastErrorModes": {

}

"getLastErrorDefaults": {

"w": 1

"wtimeout": 0

}

"replicaSetId": ObjectId ("5a94ff92bf8f7ba59f48e552")

}

}

Modify the node priority value:

Test:PRIMARY > cfg.members [0] .priority = 1

one

Test:PRIMARY > cfg.members [0] .priority = 3

three

Test:PRIMARY > cfg.members [1] .priority = 2

two

Test:PRIMARY > cfg.members [2] .priority = 1

one

Apply configuration:

Test:PRIMARY > rs.reconfig (cfg)

{"ok": 1}

Test:PRIMARY >

The above is all the content of the article "how MongoDB modifies the priority value of replica set nodes". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Nodes copies priorities content articles differences values interests possibilities guys partners more knowledge results industry information information channels parts channels references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi macOS Linux Shulou Tech Info