Database Manual / Reference / Database Commands / Sharding

transitionToDedicatedConfigServer (database command数据库命令)

Definition定义

transitionToDedicatedConfigServer

New in version 8.0.在版本8.0中新增。

Starting in MongoDB 8.0, you can:从MongoDB 8.0开始,您可以:

  • Configure a config server to store your application data in addition to the usual sharded cluster metadata. A config server that stores application data is called a config shard.配置配置服务器以存储应用程序数据以及通常的分片集群元数据。存储应用程序数据的配置服务器称为配置分片。
  • Transition a config server between being a config shard and a dedicated config server.在配置分片和专用配置服务器之间转换配置服务器。

A cluster requires a config server, but it can be a config shard instead of a dedicated config server. Using a config shard reduces the number of nodes required and can simplify your deployment.集群需要一个配置服务器,但它可以是一个配置分片,而不是一个专用的配置服务器。使用配置分片可以减少所需的节点数量,并简化部署。

If your application has demanding availability and resiliency requirements, consider deploying a dedicated config server. A dedicated config server provides isolation, dedicated resources, and consistent performance for critical cluster operations.如果应用程序具有苛刻的可用性和弹性要求,请考虑部署专用配置服务器。专用配置服务器为关键集群操作提供隔离、专用资源和一致的性能。

The transitionToDedicatedConfigServer command configures a config shard to run as a dedicated config server. The command causes the balancer to prioritize moving the chunks from the config shard to other shards in the cluster.transitionToDedicatedConfigServer命令将配置分片配置为作为专用配置服务器运行。该命令使平衡器优先将块从配置分片移动到集群中的其他分片。

Before you run transitionToDedicatedConfigServer, connect to mongos and use the admin database.在运行transitionToDedicatedConfigServer之前,请连接到mongos并使用管理数据库。

The sharded cluster must have featureCompatibilityVersion set to at least 8.0.分片集群必须将featureCompatibilityVersion设置为至少8.0

Syntax语法

Command syntax:命令语法:

db.adminCommand( {
transitionToDedicatedConfigServer: 1
} )

Behavior行为

The transitionToDedicatedConfigServer command moves application data from the config shard to the other shards in the same way that removeShard moves data. transitionToDedicatedConfigServer命令将应用程序数据从配置分片移动到其他分片,其方式与removeShard移动数据的方式相同。The balancer moves sharded collection data to other eligible shards in the cluster. You must move unsharded collection data and databases to a shard of your choice in the cluster. 平衡器将分片集合数据移动到集群中其他符合条件的分片。您必须将未分片的集合数据和数据库移动到集群中您选择的分片。For the procedure to remove a config shard, see Remove Shards from a Sharded Cluster.有关删除配置分片的过程,请参阅从分片集群中删除分片。

Internally, transitionToDedicatedConfigServer runs the removeShard command. transitionToDedicatedConfigServer returns the same response as removeShard. The response after a successful data move contains state: "completed". 在内部,transitionToDedicatedConfigServer运行removeShard命令。transitionToDedicatedConfigServer返回与removeShard相同的响应。数据移动成功后的响应包含state: "completed"For full response details and examples, see removeShard Example. 有关完整的响应详细信息和示例,请参阅removeShard示例Review the removeShard documentation before running transitionToDedicatedConfigServer to understand how it may affect your deployment.在运行transitionToDedicatedConfigServer之前,请查看removeShard文档,以了解它可能会如何影响部署。

If you run transitionToDedicatedConfigServer twice and the shard data is currently moving to other shards, the second run of transitionToDedicatedConfigServer returns the current status of the data move. transitionToDedicatedConfigServer returns the same response as removeShard.如果运行transitionToDedicatedConfigServer两次,并且分片数据当前正在移动到其他分片,则第二次运行transitionToDedicatedConfigServer将返回数据移动的当前状态。transitionToDedicatedConfigServer返回与removeShard相同的响应。

After transitionToDedicatedConfigServer completes the data move, the config server is a dedicated config server and is no longer a config shard.transitionToDedicatedConfigServer完成数据移动后,配置服务器将成为专用配置服务器,不再是配置分片。

Access Control访问控制

If access control is enabled, the transitionToDedicatedConfigServer command requires the transitionToDedicatedConfigServer authorization action for the cluster:如果启用了访问控制,则transitionToDedicatedConfigServer命令要求对群集执行transitionToDedicatedConfigServer授权操作:

{
resource: { cluster : true },
actions: [ "transitionToDedicatedConfigServer" ]
}

The clusterManager role has transitionToDedicatedConfigServer authorization action and can be assigned to a user.clusterManager角色具有transitionToDedicatedConfigServer授权操作,可以分配给用户。

The following example assigns the clusterManager role to a user named testUser:以下示例将clusterManager角色分配给名为testUser的用户:

db.grantRolesToUser(
"testUser",
[ "clusterManager" ]
)

Example示例

The following example configures a config shard to run as a dedicated config server:以下示例将配置分片配置为作为专用配置服务器运行:

db.adminCommand( {
transitionToDedicatedConfigServer: 1
} )

For details, see Downgrade Feature Compatibility Version.有关详细信息,请参阅降级功能兼容性版本

Learn More了解更多