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

Mongodb passive (passive) node configuration

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Modify a normal data node of a mongodb to a passive node, that is, it can synchronize data and vote, but cannot become a primary node.

Except for the arbitration node, each node has a value that represents the priority priority, and we can set the priority to determine who has the greatest weight in the primary.

In MongoDB replica sets, the priority is determined by setting the value of priority, which ranges from 0 to 100. The higher the value, the higher the priority.

If the value is 0, it cannot be primay.

View the list of nodes through the rs.conf () command:

The following is my experimental mongodb cluster:

PRIMARY > rs.conf () {"_ id": "test", "version": 22, "members": [{"_ id": 3, "host": "192.168.22.36 id 27017"}, {"_ id": 5, "host": "192.168.22.10 id 27017"}, {"_ id": 6, "host": "192.168.22.12 test 27017", "priority": 0, "arbiterOnly": true} {"_ id": 7, "host": "192.168.22.115purl 27017"}]}

two。 Modify the priority value of the 192.168.22.10 node above to 0 so that it only receives data and does not compete to become a primary.

The format of the command is as follows:

Cfg = rs.conf () cfg.members [0] .priority = 0.5cfg.members [1] .priority = 2cfg.members [2] .priority = 2rs.reconfig (cfg)

Description: cfg.members [0] .priority =

The numbers in square brackets are the order of nodes obtained by performing rs.conf (), with the first node writing 0 here, the second node writing 1, and so on.

Execute the command:

Cfg = rs.conf () cfg.members [1] .priority = 0rs.reconfig (cfg)

View the cluster status:

PRIMARY > rs.conf () {"_ id": "test", "version": 22, "members": [{"_ id": 3, "host": "192.168.22.36 priority 27017"}, {"_ id": 5, "host": "192.168.22.10 id 27017"priority": 0}, {"_ id": 6, "host": "192.168.22.12 id 27017", "priority": 0 "arbiterOnly": true}, {"_ id": 7, "host": "192.168.22.115displacement 27017"}]}

You can see that the value of the priority of the 192.168.22.10 priority node changes to 0, which only receives data and does not compete with the primary.

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