Mongo Sharding问题 - 此数据库未启用碎片



我正在尝试在mongodb上构建一个碎片集群。但是我在开始DB分片或收集碎片时有一些问题事实是,我已经成功地将碎片主机添加到了碎片集中。您可以在这里看到

mongos> use admin
switched to db admin
mongos> db.runCommand( { listshards : 1 } );
{
    "shards" : [
        {
            "_id" : "rs1",
            "host" : "rs1/mongodb1:10001,mongodb2:10001,mongodb3:10001"
        },
        {
            "_id" : "rs2",
            "host" : "rs2/mongodb1:10002,mongodb2:10002,mongodb3:10002"
        },
        {
            "_id" : "rs3",
            "host" : "rs3/mongodb1:10003,mongodb2:10003,mongodb3:10003"
        }
    ],
    "ok" : 1
}

那里的一切都很好。同样在Config DB中,我可以在此处看到DB碎片

mongos> use config
switched to db config
mongos> db.databases.find()
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "articles", "partitioned" : true, "primary" : "rs1" }

您在这里看到的DB文章正在分区,主要主机是副本集1 ...是RS1

现在...当我运行sh.status ...看看发生了什么

mongos> use articles
mongos> sh.status()
printShardingStatus: this db does not have sharding enabled. be sure you are connecting to a mongos from the shell and not to a mongod.

我也可以看到一个收藏夹

mongos> use articles switched to db articles 
mongos> sh.shardCollection("articles.zip",{"id_":1}) { "ok" : 0, "errmsg" : "already sharded" }

我不知道为什么会发生这种情况,因为一切都很好...

也没有分区DB ...我的意思是我没有RS2或RS3上的任何数据...因此显然不起作用。

解决了此问题。这是由于副本集的错觉引起的。.RS1上的第三个节点未正确设置。.因此,当您获得此错误时,请注意知道/p>

最新更新