Create and Configure an Atlas Cluster
This tutorial demonstrates how to use the atlas setup command to:
Create one cluster in your Atlas project.
Load sample data into your Atlas cluster.
Add your IP address to your project's IP access list.
Create a MongoDB user for your Atlas cluster.
Connect to your new cluster using the MongoDB Shell,
mongosh
.
To perform all of these steps while also creating a new Atlas account, see Get Started with Atlas.
To create a cluster using a configuration file, run the
atlas clusters create command with the --file
option instead
of atlas setup
. To learn more about the configuration file
for an Atlas cluster, see Cluster Configuration File.
You can also use atlas setup
to create an Atlas account and
authenticate with Atlas. To learn more, see
Get Started with Atlas.
Prerequisites
Before you begin, complete the following tasks:
Configure an Atlas Cluster
Use the atlas setup
command to create an M0
cluster in Atlas. M0
clusters have some operational limitations.
You can run this command in the following ways:
Default settings mode: the command creates a sample shared-tier cluster with the default settings.
Interactive mode: the command prompts you for the cluster settings and provides default values.
Noninteractive mode: you run the command with the options.
Click the tab to see the command for your preferred mode.
The command creates a sample shared-tier cluster with the following default settings:
Cluster name:
Cluster<number>
Service provider:
AWS
Provider region:
US_EAST_1
Cluster tier:
M0
Disk size:
0.5
GBDatabase Username:
Cluster<number>
Database User Password:
abcdef12345
Allow connections from IP Address:
<YourIPAddress>
Load Sample Data:
Yes
Open Shell:
No
Note
The password is a random autogenerated value. abcdef12345
is an example value.
atlas setup --force
We are deploying Cluster9876543... Please store your database authentication access details in a secure location Database User Username: Cluster9876543 Database User Password: abcdef12345 Creating your cluster... [Its safe to 'Ctrl + C'] Cluster created. Your connection string: mongodb+srv://cluster9876543.example.mongodb.net Loading sample data into your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your Atlas cluster with: mongosh -u Cluster9876543 -p abcdef12345 mongodb+srv://cluster9876543.example.mongodb.net
The command prompts you for the cluster settings and provides
default options. When prompted, press Y
, then press
Enter
to accept the default settings.
atlas setup
Press [Enter] to use the default values. Enter [?] on any option to get help. [Default Settings] Cluster Name: Cluster9876543 Cloud Provider and Region: AWS - US_EAST_1 Database User Username: Cluster9876543 Load sample data: Yes Allow connections from (IP Address): <your-IP> ? Do you want to set up your first free database in Atlas with default settings (it's free forever)? Yes We are deploying Quickstart-9876543... Please store your database authentication access details in a secure location: Database User Username: Cluster9876543 Database User Password: abcdef12345 Creating your cluster... [Its safe to 'Ctrl + C'] Cluster created. Your connection string: mongodb+srv://cluster9876543.example.mongodb.net Loading sample data into your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your Atlas cluster with: mongosh -u Cluster9876543 -p abcdef12345 mongodb+srv://cluster9876543.example.mongodb.net
The command creates a sample shared-tier cluster with the following settings:
Cluster name:
getStarted
Service provider:
AWS
Provider region:
US_EAST-1
Cluster tier:
M0
Disk size:
2
GBMongoDB version:
5.0
Replica set members:
3
atlas setup --clusterName getStarted --provider AWS --region US_EAST_1 --username testUser --password changeMe --accessListIp 192.0.2.15 --skipSampleData --force
We are deploying getStarted... Please store your database authentication access details in a secure location: Database User Username: testUser Database User Password: changeMe Creating your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your |service| cluster with: mongosh -u testUser -p changeMe mongodb+srv://getStarted.example.mongodb.net
Take the Next Steps
Congratulations! You have successfully created a cluster to host your data.
Use the connection string
to connect to your cluster through mongosh
or your application.
To view the status of your cluster:
Run an
atlas clusters
command in the Atlas CLI.