Created
October 3, 2025 08:11
-
-
Save davidcsejtei/b233b0ebb2d8132804a50725204438c5 to your computer and use it in GitHub Desktop.
Debezium example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker exec -it $(docker ps -qf "name=postgres") psql -U postgres -d demo -c \ | |
| "CREATE TABLE IF NOT EXISTS public.customers ( | |
| id SERIAL PRIMARY KEY, | |
| name VARCHAR(255), | |
| email VARCHAR(255) | |
| );" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.8' | |
| services: | |
| zookeeper: | |
| image: confluentinc/cp-zookeeper:7.5.0 | |
| environment: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 | |
| ports: | |
| - '2181:2181' | |
| kafka: | |
| image: confluentinc/cp-kafka:7.5.0 | |
| depends_on: | |
| - zookeeper | |
| ports: | |
| - '9092:9092' | |
| environment: | |
| KAFKA_BROKER_ID: 1 | |
| KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | |
| KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:29092,PLAINTEXT_HOST://0.0.0.0:9092 | |
| KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092 | |
| KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | |
| KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT | |
| KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
| KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 | |
| KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 | |
| postgres: | |
| image: debezium/postgres:15-alpine | |
| environment: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: demo | |
| ports: | |
| - '5432:5432' | |
| connect: | |
| image: debezium/connect:2.6 | |
| depends_on: | |
| - kafka | |
| - postgres | |
| ports: | |
| - '8083:8083' | |
| environment: | |
| BOOTSTRAP_SERVERS: kafka:29092 | |
| GROUP_ID: 1 | |
| CONFIG_STORAGE_TOPIC: my_connect_configs | |
| OFFSET_STORAGE_TOPIC: my_connect_offsets | |
| STATUS_STORAGE_TOPIC: my_connect_statuses | |
| kafka-ui: | |
| image: provectuslabs/kafka-ui:latest | |
| depends_on: | |
| - kafka | |
| ports: | |
| - '8080:8080' | |
| environment: | |
| KAFKA_CLUSTERS_0_NAME: local | |
| KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:29092 | |
| KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker exec -it $(docker ps -qf "name=postgres") psql -U postgres -d demo -c \ | |
| "INSERT INTO public.customers (name, email) VALUES ('Alice','[email protected]');" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -s -X POST http://localhost:8083/connectors \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "pg-customers-connector", | |
| "config": { | |
| "connector.class": "io.debezium.connector.postgresql.PostgresConnector", | |
| "database.hostname": "postgres", | |
| "database.port": "5432", | |
| "database.user": "postgres", | |
| "database.password": "postgres", | |
| "database.dbname": "demo", | |
| "topic.prefix": "pgserver1", | |
| "plugin.name": "pgoutput", | |
| "slot.name": "debezium_slot", | |
| "publication.autocreate.mode": "filtered", | |
| "schema.include.list": "public", | |
| "table.include.list": "public.customers", | |
| "tombstones.on.delete": "false" | |
| } | |
| }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment