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.
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
- 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.
- 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.
- Create a user for Data Sync with the built-in
readrole on the database. It includes thefindandchangeStreamactions Data Sync needs.
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.
| Field | Default | Description | |
|---|---|---|---|
uri | Optional | — | 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. |
host | Optional | — | Hostname of a replica-set member, when you are not using a URI. |
port | Optional | 27017 | TCP port. |
database | Optional | — | The database to read from. |
tls_ca_file | Optional | — | 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.