mongodb的优先级

The priority settings of replica set members affect both the timing and the outcome of elections for primary. Higher-priority members are more likely to call elections, and are more likely to win. Use this setting to ensure that some members are more likely to become primary and that others can never become primary.

The value of the member’s priority setting determines the member’s priority in elections. The higher the number, the higher the priority.
优先级越大,被选举成primary的机会就越大,修改的方式如下:

Copy the replica set configuration to a variable.

In the mongo shell, use rs.conf() to retrieve the replica set configuration and assign it to a variable. For example:

cfg = rs.conf()

Change each member’s priority value.¶

Change each member’s members[n].priority value, as configured in the members array.

cfg.members[0].priority = 0.5
cfg.members[1].priority = 2
cfg.members[2].priority = 2
Assign the replica set the new configuration.¶

Use rs.reconfig() to apply the new configuration.

rs.reconfig(cfg)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值