Connect to MongoDB¶
Note
This connector is subject to the Snowflake Connector Terms.
This topic describes how to configure the source MongoDB database and the target Snowflake account for the Openflow Connector for MongoDB.
Set up the source MongoDB database¶
The connector requires a MongoDB deployment running as either a Replica Set or a Sharded Cluster. This architecture ensures high availability and enables the use of Change Streams, which the connector uses to track and sync data changes in real time.
To configure the MongoDB environment, perform the following steps:
-
Configure a basic Replica Set.
Ensure all nodes have the same
replSetNamein theirmongod.confas shown in the following example: -
Initialize the replica set.
Run this command in the
mongoshconsole. In this example, the replica set consists of two nodes: -
Create a dedicated database user.
The connector opens a cluster-level Change Stream, which requires the
readAnyDatabaserole on theadmindatabase. Create the user with the following role by running the following command in themongoshconsole:Note
The
readAnyDatabaserole is required because the connector currently monitors change events at the cluster level. Database-scoped Change Stream support, which would allow a narrowerreadrole on a specific database, is not currently supported.When configuring the connector, set MongoDB Authentication Source to
admin. For more information, see MongoDB source parameters.
Set up the target Snowflake account¶
To set up the target Snowflake account, perform the following steps:
-
Create a Snowflake user.
Create a Snowflake user with the type as SERVICE.
Store the private key for that user in a file to supply to the connector’s configuration. For more information, see key-pair authentication.
-
Create a database.
Create a database that stores the replicated data, and set up permissions for the Snowflake user to create objects in that database by granting USAGE and CREATE SCHEMA privileges.
-
Create a new warehouse or use an existing warehouse for the connector.
To create a new warehouse, perform the following steps:
- Start with the MEDIUM warehouse size, then experiment with size depending on the number of tables being replicated and the amount of data transferred.
- To determine if you should increase, monitor the connector and database while data replication is in progress. If you observe significant delays during incremental replication, experiment with a larger warehouse size. However, large table numbers typically scale better using multi-cluster warehouses instead of increasing the warehouse size.
Next steps¶
After setting up the source MongoDB database and the target Snowflake account, Set up the connector.