Convert a Replica Set to a Sharded Cluster¶
On this page
You can convert a replica set to a sharded cluster.
Prerequisites¶
To convert your replica set to a sharded cluster:
- Your cluster must be an
M10
or higher cluster. - You must have
Project Cluster Manager
or higher role.
Procedure¶
Navigate to the Database Deployments 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 is not already displayed, select your desired project from the Projects menu in the navigation bar.
- If the Database Deployments page is not already displayed, click Databases in the sidebar.
Click the cluster name to view cluster details.¶
Click Configuration in the Overview tab to view the page where you can edit your cluster settings.¶
Expand Additional Settings to modify your cluster configuration.¶
Enable sharding in the Shard your cluster section by setting the toggle to On.¶
After you convert a replica set to a sharded cluster, you can't convert it again to a replica set.
Select the number of shards from the dropdown.¶
Sharding supports high throughput and large datasets, and you can increase the number of shards as data requirements grow. By default, Atlas creates two shards.
Click Review Changes to review the changes to billing and when satisfied, click Apply Changes.¶
It may take some time for Atlas to deploy the changes. Please wait until Atlas has converted your cluster before proceeding to the next step.
Restart all application clients and reconnect to the sharded cluster.¶
If you don't restart the application clients, your data might be inconsistent after Atlas begins distributing data across shards.
- If you are using a DNS Seed List
connection string, your application automatically connects to the
mongos
for your sharded cluster. - If you are using a standard connection string, you must update your connection string to reflect your new cluster topology.
To learn more, see Connect to a Database Deployment.
Distribute data across the shards in your cluster.¶
To shard the collection whose data you want to distribute, see
sh.shardCollection()
for more
information.
Change any cluster-wide settings.¶
If you want to make further changes to the sharded cluster, see Modify a Cluster for more information on the cluster-wide settings that you can modify.