MongoDB add replica and modify priority

Source: Internet
Author: User
Tags mongodb add mongodb server

MongoDB add replica and modify priority

1. Add replica set

#在primary节点上执行

>rs.add ({host: "192.168.1.11:27017", priority:0})

#host: Specify the IP and port of the MongoDB server to be added

#priority: Specify permissions for the replica set

2. Adding the quorum node

#在primary节点上执行

>rs.add (' mongodb3.example.net:27017 ', true)

Or

>rs.addarb (host)

3, on-line change priority

#必须在primary节点上执行此操作, the replica set determines the size of precedence by setting the value of the priority. The range of this value is 0--100, and the higher the value, the higher the priority. If the value is 0, it cannot be a primay. Suitable for making cold preparation.

Primary> config=rs.conf ()

Primary>config.members[2].priority = 6

primary> rs.reconfig (config)

#第一步config =rs.conf () is to store the existing configuration by reading it into a variable.

#第二步config. members[2].priority = 6, modify the value in the variable, 2 is the value that executes the rs.config () command, sorted from top to bottom (that is, the node you see is the first), and this value starts at 0. For example, a total of four nodes of the replica set, from top to bottom of the sort of 0-1-2-3. 0 is the first, 6 is the priority, the higher the value, the greater the priority.

#第三步rs. reconfig (config) to synchronize the modified data to the configuration for the changes to take effect.

MongoDB add replica and modify priority

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.