美文网首页
sharding already enabled for col

sharding already enabled for col

作者: 西南有高楼 | 来源:发表于2018-08-22 12:09 被阅读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)

    相关文章

      网友评论

          本文标题:sharding already enabled for col

          本文链接:https://www.haomeiwen.com/subject/viweiftx.html