Two questions sit inside every MongoDB to Redshift project. What does a document look like once it is a row in a SQL warehouse? And how does an order that was edited an hour after the first copy ever get there?
A first attempt usually answers neither. A script exports the collection, COPY loads the file, and the edit shows up tomorrow, provided the whole table is reloaded.
These are the routes people usually take:
-
mongoexportto JSON, thenCOPY. You keep a script, a scheduler and a staging bucket. Freshness is hours to daily, and only full reloads are possible, so an update or a delete never arrives as a change. - AWS Database Migration Service (DMS) with its MongoDB source. Change data capture (CDC) through the oplog or change streams into native Redshift tables, in document mode or table mode. You run a replication instance and a task, plus a staging bucket in Amazon Simple Storage Service (S3).
- Debezium, Kafka and a Redshift sink. Changes land within seconds. The cost is Kafka, Kafka Connect, Debezium and one sink connector per collection, plus merge logic that you write.
- Managed extract, load, transform (ELT) services such as Fivetran, Estuary or Airbyte Cloud. Nothing to host, and minutes of lag depending on the plan. They charge per row, per GB or per connector for a second copy inside Redshift.
This tutorial takes another route. OLake Go, an open source (Apache 2.0) replication tool, follows the MongoDB change stream and commits each collection as an Apache Iceberg table in the AWS Glue Data Catalog, with the files in a bucket you own. Redshift maps the Glue database onto an external schema and queries the tables where they sit, and Athena and DuckDB read the same files.
I ran every step on 2026-10-30 against MongoDB 7 as a single-node replica set in Docker, OLake Go v1.1.0 and a Redshift Serverless workgroup at 8 Redshift Processing Units (RPU) in ap-southeast-1. The first sync took 14 seconds and the change sync 11 seconds. Every figure below is from that run.
You need: MongoDB 4.0 or later as a replica set (self-hosted or Atlas), an AWS account where you can create a bucket and Identity and Access Management (IAM) entities, Redshift Serverless or an RA3 cluster, Docker, and about 40 minutes.
Step 1: A replica set, a user and two collections
OLake Go reads changes through a change stream, which MongoDB offers only in replica set mode. One member is enough, and that is what I used. Launch mongod with --replSet rs0, connect with mongosh and run:
// 1. A single-node replica set (self-hosted only) rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "<host>:27017" }] }) // 2. A user for OLake Go use admin db.createUser({ user: "olake", pwd: "<password>", roles: [{ role: "read", db: "shop" }, { role: "clusterMonitor", db: "admin" }] }) // 3. The oplog size in bytes; raise it with replSetResizeOplog if it is small use local db.oplog.rs.stats().maxSize read lets OLake Go copy the collections. The change stream needs oplog access on top, and clusterMonitor grants it (readAnyDatabase does too).
Confirm the result:
rs.status().members.map(m => m.stateStr) // one PRIMARY db.getSiblingDB("admin").getUsers().users.map(u => u.user) Next, some data. The script below rebuilds the two collections from my run: 8 customers and 40 orders, with integer _id keys and the order amount stored as NumberDecimal. Skip it if you are pointing at collections you already have.
use shop const now = new Date(); const people = [ ['Aarav Mehta', 'aarav', 'Mumbai', 'gold'], ['Priya Sharma', 'priya', 'Bengaluru', 'silver'], ['Liam Carter', 'liam', 'Austin', 'bronze'], ['Sofia Rossi', 'sofia', 'Milan', 'gold'], ['Kenji Tanaka', 'kenji', 'Tokyo', 'silver'], ['Emma Schulz', 'emma', 'Berlin', 'bronze'], ['Noah Kim', 'noah', 'Seoul', 'gold'], ['Zara Ali', 'zara', 'Dubai', 'silver'] ]; db.customers.insertMany(people.map(([name, handle, city, tier], i) => ({ _id: i + 1, name, email: handle + '@example.com', city, tier, created_at: now, updated_at: now }))); const products = ['Laptop', 'Headphones', 'Monitor', 'Keyboard', 'Mouse', 'Webcam']; const statuses = ['placed', 'shipped', 'delivered']; db.orders.insertMany(Array.from({ length: 40 }, (_, k) => { const n = k + 1; return { _id: n, customer_id: 1 + (n % 8), product: products[n % 6], amount: NumberDecimal(((2000 + (n * 7919) % 120000) / 100).toFixed(2)), status: statuses[n % 3], created_at: now, updated_at: now }; })); On Atlas the replica set already exists. Create the user under Database Access with the same two roles, and allow OLake Go's IP under Network Access.
⚠️ The oplog is your replay window. Atlas and most self-hosted installs keep 24 hours or less by default, and a job paused past the window has to take a fresh snapshot.
Step 2: A bucket, a writer and a reader on AWS
Create an S3 bucket in the region where your Redshift workgroup or cluster runs. Mine was in ap-southeast-1.
OLake Go writes with its own identity. I gave it a scoped IAM user with this inline policy; swap in your bucket, region and account:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["s3:ListBucket", "s3:GetBucketLocation"], "Resource": "arn:aws:s3:::<bucket>" }, { "Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts"], "Resource": "arn:aws:s3:::<bucket>/*" }, { "Effect": "Allow", "Action": ["glue:GetDatabase", "glue:GetDatabases", "glue:CreateDatabase", "glue:GetTable", "glue:GetTables", "glue:CreateTable", "glue:UpdateTable", "glue:DeleteTable"], "Resource": ["arn:aws:glue:<region>:<account>:catalog", "arn:aws:glue:<region>:<account>:database/*", "arn:aws:glue:<region>:<account>:table/*/*"] } ] } Redshift reads with a different identity: an IAM role attached to the Serverless namespace or the cluster. In my run that role carried AmazonS3ReadOnlyAccess plus read access to Glue.
Do not create a Glue database. OLake Go makes one per job on the first sync.
Step 3: Start OLake UI and connect MongoDB
curl -sSL https://raw.githubusercontent.com/datazip-inc/olake-ui/master/docker-compose-v1.yml | docker compose -f - up -d Open http://localhost:8000 and log in as admin with the password password.
Go to Sources, click Create Source and choose MongoDB. Under Change data capture (CDC), leave Enable CDC switched on.
Under Connection details, enter the host as host:port, the Database Name, the Auth DB, the username and password, and the Replica Set name. MongoDB sat in a separate container in my run, so I entered host.docker.internal:27017, shop, admin, olake and rs0. Leave Read Preference on primary.
Click Set up source. Before anything is saved, OLake Go tests the connection, checks that it can open a change stream and reports the oplog window. A window shorter than 7 days is flagged as a warning and does not block you.
Step 4: Add the Glue destination
Go to Destinations and click Create Destination. Choose Apache Iceberg as the connector and AWS Glue as the catalog type.
Three things go in the form: the S3 path OLake Go should write under, the AWS region of the bucket and the Glue catalog, and the access key pair of the writer user from step 2. If OLake Go runs on an instance that has a role, leave the two key fields empty. Click Create.
Step 5: Create the job and run the first sync
Go to Jobs and click Create Job. Name it mongodb_to_redshift, give it a schedule (Every Day at a fixed hour, or a cron expression), and select the source and destination you just made. The schedule sets how often the change stream is drained, and the full copy happens only once.
One setting needs a manual choice. Redshift is not in OLake Go's Target Query Engines list yet, so under Advanced Settings pick AWS Athena and DuckDB instead.
Click Next, and OLake Go discovers the collections and opens the Streams page. Tick customers and orders, set the sync mode to Full Refresh + CDC and the ingestion mode to Upsert. Then set Upsert Type to Positional Deletes, because that is the delete format Redshift reads, and Athena and DuckDB read it as well.
Click Create Job, open the job's menu and choose Sync Now.
My first sync copied 8 customers and 40 orders, 48 documents and 6.40 KB in total, in 14 seconds with container start included.
OLake Go named the Glue database mongodb_to_redshift_shop, after the job and the source database. To use a different name, edit the Iceberg DB field at the top of the Streams page before the first sync.
Step 6: One external schema in Redshift
Open query editor v2. Run the first statement once, after the first sync and in the same region as the Glue database:
CREATE EXTERNAL SCHEMA lakehouse FROM DATA CATALOG DATABASE 'mongodb_to_redshift_shop' IAM_ROLE default; SELECT _id, name, city, tier FROM lakehouse.customers ORDER BY _id; SELECT status, count(*) AS n, sum(cast(amount AS decimal(12,2))) AS total FROM lakehouse.orders GROUP BY status ORDER BY status; IAM_ROLE default picks the default role of the namespace or cluster. Name a specific role instead if you keep several.
The key column is _id, the same as in MongoDB. The roll-up casts amount because a Decimal128 field reaches Redshift as text, and a plain sum(amount) fails with ERROR: function sum(character varying) does not exist.
Step 7: Edit documents and sync again
Now the part a nightly export cannot do. Make 12 changes in mongosh, 7 inserts and 5 updates:
const now = new Date(); db.customers.insertMany([ { _id: 9, name: 'Maya Patel', email: 'maya@example.com', city: 'Pune', tier: 'silver', created_at: now, updated_at: now }, { _id: 10, name: 'Lucas Silva', email: 'lucas@example.com', city: 'São Paulo', tier: 'bronze', created_at: now, updated_at: now } ]); db.orders.insertMany([ { _id: 41, customer_id: 9, product: 'Laptop', amount: NumberDecimal('1299.00'), status: 'placed', created_at: now, updated_at: now }, { _id: 42, customer_id: 9, product: 'Mouse', amount: NumberDecimal('25.50'), status: 'placed', created_at: now, updated_at: now }, { _id: 43, customer_id: 10, product: 'Monitor', amount: NumberDecimal('349.99'), status: 'placed', created_at: now, updated_at: now }, { _id: 44, customer_id: 3, product: 'Keyboard', amount: NumberDecimal('89.00'), status: 'placed', created_at: now, updated_at: now }, { _id: 45, customer_id: 7, product: 'Webcam', amount: NumberDecimal('79.90'), status: 'placed', created_at: now, updated_at: now } ]); db.customers.updateOne({ name: 'Liam Carter' }, { $set: { tier: 'gold', updated_at: now } }); db.customers.updateOne({ name: 'Zara Ali' }, { $set: { city: 'Abu Dhabi', updated_at: now } }); db.orders.updateMany({ _id: { $in: [1, 4, 7] } }, { $set: { status: 'delivered', updated_at: now } }); Choose Sync Now again. The second sync read 12 change events (1.60 KB) from the stream and was done in 11 seconds end to end.
For customers, OLake Go wrote one new data file holding 4 rows: the 2 inserts and the new versions of the 2 updated documents. A small positional delete file retires the 2 old versions. The sync log's commit report shows the same numbers: addedDataFiles=1, addedRecords=4, addedPositionalDeleteFiles=1, addedPositionalDeletes=2.
orders follows the same pattern with 8 rows and 3 deletes.
Back in Redshift, rerun the customers query. There is no refresh and no ALTER TABLE to run first. I got 10 rows, one per key: Liam Carter on gold, Zara Ali in Abu Dhabi, and the two new customers.
Add _op_type to the select list to see how each row arrived: r for the snapshot, c for an insert, u for an update and d for a delete.
Athena and DuckDB on the same files
Nothing is exported for this. Athena shows mongodb_to_redshift_shop in its database list, with no registration and no refresh. Pick a workgroup that has a query result location in S3 and run:
SELECT _id, name, city, tier FROM mongodb_to_redshift_shop.customers ORDER BY _id; Athena returned the same 10 customers and scanned 0.76 KB.
DuckDB reads each table from its current metadata file, and Glue knows where that file is:
aws glue get-table --database-name mongodb_to_redshift_shop --name customers \ --query 'Table.Parameters.metadata_location' --output text INSTALL iceberg; LOAD iceberg; INSTALL httpfs; LOAD httpfs; CREATE SECRET lake (TYPE s3, KEY_ID '<access key>', SECRET '<secret key>', REGION '<region>'); SELECT _id, name, city, tier FROM iceberg_scan('<metadata_location from the command above>') ORDER BY _id; Each sync writes a new metadata file, so fetch the location again before a fresh read. DuckDB 1.5.5 gave me the same 10 customers.
The orders roll-up matched MongoDB to the cent in all three engines: 16 delivered orders for 8659.68, 18 placed for 10522.26 and 11 shipped for 6397.25.
Tips and limits
- This is not native Redshift speed. The external schema goes through Redshift Spectrum, which reads Parquet from S3 on every query. For a hot dashboard, load the hot slice into a native table on a schedule and keep the Iceberg tables as the source.
- Flattening stops at one level. Nested objects and arrays land as JSON text in one
VARCHARcolumn, which you unpack withJSON_PARSEorjson_extract_path_text. If every query would start that way, aSUPERcolumn in a native Redshift table may serve you better. - Two type surprises. A
datebecomes aTIMESTAMPin Coordinated Universal Time (UTC), and anObjectIdkey arrives as its 24-character hex string. Store doubles in MongoDB if you want money as a numeric column without the cast. - A new field becomes a new column on the next sync, with nulls for older rows. A field whose type changes in an incompatible way fails the sync instead of corrupting the table.
- The oplog is sized in gigabytes, not hours. A write-heavy day shortens the window, so check it after a busy day and resize before a planned pause.
- Freshness is a schedule, down to one minute.
- The external schema is read-only.
INSERTorDELETEon these tables fails.
MongoDB to Redshift methods compared
| Method | Freshness | Updates and deletes | Where the data lands | What you run |
|---|---|---|---|---|
mongoexport, then COPY | hours to daily | no, full reloads only | native Redshift tables | a script, a scheduler, a staging bucket |
| AWS DMS | CDC through the oplog or change streams | yes | native Redshift tables, document or table mode | a replication instance and task, plus a staging bucket |
| Debezium, Kafka, Redshift sink | seconds | yes, with your own merge logic | Kafka topics, then Redshift tables | Kafka, Kafka Connect, Debezium, a sink per collection |
| Fivetran, Estuary, Airbyte Cloud | minutes, by plan | varies by tool | Redshift tables, as a second copy | nothing; per row, per GB or per connector |
| OLake Go to Glue (this post) | CDC on a schedule, down to one minute | yes, as Iceberg row-level deletes | Iceberg tables for Redshift, Athena, Spark and DuckDB | one Docker Compose stack, your bucket and compute |
If you are already on AWS and Redshift will be the only reader, DMS is the simpler choice. The route above earns its setup when Athena, Spark or a notebook will read those rows too, or when you want to own the files.
FAQ
Can I run the pipeline without the UI?
Yes. The same job runs from the olakego/source-mongodb:latest image with a discover command and a sync command. In selected_streams.json, set sync_mode to cdc and update_type to pos, and give the container a persistent directory through OLAKE_INDEX_DB_DIR, because positional deletes keep a small index between runs.
What do I pay Redshift for in this setup?
Redshift Serverless bills RPU-hours only while queries run. Each query on the external schema scans Parquet files in S3, so select only the columns you need. The files are billed at S3 rates.
Who cleans up the small files each sync leaves behind?
Not Glue, which has no built-in compaction for tables written by external engines. OLake Fusion does it for the catalogs OLake Go writes to, and Spark's rewrite_data_files works through the same Glue catalog.
Where to go from here
- Point the source at your own collections. On Atlas, the source form takes one SRV host with Use SRV turned on.
- Give the job a schedule that is shorter than your oplog window.
- The full guide has the command line configuration, the complete data type table and the troubleshooting list: MongoDB to Redshift on olake.io.
If a step behaves differently on your setup, leave the error text in a comment and I will update the tutorial.







