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>
具體設定如下:
登陸主節點:
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>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2151347/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB 6.0.3副本集搭建MongoDB
- mongodb 4.0副本集搭建MongoDB
- mongodb副本集新增刪除節點MongoDB
- MongoDB日常運維-04副本集搭建MongoDB運維
- 單機Linux下搭建MongoDB副本集-三節點LinuxMongoDB
- 2.MongoDB 4.2副本集環境基於時間點的恢復MongoDB
- MongoDB日常運維-05副本集故障切換MongoDB運維
- MongoDB 4.2副本集新增/刪除副本(一主一副一仲裁)MongoDB
- MongoDB 刪除,新增副本集,並修改副本集IP等資訊MongoDB
- MongoDB 4.2副本集自動故障轉移(一主一副一仲裁)MongoDB
- MongoDB日常運維-06副本集搭建錯誤彙總MongoDB運維
- MongoDB副本集MongoDB
- 搭建MongoDB副本集MongoDB
- MongoDB 副本集搭建MongoDB
- MongoDB部署副本集MongoDB
- MongoDB 副本集管理MongoDB
- mongodb副本集用一致性快照方法新增從節點步驟MongoDB
- MongoDB - 副本集簡介MongoDB
- 006.MongoDB副本集MongoDB
- dom4j 根據xml節點路徑查詢節點,找到對應的目標節點下的子節點,對節點Text值進行修改XML
- MongoDB副本集replica set (二)--副本集環境搭建MongoDB
- MongoDB 副本集切換方法MongoDB
- MongoDB 副本集原理及管理MongoDB
- MongoDB叢集搭建(包括隱藏節點,仲裁節點)MongoDB
- onnx 增刪改查,修改節點,刪除節點,修改input,output
- MongoDB Replica Set 副本集實踐MongoDB
- mongodb主從仲裁節點配置MongoDB
- MongoDB修復config配置節點MongoDB
- MongoDB重新命名database的方法一例MongoDBDatabase
- 節點快取的優缺點快取
- mongodb叢集節點故障的切換方法MongoDB
- Python連線訪問mongodb副本集PythonMongoDB
- Mongodb分散式叢集副本集+分片MongoDB分散式
- 手把手教你搭建mongodb副本集MongoDB
- 如何修改監聽異常的優先順序
- MongoDB單節點部署與基本操作MongoDB
- 樹,計算父節點的值
- 副本集要點
- 第六章 MongoDB副本集搭建MongoDB