connect-cdc-postgres
Streams change data capture from PostgreSQL into Redpanda or Kafka using Redpanda Connect's postgres_cdc input, which reads the WAL through logical…
от skillmds★ 42 звезды на GitHub
Установить connect-cdc-postgres в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Redpanda Connect CDC: PostgreSQL
The postgres_cdc input in Redpanda Connect streams change data capture (CDC) from a PostgreSQL database into Redpanda or any Kafka-compatible topic. It uses PostgreSQL's logical replication protocol (pgoutput plugin), reads the Write-Ahead Log (WAL), and optionally snapshots all existing rows before switching to live replication. Introduced in version 4.39.0. The legacy name pg_stream is deprecated.
This is an Enterprise feature — a Redpanda Enterprise license is required. The connector creates and manages a logical replication slot and a publication automatically, but both can be pre-created manually.
Quickstart
1. Prepare PostgreSQL (4 commands)
-- 1. Verify or set wal_level (requires server restart if changed)
ALTER SYSTEM SET wal_level = logical;
-- Check current value:
SHOW wal_level; -- must return 'logical'
-- 2. Create a dedicated replication user
CREATE USER cdc_user WITH REPLICATION LOGIN PASSWORD 'secret';
GRANT CONNECT ON DATABASE mydb TO cdc_user;
GRANT SELECT ON TABLE public.orders, public.customers TO cdc_user;
-- 3. (Optional) Pre-create the publication to avoid needing CREATE PUBLICATION privilege
-- Connector uses the pattern: pglog_stream_<slot_name>
CREATE PUBLICATION pglog_stream_my_slot FOR TABLE public.orders, public.customers;
-- 4. (Optional) Pre-create the replication slot
SELECT pg_create_logical_replication_slot('my_slot', 'pgoutput');
2. Full pipeline YAML (snapshot + stream, two tables)
# postgres-cdc-pipeline.yaml
input:
label: "pg_cdc"
postgres_cdc:
dsn: postgres://cdc_user:secret@localhost:5432/mydb?sslmode=disable
schema: public
tables:
- orders
- customers
slot_name: my_slot
stream_snapshot: true # back-fill existing rows first
snapshot_batch_size: 5000 # rows per query during snapshot
max_parallel_snapshot_tables: 2 # snapshot both tables simultaneously
checkpoint_limit: 1024
heartbeat_interval: 1h # prevents slot lag on quiet tables
include_transaction_markers: false
batching:
count: 100
period: 1s
pipeline:
processors:
# Route each event to a topic named after the source table
- mapping: |
meta topic = "pg.cdc." + metadata("table")
output:
kafka_franz:
seed_brokers:
- localhost:9092
topic: ${! metadata("topic") }
key: ${! json("id").string() }
Tip: When writing to Redpanda, the native
redpandaoutput is the idiomatic choice — it handles seed broker discovery and authentication more ergonomically thankafka_franz.kafka_franzis fully valid for both Redpanda and generic Kafka targets.
3. Run the pipeline
# Self-managed Redpanda Connect binary
redpanda-connect run postgres-cdc-pipeline.yaml
# Via rpk (if installed)
rpk connect run postgres-cdc-pipeline.yaml
# Docker
docker run --rm \
-v $(pwd)/postgres-cdc-pipeline.yaml:/pipeline.yaml \
docker.redpanda.com/redpandadata/connect:latest \
run /pipeline.yaml
4. Inspect the emitted messages
Every message has these metadata fields (set via metadata() in Bloblang):
| Metadata key | Value |
|---|---|
table |
Table name (unquoted), e.g. orders |
operation |
read, insert, update, delete, begin, commit |
lsn |
WAL log sequence number string; not set (absent) for snapshot read rows |
commit_ts_ms |
Transaction commit timestamp (Unix milliseconds); set on insert/update/delete. Not set for snapshot read rows (since 4.98.0) |
before |
Pre-change row state for update and delete, in Benthos common schema format. For updates the contents depend on the table's REPLICA IDENTITY: the default identity carries only key columns, REPLICA IDENTITY FULL carries all columns (since 4.99.0) |
schema |
Column schema in Benthos common format; set on read, insert, update, delete messages. Use with parquet_encode: { schema_metadata: schema } |
Example payload for an insert into orders:
{
"id": 42,
"customer_id": 7,
"amount": 99.99,
"status": "pending"
}
Snapshot Behavior
When stream_snapshot: true the connector:
- Creates a temporary replication slot and exports a snapshot (
EXPORT_SNAPSHOT) - Opens reader transactions pinned to that snapshot and scans each table in key-order batches
- Emits messages with
operation: read(nolsn— LSN isnilfor snapshot rows) - After all tables are fully scanned, copies the temporary slot into the permanent
slot_nameslot - Drops the temporary slot and begins streaming WAL changes from the LSN at snapshot time
Tables being snapshot must have a primary key — the connector uses the primary key to parallelize and paginate the scan.
Operational Notes
- Replication slot growth: An unacknowledged replication slot blocks WAL reclamation. If the pipeline stops for a long time, disk can fill. Monitor
pg_replication_slots.confirmed_flush_lsn
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/SOURCES.md
- references/config-reference.md
- references/enterprise-sink-features.md
- references/pipeline-and-output.md
- references/setup-postgres.md
FAQ
Что делает скилл connect-cdc-postgres?
Streams change data capture from PostgreSQL into Redpanda or Kafka using Redpanda Connect's postgres_cdc input, which reads the WAL through logical replication (pgoutput). Use when configuring postgres_cdc (formerly pg_stream), setting up wal_level=logical, replication slots, and publications, enabling an initial snapshot before streaming, or troubleshooting slot growth and WAL accumulation. Also covers Redpanda Enterprise destination features such as Iceberg Topics, Tiered Storage, and server-side Schema ID Validation, since postgres_cdc itself requires a Redpanda Enterprise license.
Как установить скилл connect-cdc-postgres?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл connect-cdc-postgres запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…