mongodb 分片集群 删除片键 code : 20 sharding already enabled for collection

xiaoxiao2021-02-27  135

mongodb分片集群指定片键删除了一个collection,再次为这个collection创建片键的时候,会报错

{ "ok" : 0, "errmsg" : "sharding already enabled for collection test.test", "code" : 20 }

解决办法就是在config库里面删除这个collection相关的信息,主要涉及到的collection表有locks。 解决办法如下:

use config db.collections.remove( { _id: "test.test" } ) db.chunks.remove( { ns: "test.test" } ) db.locks.remove( { _id: "test.test" } ) use admin db.adminCommand("flushRouterConfig)

这个问题真的很坑。。。。。。

转载请注明原文地址: https://www.6miu.com/read-14958.html

最新回复(0)