# 使用以下添加语句后,长时间卡住后,报错
rs.addArb("DESKTOP-SVLTF5E:27019")
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.”
解决办法
db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {
"w" : 2
}
})
给mongodb配置一个默认writeConcern就可以解决,但是我们都知道一般情况下majority本来就是默认关注,但是为什么会有失败的情况呢?
原因
在官方文档中可以发现,默认的写关注并一定是majority(文档中还特别点名了具有arbiters的情况),而是会受到arbiter个数的影响。在添加了仲裁节点之后可能会导致默认写关注的改变,所以需要手工配置一下setDefaultRWConcern的内容。