Molt Fetch

作者 cockroachdb6c96c6394a61無授權條款4 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫2 個月前更新

Guide for using molt fetch to migrate data from PostgreSQL, MySQL, Oracle, or MSSQL to CockroachDB. Use when running molt fetch commands, configuring storage backends, handling fetch failures/resumption, or chaining fetch with verify.

僅含說明DevOps & Cloud
AI 產生的概覽

指導使用 molt fetch 將 PostgreSQL、MySQL、Oracle 或 MSSQL 資料大量遷移到 CockroachDB。

功能
此技能是 molt fetch 指令的使用指南,用於將 PostgreSQL、MySQL、Oracle 或 MSSQL 的資料大量遷移到 CockroachDB。內容涵蓋指令結構、儲存後端選項、資料表處理模式、匯入模式、關鍵參數、各資料來源的前置條件、續傳流程以及錯誤復原。產出的是操作指引與範例指令,而非檔案或程式碼。
適用情境
適用於執行 molt fetch 指令、選擇儲存後端、設定資料表處理或匯入模式、在遷移失敗後續傳,以及將 fetch 與 verify 串接執行的情境。
執行需求
需要 molt 二進位檔,並能連線來源資料庫與 CockroachDB 目標端。Oracle 資料來源另需 CGO 與 Oracle Instant Client;雲端儲存後端需要憑證或隱式驗證。不含指令碼,僅提供一份參數參考文件。

molt fetch

Bulk data migration from source databases (PostgreSQL, MySQL, Oracle, MSSQL) to CockroachDB.

Basic Structure

bash
molt fetch \  --source "<source-conn>" \  --target "<crdb-conn>" \  --bucket-path "s3://bucket/prefix"   # or --direct-copy or --local-path  [options]

Storage Backends (pick one)

OptionWhen to use
--bucket-path "s3://..."AWS S3 (also gs:// for GCS, azure:// for Azure)
--direct-copyNo intermediate storage; fastest for accessible networks
--local-path "/tmp/molt" + --local-path-listen-addr "0.0.0.0:9005"CRDB must reach the listen addr

Cloud auth: pass --use-implicit-auth for IAM/ADC/managed identity, or set AWS_ACCESS_KEY_ID/GOOGLE_APPLICATION_CREDENTIALS env vars.

Table Handling (--table-handling)

ValueBehavior
none (default)Append to existing tables
drop-on-target-and-recreateDrop + recreate from source schema; enables auto schema creation. Destroys existing target tables and their data, so use only on fresh or empty targets
truncate-if-existsTruncate before loading; errors if table missing

Import Mode

IMPORT INTO (default): Table goes OFFLINE during load. Highest throughput.

COPY FROM (--use-copy): Table stays ONLINE. Use with --direct-copy. Cannot use compression.

bash
# Zero-downtime loadmolt fetch --source "..." --target "..." --direct-copy --use-copy

Key Flags

bash
# Filtering--table-filter "customers|orders"      # POSIX regex for tables to include--table-exclusion-filter "temp_.*"     # exclude pattern--schema-filter "public"               # PostgreSQL only
# Performance--table-concurrency 4                  # parallel tables (default: 4)--export-concurrency 4                 # export threads (default: 4)--row-batch-size 100000                # rows per SELECT (default: 100k)
# Schema--type-map-file "types.json"           # custom type mappings--transformations-file "transforms.json"  # column exclusions, table aliases
# Logging--log-file "migration.log"             # or "stdout"--logging debug                        # info (default), debug, trace--metrics-listen-addr "0.0.0.0:3030"  # Prometheus scrape endpoint

Source-Specific Prerequisites

MySQL: GTID mode required (gtid_mode=ON, enforce_gtid_consistency=ON). ONLY_FULL_GROUP_BY must be off. Or use --ignore-replication-check.

Oracle: Binary must be built with CGO_ENABLED=1 -tags="cgo source_all". Oracle Instant Client in LD_LIBRARY_PATH.

PostgreSQL: Replication privileges needed, or --ignore-replication-check.

Common Workflows

1. Full migration with schema creation

drop-on-target-and-recreate drops any existing target tables first; run this only against a fresh or empty target.

bash
molt fetch \  --source "postgresql://<user>:<password>@pg:5432/db" \  --target "postgresql://root@crdb:26257/db" \  --bucket-path "s3://mybucket/migration" \  --table-handling drop-on-target-and-recreate \  --table-filter "customers|orders|payments" \  --log-file migration.log

2. Resume after failure

bash
# List available continuation tokensmolt fetch tokens --fetch-id "abc-123" --target "postgresql://root@crdb:26257/db"
# Resume all failed tablesmolt fetch \  --source "..." --target "..." \  --bucket-path "s3://mybucket/migration" \  --fetch-id "abc-123" \  --non-interactive

Error Recovery

ErrorCauseFix
"GTID-based replication not enabled"MySQL missing GTIDEnable gtid_mode=ON or add --ignore-replication-check
"Column mismatch"Schema divergedFix target schema manually or use --type-map-file
Silent IMPORT INTOCockroachDB import runningSHOW JOBS on CRDB to check progress
"timestamp in the future"Docker/Mac clock driftSync clocks between hosts

Gotchas

  • COPY mode: cannot use --compression gzip; must use --compression none (or omit, default is none with copy)
  • Table is offline during IMPORT INTO — use --use-copy for zero downtime
  • Schema changes between runs require starting from scratch
  • --fetch-id continuation tokens live in the target's exceptions table
  • For MySQL, --ignore-replication-check skips GTID validation but replication-dependent features won't work
  • After fetch, run molt verify to confirm data integrity

See flags reference [blocked] for the full flag list.

來源與署名

來源:cockroachdb/claude-plugin位於skills/cockroachdb-onboarding-and-migrations/molt-fetch提交6c96c63

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架