Convert a Replica Set to a Sharded Cluster
On this page
- In MongoDB Cloud Manager, go to the Deployment page for your project.
- Go to the Processes page.
- Select the Clusters view for your deployment.
- Convert your desired replica set.
- Provide Details for your New Sharded Cluster.
- Click Convert.
- Modify your Application to Connect to the
mongos
Processes Instead of the Replica Set. - Change any Cluster-Wide Settings.
- OAuth 2.0 authentication for programmatic access to Cloud Manager is available as a Preview feature.
- The feature and the corresponding documentation might change at any time during the Preview period. To use OAuth 2.0 authentication, create a service account to use in your requests to the Cloud Manager Public API.
Cloud Manager provides the ability to convert a replica set to a sharded cluster.
In MongoDB Cloud Manager, go to the Deployment page for your project.
If it is not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
If the Deployment page is not already displayed, click Deployment in the sidebar.
The Deployment page displays.
Go to the Processes page.
Click the Processes tab for your deployment.
The Processes page displays.
Convert your desired replica set.
From the menu on the desired replica set, click Convert to Sharded Cluster.
Provide Details for your New Sharded Cluster.
Configure the following settings in the Provide details for your new sharded cluster modal:
Name your sharded cluster components:
FieldActionCluster NameType the name of your new cluster.CSRS NameType the name of the CSRS.Note
You cannot change these values after you click Convert.
Set the following values for each
mongod
process in your Config Servers. All fields are required.Note
You must deploy at least one configuration server.
FieldActionHost NameFrom the menu, select an existing hostname or type a hostname in the search box above the list to find a host.
If you need to add a new host:
Click the New Server link.
Click Next.
Follow the instructions to install a new Automation on that new host.
Click Verify Agent.
PortType the IANA port number.Data DirectoryType the absolute directory path to the database files for each
mongod
.The example path is
/data
.The
mongod
must have exclusive use of these paths on the specified host. The Cloud Manager Automation must have file system permission to read, write, and execute all files and folders in this directory.Log FileType the absolute file path for the log file for each
mongod
.The example path is
/data/mongodb.log
.The
mongod
must have exclusive use of these paths on the specified host. The Cloud Manager Automation must have file system permission to read, write, and execute all files and folders in this directory.Note
Adding or Removing Config Servers
To add a new configuration server, click Add a Config Server.
To remove a config server, click to the right of the config server you want to remove.
Set the following values for each MongoS process in your sharded cluster. All fields are required.
Note
You must deploy at least one
mongos
.FieldActionHost NameFrom the menu, select an existing hostname or type a hostname in the search box above the list to find a host.
If you need to add a new host:
Click the New Server link.
Click Next.
Follow the instructions to install a new Automation on that new host.
Click Verify Agent.
PortType the IANA port number.Log FileType the abolute file path for the log of each
mongos
process.The example path is
/data/mongodb.log
.The
mongos
must have exclusive use of these paths on the specified host. The Cloud Manager Automation must have file system permission to read, write, and execute all files and folders in this directory.
Modify your Application to Connect to the mongos
Processes Instead of the Replica Set.
From the Cloud Manager UI, click the icon, then
click Connect to this instance. The
Connect to your Deployment dialog provides the hostname
and port of a mongos
in the cluster.
For complete documentation on connecting to an Cloud Manager deployment, see Connect to a MongoDB Process
Change any Cluster-Wide Settings.
If you want to make any further changes to the sharded cluster, see the Sharded Cluster tab on the Edit a Deployment's Configuration page.
After you convert a replica set to a sharded cluster, you can enable sharding for a database and shard collections.
To learn how to shard collections, see Shard a Collection.
If you need to add additional shards to support greater capacity, click on the wrench menu for the sharded cluster to create additional shards.
Note
Effects on Backup after Converting
The converted shard (original replica set) has:
Backup enabled
Previous snapshots retained
Ability to restore snapshots to this shard only
After converting, you should enable Backup for the entire sharded cluster. On databases running MongoDB FCV 4.0 or earlier, activating Backup causes Cloud Manager to start an initial sync on the config servers and the converted shard. Restores to the entire sharded cluster should use snapshots taken after conversion only.