On this page
- Overview
- Firewall Rules
- Procedures
Cloud Manager will no longer support Automation, Backup, and Monitoring for MongoDB 3.6 and 4.0 after August 30th, 2024. Please
Overview
To connect to a MongoDB, retrieve the hostname and port informationfrom Cloud Manager and then use a MongoDB client, such as mongosh
or aMongoDB driver, to connect. Toconnect to a cluster, retrieve the hostnameand port for the mongos process. To connect to areplica set or standalone process, retrievethe hostname and port for the mongod processes.
Firewall Rules
Firewall rules and user authentication affect your access to MongoDB.You must have access to the server and port of the MongoDB process.For information on firewalls on servers running MongoDB, seethe firewall information in the Network Security document in the MongoDB manual.
If your MongoDB instance runs on Amazon Web Services (AWS), then thesecurity group associated with the AWS servers also affects access. AWSsecurity groups control inbound and outbound traffic to theirassociated servers.
Procedures
You can retrieve a shell command for connecting to your MongoDBinstance, or you can retrieve the host and port number of a specificMongoDB process and create your own command for connecting using eithershell orMongoDB driver.
Get a Shell Command to Connect to a MongoDB Instance
1
In MongoDB Cloud Manager, go to the Deployment page for your project.
If it is not already displayed, select the organization thatcontains your desired project from the Organizations menu in thenavigation bar.
If it's not already displayed, select your desired projectfrom the Projects menu in the navigation bar.
If the Deployment page is notalready displayed, click Deployment in the sidebar.
The Deployment pagedisplays.
2
Go to the Processes page.
Click the Processes tab for your deployment.
The Processes pagedisplays.
3
Select the Clusters view for your deployment.
4
On the line listing the cluster, replica set, or process, click the ellipsis icon and select Connect to this instance.
Cloud Manager provides a mongo
command that you can useto connect to the MongoDB process.
Get the Host and Port for a MongoDB Process
1
In MongoDB Cloud Manager, go to the Deployment page for your project.
If it is not already displayed, select the organization thatcontains your desired project from the Organizations menu in thenavigation bar.
If it's not already displayed, select your desired projectfrom the Projects menu in the navigation bar.
If the Deployment page is notalready displayed, click Deployment in the sidebar.
The Deployment pagedisplays.
2
Go to the Processes page.
Click the Processes tab for your deployment.
The Processes pagedisplays.
3
Select the Clusters view for your deployment.
4
(Optional) For sharded clusters, filter which process type is listed.
The four buttons are listed in the following order, left to right:Shards, Configs, Mongos, andBIs.
Process | Displays |
---|---|
Shards | mongod processes that host your data. |
Configs | mongod processes that run as configservers to store a sharded cluster's metadata. |
Mongos | mongos processes that route data in a shardedcluster. |
BIs | BI processes that access datain a sharded cluster. |
5
On the line listing the process, click Metrics.
Cloud Manager displays the hostname and port of the process at the top of thecharts page.
Connect to a Deployment Using mongosh
Get the host and port using the previous procedure. From a shell, run mongosh
and specify thehost and port. For example:
mongosh --username <user> --password <pass> --host <host> --port <port>
Connect to a Deployment Using a MongoDB Driver
Get the host and port using the above procedure.See your driver's instructions forcreating a connection string thatspecifies the hostname and port.
For sharded clusters, you specify the hostname and port of themongos instance. For a replica set, you specify a seed list ofall hosts in the replica set. Your driver will automatically connect tothe primary. For example:
mongodb://[<username>:<password>@]hostname0<:port>[,hostname1:<port1>][,hostname2:<port2>][...][,hostnameN:<portN>]