sharding already enabled for col

2018-08-22  本文已影响0人  西南有高楼

项目中执行

user_cli.admin.command({'shardcollection':'testdb.table2','key':{'id':1}})

开启testdb.table2集合分片功能:

报:OperationFailure: sharding already enabled for collection testdb.table2 的错误。

这时再切换到config库查看:

mongos> use config

mongos> db.chunks.find()

{"_id":"testdb.table-id_MinKey","ns":"testdb.table","min":{"id":{"$minKey": 1}},"max":{"id":{"$maxKey": 1}},"shard":"autotestshd5ox8","lastmod": Timestamp(1,0),"lastmodEpoch": ObjectId("5b7c22cab2f293f9ed236190")}{"_id":"testdb.table2-id_MinKey","lastmod": Timestamp(2,0),"lastmodEpoch": ObjectId("5b7c2475b2f293f9ed23630a"),"ns":"testdb.table2","min":{"id":{"$minKey": 1}},"max":{"id": 1},"shard":"autotestshdcnas"}{"_id":"testdb.table2-id_1","lastmod": Timestamp(2,1),"lastmodEpoch": ObjectId("5b7c2475b2f293f9ed23630a"),"ns":"testdb.table2","min":{"id": 1},"max":{"id": 21},"shard":"autotestshd5ox8"}

发现testdb.table2的记录已经存在。

解决:在config库里面删除这个testdb.table2相关的信息相关的信息。

mongos>use config

mongos>db.collections.remove( { _id: "testdb.table2" } )

mongos>db.chunks.remove( { ns: "testdb.table2" } )

mongos>db.locks.remove( { _id: "testdb.table2" } )

mongos>use admin

mongos>db.adminCommand("flushRouterConfig)

上一篇下一篇

猜你喜欢

热点阅读