{"id":69130,"plugin_id":"plugin_asdk_app_6ae160c3d9e48191aaeffd03cc5ef09d","kind":"skill","collection_source":"plugin_package","comparison_source":null,"observed_at":"2026-10-28T18:07:03.913Z","digest":"3e0b45f9c732de5304a4e0acaef40580c018f93fcb927627251ab022612b1093","against":null,"payload":{"description":"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.","included_files":[{"relative_path":"references/flags.md","size_in_bytes":2869}],"name":"molt-replicator","skill_md_contents":"---\nname: molt-replicator\ndescription: 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.\ncompatibility: Requires separate replicator binary (not part of molt). Staging CockroachDB database required. Source DB must support logical replication.\n---\n\n# molt replicator\n\nContinuous change-data-capture (CDC) replication from source databases to CockroachDB. Run **after** `molt fetch` completes the initial bulk load.\n\n> **Important**: replicator is a **separate binary** from `molt`. It is not invoked by `molt fetch`. The `data-load-and-replication` mode in molt fetch is deprecated — use replicator directly instead.\n\n## Architecture\n\n```\nSource DB ──► [replicator] ──► Staging DB (_replicator schema) ──► Target CockroachDB\n                  ▲\n            Publication/\n            Slot/BinLog/\n            LogMiner\n```\n\nReplicator reads changes from the source, buffers them in a staging schema on the target CRDB cluster, and applies them to the target tables.\n\n## Subcommands by Source\n\n| Source | Command |\n|--------|---------|\n| PostgreSQL | `replicator pglogical` |\n| MySQL | `replicator mylogical` |\n| Oracle | `replicator oraclelogminer` |\n| Kafka | `replicator kafka` |\n| Cloud storage | `replicator objstore` |\n| CockroachDB CDC | `replicator start` |\n\n## Full Fetch → Replicator Workflow\n\n### Step 1: Initial bulk load with molt fetch\n\n`drop-on-target-and-recreate` drops any existing target tables first; run this only against a fresh or empty target.\n\n```bash\nmolt fetch \\\n  --source \"postgresql://<user>:<password>@source:5432/db\" \\\n  --target \"postgresql://root@crdb:26257/db\" \\\n  --bucket-path \"s3://mybucket/migration\" \\\n  --table-handling drop-on-target-and-recreate\n```\n\n### Step 2: Create publication on source (PostgreSQL)\n\n```sql\n-- Run on source PostgreSQL:\nCREATE PUBLICATION molt_fetch FOR ALL TABLES;\n-- (molt fetch may have already created this; check first)\n```\n\n### Step 3: Create staging database on target\n\n```sql\n-- Run on target CockroachDB:\nCREATE DATABASE _replicator;\n```\n\n### Step 4: Test connectivity\n\n```bash\n# preflight only takes --stagingConn and --targetConn (always required for the\n# target; stagingConn required if the target is not CRDB)\nreplicator preflight \\\n  --stagingConn \"postgresql://root@crdb:26257/_replicator\" \\\n  --targetConn \"postgresql://root@crdb:26257/db\"\n```\n\n### Step 5: Start replicator\n\n```bash\nreplicator pglogical \\\n  --publicationName \"molt_fetch\" \\\n  --sourceConn \"postgresql://<user>:<password>@source:5432/db\" \\\n  --stagingConn \"postgresql://root@crdb:26257/_replicator\" \\\n  --stagingSchema \"_replicator.public\" \\\n  --targetConn \"postgresql://root@crdb:26257/db\" \\\n  --targetSchema \"public\" \\\n  --metricsAddr \"0.0.0.0:8080\"\n```\n\n### Step 6: Monitor lag\n\n```bash\ncurl http://localhost:8080/metrics | grep replicator_\n# Watch for: mutations applied, unapplied mutations, lag\n```\n\n### Step 7: Cutover\n\n1. When lag reaches ~0, redirect app writes to CockroachDB\n2. Let replicator drain remaining changes\n3. Confirm no new writes on source\n4. Stop replicator\n5. Decommission the source only after `molt verify` passes and a source backup is confirmed\n\n## Source-Specific Setup\n\n### PostgreSQL (pglogical)\n\n**Source prerequisites:**\n- User with `REPLICATION` privilege\n- Logical replication enabled (`wal_level = logical`)\n- Publication exists (created by `molt fetch` or manually)\n\n```bash\nreplicator pglogical \\\n  --publicationName \"molt_fetch\" \\\n  --slotName \"replicator\" \\\n  --sourceConn \"postgresql://...\" \\\n  --stagingConn \"postgresql://root@crdb:26257/_replicator\" \\\n  --stagingSchema \"_replicator.public\" \\\n  --targetConn \"postgresql://root@crdb:26257/db\" \\\n  --targetSchema \"public\"\n```\n\n### MySQL (mylogical)\n\n**Source prerequisites:**\n- Binary logging enabled (`binlog_format = ROW`)\n- GTID mode on (`gtid_mode=ON`, `enforce_gtid_consistency=ON`)\n- User with `REPLICATION CLIENT` privilege\n\n```bash\nreplicator mylogical \\\n  --sourceConn \"mysql://<user>:<password>@source:3306/db\" \\\n  --stagingConn \"postgresql://root@crdb:26257/_replicator\" \\\n  --stagingSchema \"_replicator.public\" \\\n  --targetConn \"postgresql://root@crdb:26257/db\" \\\n  --targetSchema \"public\"\n```\n\n### Oracle (oraclelogminer)\n\n**Source prerequisites:**\n- Archive log mode enabled\n- Supplemental logging enabled\n- LogMiner permissions granted\n\n```bash\nreplicator oraclelogminer \\\n  --sourceConn \"oracle://<user>:<password>@oracle:1521/db\" \\\n  --stagingConn \"postgresql://root@crdb:26257/_replicator\" \\\n  --stagingSchema \"_replicator.public\" \\\n  --targetConn \"postgresql://root@crdb:26257/db\" \\\n  --targetSchema \"public\"\n```\n\n## Key Flags\n\n```bash\n# Performance\n--parallelism 16          # concurrent DB transactions (default: 16)\n--flushSize 1000          # rows per batch (default: 1000)\n--flushPeriod 1s          # flush interval (default: 1s)\n\n# Staging connection pool\n--stagingMaxPoolSize 128\n--stagingIdleTime 1m\n--stagingMaxLifetime 5m\n\n# Target connection pool\n--targetMaxPoolSize 128\n--targetStatementCacheSize 128\n\n# Retry\n--maxRetries 10\n--retryInitialBackoff 25ms\n--retryMaxBackoff 2s\n\n# Monitoring\n--metricsAddr \"0.0.0.0:8080\"    # Prometheus metrics endpoint\n--schemaRefresh 1m               # refresh schema cache (0 = disabled)\n\n# Dead letter queue (failed rows instead of stopping)\n--dlqTableName \"replicator_dlq\"\n\n# Logging\n-v                               # debug\n-vv                              # trace\n--logFormat fluent                # for log aggregators\n--logDestination \"/var/log/replicator.log\"\n```\n\n## Gotchas\n\n- Staging schema (`_replicator.public`) is auto-created by replicator, but the **database** (`_replicator`) must exist first\n- `--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.\n- DLQ table grows over time — monitor and purge failed rows periodically\n- Replicator holds an open replication slot on the source — this blocks WAL cleanup; monitor source disk usage\n- Graceful shutdown respects `--gracePeriod` (default: 30s); don't SIGKILL without it\n- No built-in alerting — set up external alerts on the Prometheus metrics endpoint\n- Long cutover windows increase replication lag — plan for a maintenance window if needed\n\nSee [flags reference](references/flags.md) for the full flag list.\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}