This page describes how to configure a MongoDB Atlas source database to work with Datastream using Private Service Connect interfaces. Note that the described procedure isn't a high availability solution. If the MongoDB node fails the connection profile test, you need to manually update the IP address in the Datastream connection profile.
Configure a MongoDB database user
To use Datastream with a MongoDB Atlas instance, you first need to create a database user and grant them access privileges:
- In the MongoDB Atlas dashboard, under Security, click Database access.
- Click New database user and select the password authentication method for your user.
- Enter the username and password for your Datastream user.
- Under Database user privileges, select Grant specific user privileges.
- Under Specific privileges, add the following role:
readAnyDatabase
- Click Add user.
Set up network configuration
Connect your Virtual Private Cloud networks across Datastream and MongoDB Atlas.
- Identify the central Virtual Private Cloud network in your Google Cloud project. Ensure that the IP address ranges of this network don't overlap with the IP address ranges of your Datastream or MongoDB Atlas networks.
- Create a private connectivity configuration to peer your Datastream network with your central Google Cloud Virtual Private Cloud network.
- Set up a network peering connection in MongoDB Atlas to peer your central Google Cloud Virtual Private Cloud network with your MongoDB Atlas network. Provide your project ID, the network name, subnet name, and endpoint name. For more information, see Set up a private endpoint for a dedicated cluster in MongoDB documentation.
Create the connection profile
After you configure your network, create a Datastream connection profile.
Go to the Connection profiles page in the Google Cloud Console.
Click Create profile and select MongoDB.
In the Hostname field, enter the IP address of the endpoint in the Connected endpoints section from the Private Service Connect page in Google Cloud.
In the Port field, enter
27017.Enter the username and password for your database user.
Add the
tlsandtls_allow_invalid_hostnameslabels and set their values totrue. For more information about setting labels, see Create a connection profile for a MongoDB database.Select Private connectivity as your connectivity method.
Select the private connectivity configuration that you created.
Click Create to save the connection profile.
Run a test to verify connection to your database.