mysql sharding stack overflow_我测试sharding时提示出错如上,不过我是给id加过索引呀。...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

odm finding:

am a newbie of mongodb,here is a simple case but got an error:

I want to use _id field (generated and indexed automatically) as a sharding key in mongodb, but got this error.

{"proposedKey" : { "_id" : "hashed"},"curIndexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "jackfruit.scenicspots" }, { "v" : 1, "key" : { "geoLocation" : "2dsphere" }, "name" : "geoLocation_2dsphere", "ns" : "jackfruit.scenicspots", "2dsphereIndexVersion" : 2 }],"ok" : 0,"errmsg" : "please create an index that starts with the shard key before sharding."

}

the error message showed that I already have an Index named _id_ on key _id, why the error still occur?

0down voteaccepted I found an answer from manual.MongoDB does not support creating new unique indexes in sharded collections and will not allow you to shard collections with unique indexes on fields other than the _id field.And here is a solution:fromEnforce Unique Keys for Sharded Collections

http://stackoverflow.com/questions/31158499/can-not-use-indexed-key-id-as-a-sharding-key-in-mongodb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值