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)
这个问题真的很坑。。。。。。