MongoDB Basic Connection
  • 2 Minutes to read
  • Dark
    Light
  • PDF

MongoDB Basic Connection

  • Dark
    Light
  • PDF

Article summary

Establishing a Connection

  1. In Rivery, go to Connections - > New Connection .
  2. Search for MongoDB.
  3. Give a Name to your Connection.
  4. Set the Host , Port (Default: 27017), Authentication Database, Username, and Password.
  5. Enter Your URI.
  6. Test your credentials by pressing Test Connection.
  7. Save your connection.

image.png

URI Connection

This section describes the standard format of the MongoDB connection Uniform Resource Identifier (URI) used to connect to a MongoDB deployment: Standalone and Replica set.
For more information on configuring your URI, see the MongoDB URI Documentation.

You can set your URI Connection by selecting Edit, entering your URI, and then pressing the V icon.
Use the X option to reverse the modifications.
To reset the URI to the default form, press Reset.
image

Please Note:

  • MongoDB must be run on a Standalone or a Replica Set

    • If you're using a Replica Set, you'll need to add it in the connection URI; here's an example.
  • it's best to explicitly mention all nodes in the connection URI.

  • If you're using Log-Based with MongoDB Atlas, leave the analytics node out of the connection URI.

  • Connecting to Primary with MongoDB Atlas is supported. We'll be able to connect to the Analytics Node, but we won't be able to get any messages from it due to Atlas' implementation.


SSL (Optional)

A Secure Sockets Layer (SSL) certificate is a digital certificate that verifies identities and enables secure communication between servers.
Although the use of an SSL connection is optional, some Mongo database hosts may require an SSL certificate to validate and enable the connection.

You'll need to upload an SSL certificate, and you can use the Allow Invalid Certificate/Hostnames options to bypass hostname validation checks.

image.png


SSH (Optional)

Secure Shell Protocol (SSH) is used to provide secure and encrypted access to internal databases from Rivery servers in order to retrieve data.

Configure your SSH Tunnel server in your network to use SSH Tunneling via Rivery. This server will be able to connect to your database server via the internal IP or address, and will accept SSH connections from Rivery IPs. Rivery uses a key file to connect to the SSH server.

After you've set up SSH tunneling, you'll need to create a Seed List connection address:

MongoDB Seed List Connection Address:

MongoDB introduces the concept of a Seed List, which is specified using SRV and TXT records. When connecting to a MongoDB replica set, the client must specify at least one replica set member; this allows the client to connect to a replica set even if one of the nodes specified by the client is unavailable.
The use of SRV records eliminates the requirement for each client to provide a complete set of cluster state information. Instead, a single SRV record identifies all cluster nodes (along with their port numbers), and a TXT record defines the URI.
To create an SRV and TXT Records, refer to the MongoDB documentation

Now that you have a Seed List connection address:
image.png

Paste it into the Connection URI and fill out the SSH tunnel connection form to activate the Rivery SSH Tunnel Connection:

image.png

Please Note:

  • You will be unable to use an SSH Tunnel connection with more than one host unless you configure the SRV and TXT Records.

Was this article helpful?