0

I deployed a sharded cluster and when I am trying to enable sharding, I am getting the below error. I tried to find solution online, but unable to solve this.

I performed the below things to start mongod/mongos and mongo instances

mongod --configsvr --dbpath /data/configdb --port 27018
mongos --configdb 127.0.0.1:27018 --port 27019
mongo --configdb 127.0.0.1:27019

In mongos:

mongos> sh.enableSharding("config")
{
"errmsg" : "exception: assertion src/mongo/s/config.cpp:155",
"code" : 0,
"ok" : 0
}

Also, I am able to create normal collection here but not a sharded colleciton.

At the same time, I am not able to create normal collections in db's other than config

mongos> show dbs
admin   (empty)
config  0.046875GB
configdb    (empty)
raghu   (empty)
test    (empty)
mongos> 
mongos> use test
switched to db test
mongos>
mongos> sh.enableSharding("test")
{ "ok" : 0, "errmsg" : "already enabled" }
mongos> db.cTest.save({Name: "Frank", Age:56, Job: "Accountant", State: "NY"});
can't create user databases on a --configsvr instance
mongos>

Can someone please tell me, what would have went wrong?

Thanks, Raghu

Amol M Kulkarni
  • 21,143
  • 34
  • 120
  • 164
Raghu
  • 57
  • 8
  • Are you trying to enable sharing on the config server database? Or do you have your own database called 'config'. I would suspect a name conflict here. – Wedge Martin May 29 '15 at 18:14
  • Btw, mongo --configdb shouldn't be necessary. To fire up the shell you should execute 'mongo localhost:27019' which is where you have your mongos routing daemon running, but I agree with Neil in that I would avoid running your mongos on the default port of the config server. – Wedge Martin May 29 '15 at 18:20

1 Answers1

0

I don't know what this line is supposed to do:

mongo --configdb 127.0.0.1:27019

Certainly nothing good, because mongo is the shell and not anything that needs to be informed of that sort of option.

Also this is a really bad idea

mongos --configdb 127.0.0.1:27018 --port 27019

As generally speaking you want the mongos instance to be using the default port (27017) to make things easier for your application. Your subsequent connections using the mongo shell should then be picking up the mongos rather than the underlying mongod instances. So start up everything else on a different port other than the mongos.

I can only point you back as was done in your original question the the sharding tutorial that you were given, and to actually follow it.

You seem to be really missing some of the concepts of sharding, in that any shard should have several replica set members and you need multiple shards.

Perhaps you should start off with replica set's as a tutorial and then look to turn those into shards. Or possibly look at the MongoDB university courses available (which are free). Either M101 or M102 have units explaining replica set and sharding deployment in detail.

The tutorials listed in the documentation, should be very easy to follow, if you follow them. From your above content, you are not really following what is stated there.

Community
  • 1
  • 1
Neil Lunn
  • 148,042
  • 36
  • 346
  • 317