- 3 Minutes to read
- Print
- DarkLight
- PDF
MongoDB Change Streams Connection
- 3 Minutes to read
- Print
- DarkLight
- PDF
Prerequisites
Versions 4.0 and higher of MongoDB must be installed.
For the following versions, make sure the Read Preference is set to Primary:
Version Set the Read Preference to Primary 4.0 Required 4.1 Required 4.2 + Recommended
Connecting to MongoDB with AWS DocumentDB and Log-Based is currently not supported
Connection Procedure
- In Rivery, go to Connections - > New Connection .
- Search for MongoDB.
- Give a Name to your Connection.
- Set the Host , Port (Default: 27017), Authentication Database , Username , and Password
- Enter Your URI.
- Test your credentials by pressing Test Connection.
- Save your connection.
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.
Please Note:
MongoDB must be run on a Single Node Cluster or a Replica Set.
- If you're using a Replica Set, you'll need to add it in the connection URI with readPreference=Primary; 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.
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:
Paste it into the Connection URI and fill out the SSH tunnel connection form to activate the Rivery SSH Tunnel Connection:
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.
If you're using Atlas with Log-Based, employ Private Endpoint to connect to several hosts.