这个错的原因是。对collection分片时。key没有建索引。
解决方法。对该key建索引。或者还用其他已经建好索引的key
> db.runCommand( { shardcollection :"ISYDB_B.VIDEO",key : {id: 1} })
{
"ok" : 0,
"errmsg" : "please create an index over the sharding key before sharding."
}
> db.runCommand( { shardcollection :"ISYDB_B.VIDEO",key : {_id: 1} })
{ "collectionsharded" : "ISYDB_B.VIDEO", "ok" : 1 }