仅在主碎片中收集MongoDB碎片
我试图在我的分片集群中用三个分片服务器分片一个集合(db:mql,集合名称:teste),但是,包含我的数据的唯一分片是主分片仅在主碎片中收集MongoDB碎片,mongodb,nosql,scalability,sharding,Mongodb,Nosql,Scalability,Sharding,我试图在我的分片集群中用三个分片服务器分片一个集合(db:mql,集合名称:teste),但是,包含我的数据的唯一分片是主分片 --- Sharding Status --- sharding version: { "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId&q
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("60907ccc078cdbdf9b66c6d0")
}
shards:
{ "_id" : "sh1", "host" : "sh1/localhost:27022", "state" : 1, "tags" : [ "NYC", "SF" ] }
{ "_id" : "sh2", "host" : "sh2/localhost:27023", "state" : 1 }
{ "_id" : "sh3", "host" : "sh3/localhost:27026", "state" : 1 }
active mongoses:
"4.2.13" : 1
autosplit:
Currently enabled: yes
balancer:
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
853 : Success
databases:
{ "_id" : "config", "primary" : "config", "partitioned" : true }
config.system.sessions
shard key: { "_id" : 1 }
unique: false
balancing: true
chunks:
sh1 341
sh2 342
sh3 341
too many chunks to print, use verbose if you want to force print
{ "_id" : "mql", "primary" : "sh3", "partitioned" : true, "version" : { "uuid" : UUID("c2c07a45-b8a7-4468-a3ef-cd5bafd8999c"), "lastMod" : 1 } }
mql.teste
shard key: { "_id" : 1 }
unique: false
balancing: true
chunks:
sh3 1
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : sh3 Timestamp(1, 0)
这是我在检查集合是否被切分时得到的结果:
mongos> db.collections.find( {_id: "mql.teste" , dropped : false } )
{
"_id" : "mql.teste",
"lastmodEpoch" : ObjectId("6090c18062e39651b4cd267c"),
"lastmod" : ISODate("1970-02-19T17:02:47.296Z"),
"dropped" : false,
"key" : { "_id" : 1 },
"unique" : false,
"uuid" : UUID("91d1fdd2-5062-404b-b2ec-28a1f6e15b3e")
}
数据库未分片,它缺少
“distributionMode”:“分片”
核对
db.databases.find( {_id: "mql"}, {partitioned: 1} )
必须在数据库和集合级别启用分片:
sh.enableSharding("mql")
sh.shardCollection("mql.teste", { _id : 1 })
注意,使用
\u id
作为shardkey不是很聪明,最好使用{\u id:“hashed”}
,请参见mongodb分片集群均衡器尝试在每个分片上放置相同数量的块
该集合只有一个区块,因此不能在碎片中分割
块的默认最大大小为64MB
根据MongoDB的版本,当mongos或mongod意识到最大数据块大小的很大一部分已经写入数据块时,它将调用拆分
或者,您可以使用手动拆分块
您还可以运行db.getSiblingDB(“mql”).teste.getShardDistribution()
,以获取关于每个碎片上文档/块的数量和大小的信息