开发者

Unable to create index while sharding

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" : 开发者_如何学Python"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 sgserver collection inside of the admin database?

I don't see the command where you switch to the correct database before you do ensureIndex(). The code should probably look like this:

db.runCommand( { enablesharding : "sgserver" } );
use sgserver;
db.sgserver.ensureIndex({"fileGUID": 1});
db.runCommand( { shardcollection : "sgserver.block_seek_pos", key : {fileGUID : 1} } )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜