npx skills add ...
npx skills add cockroachlabs/cockroachdb-skills --skill molt-replicator
Guide for using the CockroachDB replicator to continuously replicate changes from PostgreSQL, MySQL, or Oracle to CockroachDB after an initial molt fetch data load. Use when setting up CDC replication, configuring pglogical/mylogical/oraclelogminer, or managing the fetch → replicator cutover workflow.
npx skills add cockroachlabs/cockroachdb-skills --skill molt-replicator
Continuous change-data-capture (CDC) replication from source databases to CockroachDB. Run after molt fetch completes the initial bulk load.
Important: replicator is a separate binary from
molt. It is not invoked bymolt fetch. Thedata-load-and-replicationmode in molt fetch is deprecated — use replicator directly instead.
Replicator reads changes from the source, buffers them in a staging schema on the target CRDB cluster, and applies them to the target tables.
| Source | Command |
|---|---|
| PostgreSQL | replicator pglogical |
| MySQL | replicator mylogical |
| Oracle | replicator oraclelogminer |
| Kafka | replicator kafka |
| Cloud storage | replicator objstore |
| CockroachDB CDC | replicator start |
drop-on-target-and-recreate drops any existing target tables first; run this only against a fresh or empty target.
molt verify passes and a source backup is confirmedSource prerequisites:
REPLICATION privilegewal_level = logical)molt fetch or manually)Source prerequisites:
binlog_format = ROW)gtid_mode=ON, enforce_gtid_consistency=ON)REPLICATION CLIENT privilegeSource prerequisites:
_replicator.public) is auto-created by replicator, but the database (_replicator) must exist first--publicationName and --slotName must match what molt fetch created. molt fetch's --pglogical-publication-name defaults to molt_fetch and its --pglogical-replication-slot-name has no default; on the replicator side, --publicationName has no default and --slotName defaults to replicator. If the names don't line up, set both explicitly on both sides.--gracePeriod (default: 30s); don't SIGKILL without itSee flags reference for the full flag list.
-- Run on source PostgreSQL:
CREATE PUBLICATION molt_fetch FOR ALL TABLES;
-- (molt fetch may have already created this; check first)-- Run on target CockroachDB:
CREATE DATABASE _replicator;# preflight only takes --stagingConn and --targetConn (always required for the
# target; stagingConn required if the target is not CRDB)
replicator preflight \
--stagingConn "postgresql://root@crdb:26257/_replicator" \
--targetConn "postgresql://root@crdb:26257/db"replicator pglogical \
--publicationName "molt_fetch" \
--sourceConn "postgresql://<user>:<password>@source:5432/db" \
--stagingConn "postgresql://root@crdb:26257/_replicator" \
--stagingSchema "_replicator.public" \
--targetConn "postgresql://root@crdb:26257/db" \
--targetSchema "public" \
--metricsAddr "0.0.0.0:8080"curl http://localhost:8080/metrics | grep replicator_
# Watch for: mutations applied, unapplied mutations, lagreplicator pglogical \
--publicationName "molt_fetch" \
--slotName "replicator" \
--sourceConn "postgresql://..." \
--stagingConn "postgresql://root@crdb:26257/_replicator" \
--stagingSchema "_replicator.public" \
--targetConn "postgresql://root@crdb:26257/db" \
--targetSchema "public"replicator mylogical \
--sourceConn "mysql://<user>:<password>@source:3306/db" \
--stagingConn "postgresql://root@crdb:26257/_replicator" \
--stagingSchema "_replicator.public" \
--targetConn "postgresql://root@crdb:26257/db" \
--targetSchema "public"replicator oraclelogminer \
--sourceConn "oracle://<user>:<password>@oracle:1521/db" \
--stagingConn "postgresql://root@crdb:26257/_replicator" \
--stagingSchema "_replicator.public" \
--targetConn "postgresql://root@crdb:26257/db" \
--targetSchema "public"# Performance
--parallelism 16 # concurrent DB transactions (default: 16)
--flushSize 1000 # rows per batch (default: 1000)
--flushPeriod 1s # flush interval (default: 1s)
# Staging connection pool
--stagingMaxPoolSize 128
--stagingIdleTime 1m
--stagingMaxLifetime 5m
# Target connection pool
--targetMaxPoolSize 128
--targetStatementCacheSize 128
# Retry
--maxRetries 10
--retryInitialBackoff 25ms
--retryMaxBackoff 2s
# Monitoring
--metricsAddr "0.0.0.0:8080" # Prometheus metrics endpoint
--schemaRefresh 1m # refresh schema cache (0 = disabled)
# Dead letter queue (failed rows instead of stopping)
--dlqTableName "replicator_dlq"
# Logging
-v # debug
-vv # trace
--logFormat fluent # for log aggregators
--logDestination "/var/log/replicator.log"