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