On this page本页内容
mongos
detect changes in the sharded cluster configuration?mongos
如何检测分片集群配置中的更改?writebacklisten
in the log mean?writebacklisten
是什么意思?mongos
use connections?mongos
如何使用连接?This document answers common questions about Sharding. 本文档回答了有关分片的常见问题。See also the Sharding section in the manual, which provides an overview of sharding, including details on:另请参阅手册中的分片部分,该部分提供了分片的概述,包括以下详细信息:
Sometimes. However, if your data set fits on a single server, you should begin with an unsharded deployment as sharding while your data set is small provides little advantage .有时但是,如果您的数据集适合于单个服务器,那么您应该从非共享部署开始,因为当您的数据集中很小时,分片并没有什么好处。
Your options for changing a shard key depend on the version of MongoDB that you are running:更改分片键的选项取决于您正在运行的MongoDB版本:
In MongoDB 4.2 and earlier, if you must change a shard key after sharding a collection and cannot upgrade, the best option is to:在MongoDB 4.2及更早版本中,如果在对集合进行分片后必须更改分片键,并且无法升级,最好的选择是:
The balancer starts distributing data across the shards once the distribution of chunks has reached certain thresholds. 一旦块的分布达到一定的阈值,均衡器就开始跨分片分发数据。See Migration Thresholds.请参见迁移阈值。
In addition, MongoDB cannot move a chunk if the number of documents in the chunk exceeds a certain number. 此外,如果区块中的文档数量超过一定数量,MongoDB就无法移动区块。See Maximum Number of Documents Per Chunk to Migrate and Indivisible/Jumbo Chunks.请参见要迁移的每个块的最大文档数和不可见/巨型块。
mongos
detect changes in the sharded cluster configuration?mongos
如何检测分片集群配置中的更改?mongos
instances maintain a cache of the config database that holds the metadata for the sharded cluster.mongos
实例维护config
数据库的缓存,该缓存保存了分片集群的元数据。
mongos
updates its cache lazily by issuing a request to a shard and discovering that its metadata is out of date. 通过向分片发出请求并发现其元数据已过期,从而懒洋洋地更新其缓存。To force the 要强制mongos
to reload its cache, you can run the flushRouterConfig
command against each mongos
directly.mongos
重新加载其缓存,可以直接对每个mongos
运行fflushRouterConfig
命令。
writebacklisten
in the log mean?writebacklisten
是什么意思?The writeback listener is a process that opens a long poll to relay writes back from a 写回侦听器是一个过程,它打开一个长轮询,以在迁移后中继来自mongod
or mongos
after migrations to make sure they have not gone to the wrong server. mongod
或mongos
的写回,以确保它们没有转到错误的服务器。The writeback listener sends writes back to the correct server if necessary.如果需要,写回侦听器将写回发送到正确的服务器。
These messages are a key part of the sharding infrastructure and should not cause concern.这些消息是分片基础设施的关键部分,不应引起关注。
mongos
use connections?mongos
如何使用连接?Each 每个mongos
instance maintains a pool of connections to the members of the sharded cluster. mongos
实例都维护一个到分片集群成员的连接池。Client requests use these connections one at a time; i.e. requests are not multiplexed or pipelined.客户端请求一次使用一个连接;即,请求不是多路复用或流水线的。
When client requests complete, the 当客户端请求完成时,mongos
returns the connection to the pool. mongos
将连接返回到池。These pools do not shrink when the number of clients decreases. 当客户端数量减少时,这些池不会收缩。This can lead to an unused 这可能导致未使用的mongos
with a large number of open connections. mongos
具有大量开放连接。If the 如果mongos
is no longer in use, it is safe to restart the process to close existing connections.mongos
不再使用,可以安全地重新启动进程以关闭现有连接。
To return aggregated statistics related to all of the outgoing connection pools used by the 要返回与mongos
, connect mongosh
to the mongos
, and run the connPoolStats
command:mongos
使用的所有传出连接池相关的聚合统计信息,请将mongosh
连接到mongos
,然后运行connPoolStats
命令:
db.adminCommand("connPoolStats");
See the System Resource Utilization section of the UNIX 请参见UNIX ulimit
Settings document.ulimit
设置文档的系统资源利用率部分。