sharding already enabled for collection testdb.table2

項目中執(zhí)行

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"}

發(fā)現(xiàn)testdb.table2的記錄已經(jīng)存在。

解決:在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)

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容