MongoDB分片数据库partitioned属性始终为false问题求助
MongoDB分片集群中sharddb数据库partitioned属性始终为false的问题
环境信息
- MongoDB版本:6.0.4
- Mongosh版本:1.8.0
- 本地通过不同端口搭建分片集群,执行
sh.status()得到的集群配置如下:
[direct: mongos] test> sh.status() shardingVersion { _id: 1, minCompatibleVersion: 5, currentVersion: 6, clusterId: ObjectId("643fd1088dc14852e495a094") } --- shards [ { _id: 'shard001', host: 'shard001/127.0.0.1:27117,127.0.0.1:27118,127.0.0.1:27119', state: 1, topologyTime: Timestamp({ t: 1681904960, i: 7 }) }, { _id: 'shard002', host: 'shard002/127.0.0.1:27217,127.0.0.1:27218,127.0.0.1:27219', state: 1, topologyTime: Timestamp({ t: 1681904968, i: 8 }) }, { _id: 'shard003', host: 'shard003/127.0.0.1:27317,127.0.0.1:27318,127.0.0.1:27319', state: 1, topologyTime: Timestamp({ t: 1681904975, i: 6 }) } ]
已执行操作及结果
- 创建sharddb数据库,以及
user、users两个集合 - 执行
sh.enableSharding("sharddb")为数据库开启分片 - 为两个集合配置分片并插入数据,相关配置及数据分布结果如下:
{ database: { _id: 'sharddb', primary: 'shard002', partitioned: false, version: { uuid: new UUID("e2603a9b-53e3-4ecd-8ef9-f35786431451"), timestamp: Timestamp({ t: 1682148090, i: 1 }), lastMod: 1 } }, collections: { 'sharddb.user': { shardKey: { name: 1 }, unique: false, balancing: true, chunkMetadata: [ { shard: 'shard002', nChunks: 1 } ], chunks: [ { min: { name: MinKey() }, max: { name: MaxKey() }, 'on shard': 'shard002', 'last modified': Timestamp({ t: 1, i: 0 }) } ], tags: [] }, 'sharddb.users': { shardKey: { name: 'hashed' }, unique: false, balancing: true, chunkMetadata: [ { shard: 'shard001', nChunks: 2 }, { shard: 'shard002', nChunks: 2 }, { shard: 'shard003', nChunks: 2 } ], chunks: [ { min: { name: MinKey() }, max: { name: Long("-6148914691236517204") }, 'on shard': 'shard001', 'last modified': Timestamp({ t: 1, i: 0 }) }, { min: { name: Long("-6148914691236517204") }, max: { name: Long("-3074457345618258602") }, 'on shard': 'shard001', 'last modified': Timestamp({ t: 1, i: 1 }) }, { min: { name: Long("-3074457345618258602") }, max: { name: Long("0") }, 'on shard': 'shard002', 'last modified': Timestamp({ t: 1, i: 2 }) }, { min: { name: Long("0") }, max: { name: Long("3074457345618258602") }, 'on shard': 'shard002', 'last modified': Timestamp({ t: 1, i: 3 }) }, { min: { name: Long("3074457345618258602") }, max: { name: Long("6148914691236517204") }, 'on shard': 'shard003', 'last modified': Timestamp({ t: 1, i: 4 }) }, { min: { name: Long("6148914691236517204") }, max: { name: MaxKey() }, 'on shard': 'shard003', 'last modified': Timestamp({ t: 1, i: 5 }) } ], tags: [] } } }
问题描述
尽管已执行sh.enableSharding("sharddb"),且两个集合已配置分片(其中users集合的分片数据已分布到三个shard),但sharddb数据库的partitioned属性始终显示为false。再次执行sh.enableSharding("sharddb")返回成功,但查询db.databases.find()的结果仍显示该属性为false:
[direct: mongos] config> sh.enableSharding("sharddb"); { ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1683086356, i: 1 }), signature: { hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0), keyId: Long("0") } }, operationTime: Timestamp({ t: 1683086356, i: 1 }) } [direct: mongos] config> db.databases.find() [ { _id: 'sharddb', primary: 'shard002', partitioned: false, version: { uuid: new UUID("e2603a9b-53e3-4ecd-8ef9-f35786431451"), timestamp: Timestamp({ t: 1682148090, i: 1 }), lastMod: 1 } }, ]
寻求解决该问题的方法。
内容的提问来源于stack exchange,提问作者jan
相关产品推荐
相关产品推荐

