Docs Menu

Docs HomeMongoDB Ops Manager

Connect to a MongoDB Process

On this page

  • Overview
  • Firewall Rules
  • Procedures

To connect to a MongoDB, retrieve the hostname and port information from Ops Manager and then use a MongoDB client, such as mongosh or a MongoDB driver, to connect. To connect to a cluster, retrieve the hostname and port for the mongos process. To connect to a replica set or standalone process, retrieve the hostname and port for the mongod processes.

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, see the firewall information in the Network Security document in the MongoDB manual.

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.

You can retrieve a shell command for connecting to your MongoDB instance, or you can retrieve the host and port number of a specific MongoDB process and create your own command for connecting using either shell or MongoDB driver.

1
  1. If it is not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it is not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. If it is not already displayed, click Deployment in the sidebar.

  1. Click the Clusters view.

2

Ops Manager provides a mongo command that you can use to connect to the MongoDB process.

1
  1. If it is not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it is not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. If it is not already displayed, click Deployment in the sidebar.

  1. Click the Clusters view.

2

The four buttons are listed in the following order, left to right: Shards, Configs, Mongos, and BIs.

Process
Displays
Shards
mongod processes that host your data.
Configs
mongod processes that run as config servers to store a sharded cluster's metadata.
Mongos
mongos processes that route data in a sharded cluster.
BIs
BI processes that access data in a sharded cluster.
3

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

Get the host and port using the previous procedure. From a shell, run mongosh and specify the host and port. For example:

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

Get the host and port using the above procedure. See your driver's instructions for creating a connection string that specifies the hostname and port.

For sharded clusters, you specify the hostname and port of the mongos instance. For a replica set, you specify a seed list of all hosts in the replica set. Your driver will automatically connect to the primary. For example:

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

Tip

See also:

←  Deploy a BI ConnectorData Explorer →