Navigation
This version of the documentation is archived and no longer supported. To learn how to upgrade your version of MongoDB Ops Manager, refer to the upgrade documentation.
You were redirected from a different version of the documentation. Click here to go back.

Connect to a MongoDB Process

Overview

To connect to a MongoDB instance, retrieve the hostname and port information from the Ops Manager console and then use a MongoDB client, such as the mongo shell or a MongoDB driver, to connect to the instance. You can connect to a cluster, replica set, or standalone.

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.

If your MongoDB instance runs on Amazon Web Services (AWS), then the security group associated with the AWS servers also affects access. AWS security groups control inbound and outbound traffic to their associated servers.

Procedures

Get the Connection Information for the MongoDB Instance

1

Select the Deployment tab and then the Deployment page.

2

Click view mode.

3

Click the process.

For a replica set, click the primary. For a sharded cluster, click the mongod.

Ops Manager displays the hostname and port of the process at the top of the charts page.

Connect to a Deployment Using the Mongo Shell

1

Select the Deployment tab and then the Deployment page.

2

Click view mode.

3

Click the process.

For a replica set, click the primary. For a sharded cluster, click the mongod.

Ops Manager displays the hostname and port of the process above the status charts.

4

On a system shell, run mongo and specify the host and port of the deployment.

Issue a command in the following form:

mongo --username <user> --password <pass> --host <host> --port <port>

Connect to a Deployment Using a MongoDB Driver

1

Select the Deployment tab and then the Deployment page.

2

Click view mode.

3

Click the process.

For a replica set, click the primary. For a sharded cluster, click the mongod.

Ops Manager displays the hostname and port of the process at the top of the charts on the page.

4

Connect from your driver.

Use your driver to create a connection string that specifies the hostname and port of the deployment. The connection string for your driver will resemble the following:

mongodb://[<username>:<password>@]hostname0<:port>[,hostname1:<port1>][,hostname2:<port2>][...][,hostnameN:<portN>]

If you specify a seed list of all hosts in a replica set in the connection string, your driver will automatically connect to the term:primary.

For standalone deployments, you will only specify a single host. For sharded clusters, only specify a single mongos instance.

Retrieve the Command to Connect Directly from the Process’s Server

1

Select the Deployment tab and then the Deployment page.

2

Click view mode.

3

Click the instance’s gear icon and select Connect to this Instance.

Ops Manager provides a mongo shell command that you can use to connect to the MongoDB process if you are connecting from the system where the deployment runs.