> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# commitTransitionToDedicatedConfigServer (database command)

## Definition

Commits the transition from an embedded config server to a dedicated config server.

In order to run this command, you must transition to a dedicated config server with the [`startTransitionToDedicatedConfigServer`](https://www.mongodb.com/docs/manual/reference/command/starttransitiontodedicatedconfigserver.md#mongodb-dbcommand-dbcmd.startTransitionToDedicatedConfigServer) command. This command tells the balancer to move chunks from the shard to other shards in the cluster. You must also manually move databases that use the shard as the [primary shard](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-primary-shard) and unsharded collections stored on the shard before running the `commitTransitionToDedicatedConfigServer` command.

The command returns `ok: 0` with an error if the transition to the dedicated config server does not complete or if it contains a database or unsharded collection. If the transition occurs and all databases and unsharded collections migrated off of the shard, the command returns `ok: 1`.

To start transitioning to a dedicated config server see the [`startTransitionToDedicatedConfigServer`](https://www.mongodb.com/docs/manual/reference/command/starttransitiontodedicatedconfigserver.md#mongodb-dbcommand-dbcmd.startTransitionToDedicatedConfigServer) command.

To show the status of the transition from an embedded config server to a dedicated config server, see the [`getTransitionToDedicatedConfigServerStatus`](https://www.mongodb.com/docs/manual/reference/command/gettransitiontodedicatedconfigserverstatus.md#mongodb-dbcommand-dbcmd.getTransitionToDedicatedConfigServerStatus) command.

To stop the in-progress transition from an embedded config server to a dedicated config server [`stopTransitionToDedicatedConfigServer`](https://www.mongodb.com/docs/manual/reference/command/stoptransitiontodedicatedconfigserver.md#mongodb-dbcommand-dbcmd.stopTransitionToDedicatedConfigServer) command.

**New in version 8.3**

## Compatibility

This command is available in deployments hosted in the following environments:

- [MongoDB Enterprise](https://www.mongodb.com/docs/manual/administration/install-enterprise.md#std-label-install-mdb-enterprise): The subscription-based, self-managed version of MongoDB

- [MongoDB Community](https://www.mongodb.com/docs/manual/administration/install-community.md#std-label-install-mdb-community-edition): The source-available, free-to-use, and self-managed version of MongoDB

**Note:**

This command is not supported in [MongoDB Atlas](https://www.mongodb.com/docs/atlas). See [Modify your Atlas Sharded Cluster](https://www.mongodb.com/docs/atlas/cluster-additional-settings/#atlas-managed-config-servers-for-sharded-clusters) to drain the embedded config server.

## Syntax

The command has the following syntax:

```javascript
db.adminCommand( {
     commitTransitionToDedicatedConfigServer: 1
} )
```

## Behavior

### Access Requirements

If you have [`authorization`](https://www.mongodb.com/docs/manual/reference/configuration-options.md#mongodb-setting-security.authorization) enabled, you must have the [`clusterManager`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-clusterManager) role or any role that includes the [`removeShard`](https://www.mongodb.com/docs/manual/reference/privilege-actions.md#mongodb-authaction-removeShard) action.

### Database Migration Requirements

Each database in a sharded cluster has a primary shard. If the transitioning shard is also the primary of one of the cluster's databases, then you must manually move the databases from its primary shard to a new shard after migrating all data from the shard.

If there is a database that uses the shard you want to use as a primary, the `commitTransitionToDedicatedConfigServer` command returns an error.

For details, see the [`movePrimary`](https://www.mongodb.com/docs/manual/reference/command/moveprimary.md#mongodb-dbcommand-dbcmd.movePrimary) command and the [Remove Shards from a Sharded Cluster](https://www.mongodb.com/docs/manual/tutorial/remove-shards-from-cluster.md#std-label-remove-shards-from-cluster-tutorial) for more information.

### Collection Migration Requirements

Unsharded collections are stored on individual shards. If one of these collections is on the shard you want to transition from embedded to dedicated config server, you must first migrate the collection to a different shard.

If there is an unsharded collection stored on the shard you want to transition from embedded to dedicated config server, the `commitTransitionToDedicatedConfigServer` command returns an error.

To migrate an unsharded collection, see the [`moveCollection`](https://www.mongodb.com/docs/manual/reference/command/movecollection.md#mongodb-dbcommand-dbcmd.moveCollection) command.

## Examples

To start draining a shard, use the [`db.adminCommand()`](https://www.mongodb.com/docs/manual/reference/method/db.admincommand.md#mongodb-method-db.adminCommand) method to run the [`startTransitionToDedicatedConfigServer`](https://www.mongodb.com/docs/manual/reference/command/starttransitiontodedicatedconfigserver.md#mongodb-dbcommand-dbcmd.startTransitionToDedicatedConfigServer) command:

```javascript
db.adminCommand( { startTransitionToDedicatedConfigServer: "1" } )
```

To check the status of the draining operation, use the [`getTransitionToDedicatedConfigServerStatus`](https://www.mongodb.com/docs/manual/reference/command/gettransitiontodedicatedconfigserverstatus.md#mongodb-dbcommand-dbcmd.getTransitionToDedicatedConfigServerStatus) command:

```javascript
db.adminCommand( { getTransitionToDedicatedConfigServerStatus: "1" } )
```

**Output:**

```javascript
{
   "state" : "drainingComplete",
   "msg" : "draining completed successfully",
   "ok" : 1,
   "$clusterTime" : {
      "clusterTime" : Timestamp(1772142838, 176),
      "signature" : {
         "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
         "keyId" : NumberLong(0)
      }
   },
   "operationTime" : Timestamp(1772142838, 174)
}
```

If the output shows any databases in the `dbsToMove` field, use the [`movePrimary`](https://www.mongodb.com/docs/manual/reference/command/moveprimary.md#mongodb-dbcommand-dbcmd.movePrimary) command to move them onto a different shard.

If the output shows any unsharded collections in the `collectionsToMove` field, use the [`moveCollection`](https://www.mongodb.com/docs/manual/reference/command/movecollection.md#mongodb-dbcommand-dbcmd.moveCollection) command to move them onto a different shard.

When [`getTransitionToDedicatedConfigServerStatus`](https://www.mongodb.com/docs/manual/reference/command/gettransitiontodedicatedconfigserverstatus.md#mongodb-dbcommand-dbcmd.getTransitionToDedicatedConfigServerStatus) shows `{ state:
"completed" }`, the balancer has finished moving chunks off the shard. You can now remove the shard:

```javascript
db.adminCommand( { commitTransitionToDedicatedConfigServer: "1" } )
```

**Output:**

```javascript
{
   "ok" : 1,
   "$clusterTime" : {
      "clusterTime" : Timestamp(1772142839, 19),
      "signature" : {
         "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
         "keyId" : NumberLong(0)
      }
   },
   "operationTime" : Timestamp(1772142839, 19)
}
```

## Learn More

- [`getTransitionToDedicatedConfigServerStatus`](https://www.mongodb.com/docs/manual/reference/command/gettransitiontodedicatedconfigserverstatus.md#mongodb-dbcommand-dbcmd.getTransitionToDedicatedConfigServerStatus)

- [`startTransitionToDedicatedConfigServer`](https://www.mongodb.com/docs/manual/reference/command/starttransitiontodedicatedconfigserver.md#mongodb-dbcommand-dbcmd.startTransitionToDedicatedConfigServer)

- [`stopTransitionToDedicatedConfigServer`](https://www.mongodb.com/docs/manual/reference/command/stoptransitiontodedicatedconfigserver.md#mongodb-dbcommand-dbcmd.stopTransitionToDedicatedConfigServer)
