Docs Menu
Docs Home
/
MongoDB 매뉴얼
/ / /

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:

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.

1

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.

2

For example, to connect to your mongos instance running on host mongodb6.example.net as an admin user named admin01:

mongosh "mongodb://admin01@mongodb6.example.net:27017"
3

To configure your dedicated config server to run as a config shard, run the transitionFromDedicatedConfigServer command from the admin database:

db.adminCommand( {
transitionFromDedicatedConfigServer: 1
} )
4

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.

5

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.

돌아가기

구성 샤드