我已将mongo db增强为集群。 我正在使用mongo 4.0.0
1个配置节点,4个shardsrv节点和1个mongos节点
从mongos节点连接机器人3T后
use admin
db.runCommand( { enablesharding : "test007" } )
输出
/* 1 */
{
"ok" : 1.0,
"operationTime" : Timestamp(1533293758, 4),
"$clusterTime" : {
"clusterTime" : Timestamp(1533293758, 4),
"signature" : {
"hash" : { "$binary" : "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "$type" : "00" },
"keyId" : NumberLong(0)
}
}
}
之后
use test007
sh.shardCollection("test007.customer", { "_id": "hashed" } )
输出
/* 1 */
{
"collectionsharded" : "test007.customer",
"collectionUUID" : UUID("448797e0-afdf-46b1-b2db-92d8e8ed2661"),
"ok" : 1.0,
"operationTime" : Timestamp(1533293909, 2),
"$clusterTime" : {
"clusterTime" : Timestamp(1533293909, 6),
"signature" : {
"hash" : { "$binary" : "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "$type" : "00" },
"keyId" : NumberLong(0)
}
}
}
然后我执行检查
db.customer.getShardDistribution()
输出
Collection test007.customer is not sharded.
当我将某些内容摄取到群集中时,我可以看到所有碎片节点的所有内容。
sh.status()
输出
{ "_id" : "test007", "primary" : "cluster1", "partitioned" : true, "version" : { "uuid" : BinData(4,"4IIk2Q3fSYO67QusUND2og=="), "lastMod" : 1 } }
test007.customer
shard key: { "_id" : "hashed" }
unique: false
balancing: true
chunks:
cluster1 2
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : NumberLong(0) } on : cluster1 Timestamp(1, 1)
{ "_id" : NumberLong(0) } -->> { "_id" : { "$maxKey" : 1 } } on : cluster1 Timestamp(1, 2)
有人知道为什么分片未正确初始化吗?