2
votes

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..

1
Have you sharded a collection.Markus W Mahlberg
yes... the collection is called zip... I'll edit the post so you can see itDiego Velez
When you type this 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
@Hakan mongos> db.adminCommand({enableSharding: "articles"}) { "ok" : 0, "errmsg" : "already enabled" }Diego Velez
what is written in the log files, they can help to find the issue perhaps.Hakan Özler

1 Answers

0
votes

This problem is Solved.. this was caused due to a missconfiguration of a replica Set.. the third node on rs1 was not correctly set.. so be aware when you get this error