When i am trying to enable the shard… I am getting following errors……..
use admin
switched to db admin
> db.runCommand( { enablesharding : "sgserver" } )
{ "ok" : 1 }
> db.runCommand( { shardcollection : "sgserver.block_seek_pos", key : {fileGUID : 1} } )
"ok" : 0,
"errmsg" : "please create an index over the sharding key before sharding."
> db.sgserver.ensureIndex({"fileGUID": 1})
> db.runCommand( { shardcollection : "sgserver.block_seek_pos", key : {fileGUID : 1} } )
"ok" : 0,
"errmsg" : "please create an index over the sharding key before sharding."
Its insisting that I create an index, but if I try to create an index I am getting the above mentioned error.
Can anyone help me out with this?
Is the
sgservercollection inside of theadmindatabase?I don’t see the command where you switch to the correct database before you do
ensureIndex(). The code should probably look like this: