我正在尝试在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...which是rs1
现在..。当我运行sh.status...see时会发生什么
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的数据...所以它显然不起作用..
发布于 2015-05-09 02:32:35
这个问题已经解决了..这是由于副本集的配置错误导致的。rs1上的第三个节点未正确设置。因此,当您收到此错误时,请注意
https://stackoverflow.com/questions/30108277
复制相似问题