Convert a Replica Set to a Sharded Cluster with an Embedded Config Server
Starting in MongoDB 8.0, you can 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 or embedded config server.
Converting your replica set into a sharded cluster with an embedded config server can reduce:
The number of nodes required in your deployment.
Complexity for maintaining one-shard clusters.
이 작업에 대하여
You can't directly convert a replica set to a config shard. To convert a replica set to an embedded config server, you must:
Convert your replica set to a sharded cluster with a dedicated config server.
Configure the dedicated config server to run as a config shard using the
transitionFromDedicatedConfigServer
command.The
transitionFromDedicatedConfigServer
command adds the config server as a shard in the cluster.
Reduce the number of shards in your cluster after adding the config shard.
액세스 제어
If access control is enabled, the transitionFromDedicatedConfigServer
command requires the transitionFromDedicatedConfigServer
authorization action for the cluster.
The clusterManager
role has the transitionFromDedicatedConfigServer
authorization action and can be assigned to a user.
단계
The following example converts a self-managed replica set to a config shard that contain pre-existing user data from the replica set.
Convert your replica set to a sharded cluster with a dedicated config server
This tutorial assumes that you know how to convert your self-managed replica set to a sharded cluster. For full instructions, see Convert a Self-Managed Replica Set to a Sharded Cluster.
Verify that the config server is now a config shard
You can check the admin.system.version
collection for an entry where shardName: 'config'
.
db.getSiblingDB("admin").system.version.find( { shardName: 'config' } )
참고
If the balancer is running, it automatically migrates data across the shards. Otherwise, use the moveCollection
or moveChunk
commands to manually distribute your data.
Reduce the number of shards in your cluster to one
To reduce the cluster to a single shard after adding the config shard, move all unsharded collections to the config shard using the moveCollection
command and remove the first shard in the cluster with the removeShard
command. This step reduces your cluster to a single config shard.
For full instructions on removing shards in your cluster, see Remove Shards from a Sharded Cluster.