这篇文章主要介绍MongoDB如何修改副本集节点的优先值,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
复制集节点的优先级影响了 elections 的结果。我们通过设置不同的优先级来提高部分节点成为主节点的可能性,也可以让某些节点不能成为主节点。
具体设置如下:
登陆主节点:
test:PRIMARY> cfg = rs.conf()
{
"_id" : "test",
"version" : 4,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "192.168.0.51:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "192.168.0.52:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "192.168.0.53:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 3,
"host" : "192.168.0.52: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")
}
}
修改节点优先值:
test:PRIMARY> cfg.members[0].priority = 1
1
test:PRIMARY> cfg.members[0].priority = 3
3
test:PRIMARY> cfg.members[1].priority = 2
2
test:PRIMARY> cfg.members[2].priority = 1
1
应用配置:
test:PRIMARY> rs.reconfig(cfg)
{ "ok" : 1 }
test:PRIMARY>
以上是“MongoDB如何修改副本集节点的优先值”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。