首页  :: 新随笔  :: 管理

实验测试阶段,删除Arbiter节点报如下错误:

"errmsg" : "Reconfig attempted to install a config that would change the implicit default write concern. Use the setDefaultRWConcern command to set a cluster-wide write concern and try the reconfig again.",

 

查看复制集配置信息(3个DB节点,1个Arbiter节点):

replicas:PRIMARY> rs.conf()
{
	"_id" : "replicas",
	"version" : 14,
	"term" : 8,
	"members" : [
		{
			"_id" : 0,
			"host" : "10.150.57.13:37071",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		},
		{
			"_id" : 1,
			"host" : "10.150.57.13:37072",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		},
		{
			"_id" : 2,
			"host" : "10.150.57.13:37073",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		},
		{
			"_id" : 3,
			"host" : "10.150.57.13:37074",
			"arbiterOnly" : true,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 0,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		}
	],
	"protocolVersion" : NumberLong(1),
	"writeConcernMajorityJournalDefault" : true,
	"settings" : {
		"chainingAllowed" : true,
		"heartbeatIntervalMillis" : 2000,
		"heartbeatTimeoutSecs" : 10,
		"electionTimeoutMillis" : 10000,
		"catchUpTimeoutMillis" : -1,
		"catchUpTakeoverDelayMillis" : 30000,
		"getLastErrorModes" : {
			
		},
		"getLastErrorDefaults" : {
			"w" : 1,
			"wtimeout" : 0
		},
		"replicaSetId" : ObjectId("61e62c38d305eeacf7ed8f87")
	}
}

 

当前复制集总共4个节点(3个DB节点,1个Arbiter节点),需要将setDefaultRWConcern修改为2个(参考:官方解决方案):

replicas:PRIMARY> db.adminCommand({
   "setDefaultRWConcern" : 2,
   "defaultWriteConcern" : {
     "w" : 3
   }
 })
{
#输出如下内容:
	"defaultReadConcern" : {
		"level" : "local"
	},
	"defaultWriteConcern" : {
		"w" : 2,
		"wtimeout" : 0
	},
	"updateOpTime" : Timestamp(1645495811, 1),
	"updateWallClockTime" : ISODate("2022-02-22T02:10:19.308Z"),
	"defaultWriteConcernSource" : "global",
	"defaultReadConcernSource" : "implicit",
	"localUpdateWallClockTime" : ISODate("2022-02-22T02:10:19.312Z"),
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1645495819, 2),
		"signature" : {
			"hash" : BinData(0,"JtmygH2Lh1ldlTiyOe5xDDOf7vI="),
			"keyId" : NumberLong("7054374532596891652")
		}
	},
	"operationTime" : Timestamp(1645495819, 2)
}

 

再次删除Arbiter节点

replicas:PRIMARY> rs.remove("10.150.57.13:37074")
{
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1645495899, 1),
		"signature" : {
			"hash" : BinData(0,"QGH1IPMHb6pxPf9UjIoKjf4kYnM="),
			"keyId" : NumberLong("7054374532596891652")
		}
	},
	"operationTime" : Timestamp(1645495899, 1)
}

 

再次查看复制集信息(目前3个DB节点):

replicas:PRIMARY> rs.conf()
{
	"_id" : "replicas",
	"version" : 15,
	"term" : 9,
	"members" : [
		{
			"_id" : 0,
			"host" : "10.150.57.13:37071",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		},
		{
			"_id" : 1,
			"host" : "10.150.57.13:37072",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		},
		{
			"_id" : 2,
			"host" : "10.150.57.13:37073",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
				
			},
			"secondaryDelaySecs" : NumberLong(0),
			"votes" : 1
		}
	],
	"protocolVersion" : NumberLong(1),
	"writeConcernMajorityJournalDefault" : true,
	"settings" : {
		"chainingAllowed" : true,
		"heartbeatIntervalMillis" : 2000,
		"heartbeatTimeoutSecs" : 10,
		"electionTimeoutMillis" : 10000,
		"catchUpTimeoutMillis" : -1,
		"catchUpTakeoverDelayMillis" : 30000,
		"getLastErrorModes" : {
			
		},
		"getLastErrorDefaults" : {
			"w" : 1,
			"wtimeout" : 0
		},
		"replicaSetId" : ObjectId("61e62c38d305eeacf7ed8f87")
	}
}