【发布时间】:2015-05-07 17:48:04
【问题描述】:
我正在尝试在 mongoDB 上构建一个分片集群。但是在启动数据库分片或集合分片时我遇到了一些问题 问题是我已经成功地将分片主机添加到分片集中。你可以在这里看到它
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
}
那里一切都很好.. 同样在配置数据库中,我将数据库分片,如您在此处看到的那样
mongos> use config
switched to db config
mongos> db.databases.find()
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "articles", "partitioned" : true, "primary" : "rs1" }
正如您在此处看到的,数据库文章正在被分区,主主机是副本集 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" }
我不知道为什么会这样,因为一切都很好......
数据库也没有被分区...我的意思是我在 rs2 或 rs3 上没有任何数据...所以它显然无法正常工作..
【问题讨论】:
-
您是否对集合进行了分片。
-
是的...该集合称为 zip... 我将编辑帖子以便您查看
-
当您输入
db.adminCommand({enableSharding: "articles"})时,您会得到什么? zip 中有多少个系列?为什么我要问是因为可能会发生所有文档都可以根据 _id 和集合大小位于一个分片中的情况。 -
@Hakan mongos> db.adminCommand({enableSharding: "articles"}) { "ok" : 0, "errmsg" : "already enabled" }
-
日志文件中写了什么,他们也许可以帮助找到问题。
标签: mongodb