mongos> use sharding_test;
mongos> sh.enableSharding("sharding_test");
mongos> db.createCollection('test1');
mongos> sh.shardCollection("sharding_test.test1", { 'a1234567890': 1, 'b1234567890': 1, 'c1234567890': 1 });
{ "collectionsharded" : "sharding_test.test1", "ok" : 1 }
mongos> db.test1.insert({ 'a1234567890': 1, 'b1234567890': 1, 'c1234567890': 1 });
mongos> db.test1.getIndexes();
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "sharding_test.test1",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"a1234567890" : 1,
"b1234567890" : 1,
"c1234567890" : 1
},
"ns" : "sharding_test.test1",
"name" : "a1234567890_1_b1234567890_1_c1234567890_1"
}
]
mongos> db.createCollection('test2');
mongos> sh.shardCollection("sharding_test.test2", { 'a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890': 1, 'b1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890': 1, 'c1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890': 1 });
{ "collectionsharded" : "sharding_test.test2", "ok" : 1 }
mongos> db.test2.insert({ "a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" : 1, "b1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" : 1, "c1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" : 1 });
mongos> db.test2.getIndexes();
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "sharding_test.test2",
"name" : "_id_"
}
]