配置开启zzq7数据库和hehe集合的分片(实现在一个集合中的多个document进行分片,通过设置散列片键);
mongos> db.hehe.ensureIndex({"id":"hashed"})
{
"raw" : {
"shard1/192.168.100.102:27017,192.168.100.102:27018,192.168.100.102:27019" : {
"createdCollectionAutomatically" : true,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
},
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1587006957, 7),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1587006957, 7)
}
mongos> sh.enableSharding("zzq7");
{
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1587006992, 6),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1587006992, 6)
}
mongos> sh.shardCollection("zzq7.hehe",{"id":"hashed"})
{
"collectionsharded" : "zzq7.hehe",
"collectionUUID" : UUID("955e9cec-ad84-4956-bef0-bc9d0dbf7115"),
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1587007045, 22),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1587007