How to create a new cluster in MongoDB Atlas

A MongoDB cluster is a group of interconnected MongoDB servers, working together to provide high availability, scalability, and fault tolerance for MongoDB databases.

In a cluster, multiple MongoDB instances, called nodes, collaborate to store and manage data.

MongoDB clusters typically consist of the following components:

  • Shard: It represents a subset of the entire dataset distributed across multiple servers or machines called shard servers. It is a horizontal partition of data in MongoDB.

  • Config servers: These are a set of servers that store metadata and configuration information about the cluster.

  • Mongos: It refers to a MongoDB router. It is a process that acts as a query router in a sharded cluster. It serves as an interface between the client applications and the underlying sharded cluster.

  • Replica sets: These sets are a form of data replication in MongoDB. They maintain multiple copies of data on different servers and provide the feature of high availability and data redundancy.

To create a cluster on Atlas, we must have access to the project as an organization owner or project owner. A step-by-step guide to creating a MongoDB cluster on MongoDB Atlas is as follows:

  1. Go to the MongoDB Atlas website and sign up for an account or log in if you already have one.

  2. After logging in, click “New Project” and provide a name for the project. After naming the project, set permissions or keep the settings to default.

Add a project name
Add a project name
  1. On the left sidebar, click “Database” to go to the “Database Deployments” page. Click the “Build a Database” or “Create a Cluster” button to start the cluster creation process.
Click “Build a Database”
Click “Build a Database”
  1. Select the preferred cloud provider (such as AWS, Azure, or Google Cloud) and the region where the cluster should be hosted. Consider selecting a region that is geographically closest to the target audience or the existing infrastructure and then click “Create” to initiate the cluster creation process.
Select the provider, region, and cluster name
Select the provider, region, and cluster name

  1. In the next window, fill out two types of information:
  • Add a username and password for authentication.
  • Select an IP address to the access list that can connect to the project’s cluster.
Add username and password
1 of 2
  1. After creating the user and configuring the IP address, click the “Connect” button to get the connection string for the cluster. This connection string will be used by the application to connect to the MongoDB cluster on Atlas.

Note: In the “Overview” window of the cluster, you can get the cluster ID of the primary cluster and use it in your project with the username and password you created, and the port as 27017.

With the cluster created and access configured, we can start using our MongoDB cluster on Atlas. The connection string can be used to connect and manage our databases and interact with our data using the MongoDB client libraries or other tools.

Copyright ©2024 Educative, Inc. All rights reserved