Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How MongoDB modifies the priority value of a replica set node

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report