翻译或纠错本页面

分片参考文献

Sharding Methods in the mongo Shell

名字

描述

sh._adminCommand()

在admin数据库运行 database command ,就像 db.runCommand() ,不过可以保证只在 mongos 上运行.

sh.getBalancerLockDetails() Reports on the balancer lock.
sh._checkFullName() Tests a namespace to determine if its well formed.
sh._checkMongos()

检测 mongo 终端连接的是否为一个 mongos 示例.

sh._lastMigration()

报告最后进行的 chunk 迁移.

sh.addShard()

向集群中添加一个 shard

sh.addShardTag()

将一个分片与一个标记相关联,用以支持 标记相关的分片.

sh.addShardToZone()

将片键的范围与某个标记相关联,用以支持 标记相关的分片.

sh.addTagRange() In MongoDB 3.4, this method aliases to sh.updateZoneKeyRange().
sh.updateZoneKeyRange()

禁用一个分片数据库中某个集合的均衡过程,这并不影响这个分片数据库中其他分片的均衡过程.

sh.removeTagRange()

如果之前使用了命令 sh.disableBalancing() 禁用了某个集合的均衡过程,这个命令将重新启用均衡过程.

sh.removeRangeFromZone() Removes an association between a range of shard keys and a zone. Supports configuring zones in sharded clusters.
sh.disableBalancing() Disable balancing on a single collection in a sharded database. Does not affect balancing of other collections in a sharded cluster.
sh.enableBalancing() Activates the sharded collection balancer process if previously disabled using sh.disableBalancing().
sh.enableSharding() Enables sharding on a specific database.
sh.getBalancerHost()

返回一个布尔值,报告当前是否有均衡器在进行数据块的迁移.

sh.getBalancerState() Returns a boolean to report if the balancer is currently enabled.
sh.help() Returns help text for the sh methods.
sh.isBalancerRunning()

打开或关闭在 shards 间迁移 数据块balancer .

sh.moveChunk() Migrates a chunk in a sharded cluster.
sh.removeShardTag()

使用特定的 shard key 值,将一个已经存在的 chunk 分成两部分.

sh.removeShardFromZone()

将包含查询文档的一个已经存在的 chunk 分成两个差不多大小的数据块.

sh.setBalancerState() Enables or disables the balancer which migrates chunks between shards.
sh.shardCollection()

就像 db.printShardingStatus() 一样,返回 sharded cluster 的状态信息.

sh.splitAt() Divides an existing chunk into two chunks using a specific value of the shard key as the dividing point.
sh.splitFind() Divides an existing chunk that contains a document matching a query into two approximately equal chunks.
sh.startBalancer() Enables the balancer and waits for balancing to start.
sh.status()

内部命令,等待指定的 sharded cluster 分布锁.

sh.stopBalancer()

内部命令,(等待来自集群中一个 mongos 发来的ping状态的改变.)

sh.waitForBalancer() Internal. Waits for the balancer state to change.
sh.waitForBalancerOff() Internal. Waits until the balancer stops running.
sh.waitForDLock() Internal. Waits for a specified distributed sharded cluster lock.
sh.waitForPingChange() Internal. Waits for a change in ping state from one of the mongos in the sharded cluster.

分片数据库命令

以下的命令支持 集群.

名字

描述

flushRouterConfig Forces an update to the cluster metadata cached by a mongos.
addShard

sharded cluster 中增加一个 shard.

balancerStart Starts a balancer thread.
balancerStatus Returns information on the balancer status.
balancerStop Stops the balancer thread.
cleanupOrphaned

移除不属于某个分片却存储在这个分片的数据.

checkShardingIndex

验证片键上索引有效性的内部命令.

enableSharding Enables sharding on a specific database.
listShards

返回配置服务器中的分片列表

removeShard

开始删除一个分片的过程.

getShardMap

报告集群状态的内部命令.

getShardVersion Internal command that returns the config server version.
mergeChunks

可以合并在一个分片上的数据块.

setShardVersion

设置 配置服务器 上数据块版本的内部命令.

shardCollection Enables the sharding functionality for a collection, allowing the collection to be sharded.
shardingState Reports whether the mongod is a member of a sharded cluster.
unsetSharding

在MongoDB部署中影响实例间连接的内部命令.

split

创建一个新的 chunk.

splitChunk

分裂数据块的内部命令,使用 sh.splitFind()sh.splitAt() 进行替代.

splitVector

决定分裂点的内部命令.

medianKey

废弃非内部命令,参见 splitVector.

moveChunk

在分片间迁移数据块的内部命令.

movePrimary

在将某个分片从集群中删除时,重新设置 primary shard .

isdbgrid

确认一个实例是否为 mongos.

addShardToZone Associates a shard with a zone. Supports configuring zones in sharded clusters.
removeShardFromZone Removes the association between a shard and a zone. Supports configuring zones in sharded clusters.
updateZoneKeyRange Adds or removes the association between a range of sharded data and a zone. Supports configuring zones in sharded clusters.

参考文档

Operational Restrictions
Requirement for deploying a sharded cluster
排除集群故障
Common strategies for troubleshooting sharded cluster deployments.
Config Database
Complete documentation of the content of the local database that MongoDB uses to store sharded cluster metadata.