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:
Go to the MongoDB Atlas website and sign up for an account or log in if you already have one.
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.
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.