Config Servers配置服务器

On this page本页内容

Important重要

Starting in 3.4, the use of the deprecated mirrored mongod instances as config servers (SCCC) is no longer supported. 从3.4开始,不再支持将不推荐使用的镜像mongod实例用作配置服务器(SCCC)。Before you can upgrade your sharded clusters to 3.4, you must convert your config servers from SCCC to CSRS.在将分片集群升级到3.4之前,必须将配置服务器从SCCC转换为CSR。

To convert your config servers from SCCC to CSRS, see the MongoDB 3.4 manual Upgrade Config Servers to Replica Set.要将配置服务器从SCCC转换为CSR,请参阅MongoDB 3.4手动将配置服务器升级到副本集

Config servers store the metadata for a sharded cluster. 配置服务器存储分片集群的元数据。The metadata reflects state and organization for all data and components within the sharded cluster. 元数据反映了分片集群中所有数据和组件的状态和组织。The metadata includes the list of chunks on every shard and the ranges that define the chunks.元数据包括每个分片上的块列表以及定义块的范围。

The mongos instances cache this data and use it to route read and write operations to the correct shards. mongos实例缓存这些数据,并使用它将读写操作路由到正确的分片。mongos updates the cache when there are metadata changes for the cluster, such as Chunk Splits or adding a shard. 当集群的元数据发生变化时,比如区块分割添加分片mongos会更新缓存。Shards also read chunk metadata from the config servers.分片还从配置服务器读取区块元数据。

The config servers also store Authentication configuration information such as Role-Based Access Control or internal authentication settings for the cluster.配置服务器还存储身份验证配置信息,例如基于角色的访问控制集群的内部身份验证设置

MongoDB also uses the config servers to manage distributed locks.MongoDB还使用配置服务器来管理分布式锁。

Each sharded cluster must have its own config servers. 每个分片集群必须有自己的配置服务器。Do not use the same config servers for different sharded clusters.不要对不同的分片集群使用相同的配置服务器。

Warning警告

Administrative operations conducted on config servers may have significant impact on sharded cluster performance and availability. 在配置服务器上执行的管理操作可能会对分片集群的性能和可用性产生重大影响。Depending on the number of config servers impacted, the cluster may be read-only or offline for a period of time.根据受影响的配置服务器的数量,群集可能会在一段时间内处于只读或脱机状态。

Replica Set Config Servers副本集配置服务器

Changed in version 3.4.在版本3.4中更改

Starting in MongoDB 3.2, config servers for sharded clusters can be deployed as a replica set (CSRS) instead of three mirrored config servers (SCCC). 从MongoDB 3.2开始,分片集群的配置服务器可以部署为副本集(CSR),而不是三个镜像配置服务器(SCCC)。Using a replica set for the config servers improves consistency across the config servers, since MongoDB can take advantage of the standard replica set read and write protocols for the config data. 为配置服务器使用副本集可以提高配置服务器之间的一致性,因为MongoDB可以利用配置数据的标准副本集读写协议。In addition, using a replica set for config servers allows a sharded cluster to have more than 3 config servers since a replica set can have up to 50 members. 此外,为配置服务器使用副本集允许分片集群拥有3个以上的配置服务器,因为副本集最多可以有50个成员。To deploy config servers as a replica set, the config servers must run the WiredTiger storage engine.要将配置服务器部署为副本集,配置服务器必须运行WiredTiger存储引擎

In version 3.4, MongoDB removes support for SCCC config servers.在3.4版中,MongoDB取消了对SCCC配置服务器的支持

The following restrictions apply to a replica set configuration when used for config servers:当用于配置服务器时,以下限制适用于副本集配置:

Read and Write Operations on Config Servers配置服务器上的读写操作

The admin database and the config database exist on the config servers.配置服务器上存在admin数据库和配置数据库

Writes to Config Servers写入配置服务器

The admin database contains the collections related to the authentication and authorization as well as the other system.* collections for internal use.admin数据库包含与身份验证和授权以及其他system.* 集合相关的集合供内部使用。

The config database contains the collections that contain the sharded cluster metadata. 配置数据库包含包含分片集群元数据的集合。MongoDB writes data to the config database when the metadata changes, such as after a chunk migration or a chunk split.当元数据发生变化时,例如在块迁移块分割之后,MongoDB会将数据写入配置数据库

Users should avoid writing directly to the config database in the course of normal operation or maintenance.用户应避免在正常操作或维护过程中直接写入配置数据库。

When writing to the config servers, MongoDB uses a write concern of "majority".在向配置服务器写入时,MongoDB使用"majority"写入关注点

Reads from Config Servers从配置服务器读取

MongoDB reads from the admin database for authentication and authorization data and other internal uses.MongoDB从admin数据库中读取身份验证和授权数据以及其他内部用途。

MongoDB reads from the config database when a mongos starts or after a change in the metadata, such as after a chunk migration. MongoDB在mongos启动时或元数据更改后(例如区块迁移后)从config数据库读取数据。Shards also read chunk metadata from the config servers.分片还从配置服务器读取区块元数据。

When reading from the replica set config servers, MongoDB uses a Read Concern level of "majority".从副本集配置服务器读取时,MongoDB使用"majority"读取关注级别。

Config Server Availability配置服务器可用性

If the config server replica set loses its primary and cannot elect a primary, the cluster's metadata becomes read only. 如果配置服务器副本集丢失其主副本集,并且无法选择主副本集,则集群的元数据将变为只读You can still read and write data from the shards, but no chunk migration or chunk splits will occur until the replica set can elect a primary.您仍然可以从分片中读取和写入数据,但在副本集可以选择主数据之前,不会发生块迁移或块拆分。

In a sharded cluster, mongod and mongos instances monitor the replica sets in the sharded cluster (e.g. shard replica sets, config server replica set).在分片集群中,mongodmongos实例监视分片集群中的副本集(例如,分片副本集、配置服务器副本集)。

If all config servers become unavailable, the cluster can become inoperable. 如果所有配置服务器都不可用,集群可能无法运行。To ensure that the config servers remain available and intact, backups of config servers are critical. 为了确保配置服务器保持可用和完整,配置服务器的备份至关重要。The data on the config server is small compared to the data stored in a cluster, and the config server has a relatively low activity load.与集群中存储的数据相比,配置服务器上的数据较小,并且配置服务器的活动负载相对较低。

For 3.2 sharded clusters, if the number of consecutive unsuccessful attempts to monitor the config server replica set exceeds replMonitorMaxFailedChecks parameter value, the monitoring mongos or mongod instance becomes unusable until you restart the instance. 对于3.2分片群集,如果监视配置服务器副本集的连续失败尝试次数超过replMonitorMaxFailedChecks参数值,则监视mongosmongod实例将无法使用,直到重新启动该实例。See v3.2 troubleshooting guide for a workaround.请参阅v3.2解决方法的故障排除指南

See A Config Server Replica Set Member Become Unavailable for more information.有关详细信息,请参阅配置服务器副本集成员变得不可用

Sharded Cluster Metadata分片集群元数据

Config servers store metadata in the Config Database.配置服务器在配置数据库中存储元数据。

Important重要

Always back up the config database before doing any maintenance on the config server.在对配置服务器进行任何维护之前,请始终备份config数据库。

To access the config database, issue the following command in mongosh:要访问config数据库,请在mongosh中发出以下命令:

use config

In general, you should never edit the content of the config database directly. 一般来说,绝不直接编辑配置数据库的内容。The config database contains the following collections:config数据库包含以下集合:

For more information on these collections and their role in sharded clusters, see Config Database. 有关这些集合及其在分片集群中的角色的更多信息,请参阅配置数据库See Read and Write Operations on Config Servers for more information about reads and updates to the metadata.有关元数据读取和更新的更多信息,请参阅配置服务器上的读写操作

Sharded Cluster Security分片集群安全

Use Internal/Membership Authentication to enforce intra-cluster security and prevent unauthorized cluster components from accessing the cluster. 使用内部/成员身份验证来实施集群内安全,并防止未经授权的集群组件访问集群。You must start each mongod in the cluster with the appropriate security settings in order to enforce internal authentication.必须使用适当的安全设置启动群集中的每个mongod,以强制执行内部身份验证。

Starting in MongoDB 5.3, SCRAM-SHA-1 cannot be used for intra-cluster authentication. 从MongoDB 5.3开始,SCRAM-SHA-1不能用于集群内身份验证。Only SCRAM-SHA-256 is supported.仅支持SCRAM-SHA-256

In previous MongoDB versions, SCRAM-SHA-1 and SCRAM-SHA-256 can both be used for intra-cluster authentication, even if SCRAM is not explicitly enabled.在以前的MongoDB版本中,SCRAM-SHA-1和SCRAM-SHA-256都可以用于集群内身份验证,即使没有明确启用SCRAM。

See Deploy Sharded Cluster with Keyfile Authentication for a tutorial on deploying a secured sharded cluster.有关部署安全分片集群的教程,请参阅使用密钥文件身份验证部署分片集群

←  Shardsmongos →