Replicate MongoDB® Collections to SingleStore

Change Data Capture (CDC) pipelines enable you to ingest historical data and sync the continuous changes to data as they happen on the source MongoDB® database. SingleStore allows you to replicate your existing MongoDB® collections to your SingleStore Helios database using Change Data Capture (CDC). The CDC pipeline ingests data in the BSON format. You can perform the replication using any of the following methods:

To replicate data from MongoDB® using CDC via AWS PrivateLink, refer to Replicate MongoDB® Collections via AWS PrivateLink.

Prerequisites

Source Database Requirements

The replication feature uses MongoDB® change streams, and it works only with replica sets. A MongoDB® user must have the following roles (privileges) to replicate the collections in SingleStore:

  • Read the admin database for the operation log (oplog)

  • Read the config database in the configuration server

  • listDatabases privilege

  • Cluster-wide find and changeStream privileges

  • Write permission to the singlestore database. The singlestore database is automatically created during the replication process.

You can provide the privileges or assign roles to the MongoDB® user using the MongoDB® Atlas UI or MongoDB® commands. For example:

  • Using the UI for MongoDB® Atlas:

    1. On the MongoDB® Cloud dashboard, select Projects > <your_project>.

    2. In the left navigation pane, under Security, select Database Access.

    3. On the Database Users page, select Edit for the MongoDB® user used to connect to the MongoDB® instance.

    4. On the Edit User dialog, under Database User Privileges, select Specific Privileges > Add Specific Privilege.

    5. Add the following privileges:

      • readAnyDatabase

      • read for the config database

      • readWrite for the singlestore database

      Provide the readWrite privilege for the singlestore database to the user.
    6. Select Update User.

  • Using MongoDB® commands for self-managed deployments: The following commands create a role and then assign the role to a user.

    db.adminCommand({ createRole: 'cdcRole',
    privileges: [
    {'resource': {'cluster': true}, 'actions': ['find', 'changeStream']}
    ],
    roles: [
    {'role': 'read', 'db': 'admin'},
    {'role': 'read', 'db': 'local'},
    {'role': 'read', 'db': 'config'},
    {'role': 'readWrite', 'db': 'singlestore'}
    ]})
    db.adminCommand({ createUser: 'cdcUser',
    pwd: 's2mongoCDC12',
    roles: ['cdcRole']
    })

    Refer to Database Commands for more information.

Allow Access to the MongoDB® Instance

To allow SingleStore to connect to your MongoDB® instance (MongoDB® Atlas or self-managed deployment), allow incoming traffic from the outbound IP addresses of your SingleStore Helios workspace group.

Note

Allow all the outbound IP addresses.

  1. Copy the outbound IP address of your SingleStore Helios workspace.

    1. On the Cloud Portal, select Deployments > <your_workspace_group> > Firewall > Outbound.

    2. Copy all the IPs listed under IPs for Outbound Connections.

  2. Allow incoming traffic to the MongoDB® instance from the SingleStore Helios outbound IP addresses. Follow the instructions for your deployment:

Limitations

  • SingleStore does not support data replication using CDC pipelines from MongoDB® Atlas standalone or serverless instances. Replication is only supported for replica set deployments.

  • Because MongoDB® time series collections do not support change streams, they cannot be replicated in SingleStore using CDC. Refer to Time Series Collection Limitations for more information.

In this section

Last modified: September 11, 2024

Was this article helpful?