Closing question in mongo db

When I do sharding then after getting an error when using addShard function in mongodb: Please help me

"ok" : 0,
"errmsg" : "no such command: addShard",
"code" : 59,
"bad cmd" : {
    "addShard" : "<server name>"
}

      

Why is this error occurring?

+3


source to share


2 answers


It looks like you might not be related to the mongos instance.

Make sure you are connected to mongo (router). Here is some sample code that I am using to implement sharding with reference to addShard. I've included the rest of the code for clarity.



//this adds members of a replica set as a shard
sh.addShard("rs0/serverShd4:27017,serverShd4b:27017,serverShd4c:27017")

//indexes
use mydb
db.mycoll.ensureIndex({s:"hashed"})

//The db name is "mydb"
sh.enableSharding("mydb")

//This is the shard key strategy deemed necessary by OI to date
sh.shardCollection( "mydb.mycoll", { s: "hashed" } )

      

+1


source


switched to db admin

db.runCommand ({addshard: "localhost: 10000"})

{"shardadded": "shard0000", "ok": 1}



db.runCommand ({addshard: "localhost: 10001"})

{"shardadded": "shard0001", "ok": 1}

must work. http://comments.gmane.org/gmane.comp.db.mongodb.user/77102

0


source







All Articles