Skip to content
Open Data Sync ↗

MongoDB

Data Sync reads MongoDB as a source, self-hosted or on Atlas: it backfills the collections you select, then streams every insert, update and delete from MongoDB's change streams. There is no MongoDB sink.

Source Change streams

Overview

A change stream is MongoDB's own ordered feed of changes, built on the replica set's operation log. Data Sync subscribes to it rather than polling collections, so each change is seen once and in order, and nothing is written into your database.

Before you connect

  1. Run a replica set or a sharded cluster. Change streams are not available on a standalone server. Every Atlas cluster qualifies; a self-hosted single node can be started as a one-member replica set.
  2. Size the oplog for outages. If Data Sync is stopped for longer than the oplog window, the changes it needs to resume from have been overwritten and the sync cannot pick up where it stopped.
  3. Create a user for Data Sync with the built-in read role on the database. It includes the find and changeStream actions Data Sync needs.
// a read-only user Data Sync can stream with db.getSiblingDB("admin").createUser({ user: "pulse", pwd: "…", roles: [{ role: "read", db: "shop" }] })

Connection fields

Set once, on the connection, in step 2 of the add-a-connection wizard. Give either a connection URI or a host and port.

FieldDefaultDescription
uriOptional—A full connection string, mongodb:// or mongodb+srv://. Atlas gives you one. Keep the password out of it and supply it in step 3 instead.
hostOptional—Hostname of a replica-set member, when you are not using a URI.
portOptional27017TCP port.
databaseOptional—The database to read from.
tls_ca_fileOptional—A CA certificate file used to verify the server's TLS certificate.

Credentials

Step 3 asks for a user and password. Both are optional in the form, because a server can run without authentication, but any server you replicate from should require them. Store them as a Blunox-managed secret or as a reference to your own secret store. See Connections.