I'm trying to build a sharded cluster on mongoDB. but I have some issues when starting the db sharding or collection sharding the thing is that I've successfully added sharded hosts to the shard set. you can see it here
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
}
everything fine there.. also in the config db I have the db sharded as you can see here
mongos> use config
switched to db config
mongos> db.databases.find()
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "articles", "partitioned" : true, "primary" : "rs1" }
as you can see here the db articles is being partitioned and the primary host is the replica set 1...which is rs1
now... when I run sh.status...see what happens
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.
Also I have a collection sharded as you can see here
mongos> use articles switched to db articles
mongos> sh.shardCollection("articles.zip",{"id_":1}) { "ok" : 0, "errmsg" : "already sharded" }
I don't know why this is happening since everything is fine...
also the db is not being partitioned... I mean I dont have any data on rs2 or rs3... so it is clearly not working..
db.adminCommand({enableSharding: "articles"})
what do you get? and how many collections do you have in the zip? Why I am asking is because it may happen that all the documents can be located in one shard based on _id and the collection size. – Hakan Özler