Implementation:Risingwavelabs Risingwave CDC Database Configuration
| Knowledge Sources | |
|---|---|
| Domains | CDC, Database_Administration |
| Last Updated | 2026-02-09 07:00 GMT |
Overview
Concrete tool for preparing source databases for CDC replication provided by integration test Docker Compose configurations and SQL scripts.
Description
CDC Database Configuration encompasses the Docker Compose service definitions and SQL preparation scripts that configure MySQL and PostgreSQL databases for Change Data Capture. This includes enabling binary logging (MySQL) or logical WAL decoding (PostgreSQL), creating appropriate users with replication privileges, and setting up test data.
Usage
Use these configurations when setting up a CDC pipeline from MySQL or PostgreSQL to RisingWave. The integration test configurations serve as reference implementations.
Code Reference
Source Location
- Repository: risingwave
- File: integration_tests/mysql-cdc/docker-compose.yml (L23-48), integration_tests/postgres-cdc/docker-compose.yml (L25-56)
Signature
-- MySQL CDC Preparation
SET GLOBAL binlog_format = 'ROW';
CREATE USER 'cdcuser'@'%' IDENTIFIED BY 'password';
GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'cdcuser';
-- PostgreSQL CDC Preparation
ALTER SYSTEM SET wal_level = logical;
CREATE PUBLICATION my_pub FOR ALL TABLES;
ALTER TABLE my_table REPLICA IDENTITY FULL;
Import
# No import - these are SQL scripts run against source databases
# MySQL: mysql -u root -p < prepare.sql
# PostgreSQL: psql -U postgres -f postgres_prepare.sql
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| MYSQL_ROOT_PASSWORD | Environment variable | Yes (MySQL) | Root password for MySQL (default: 123456) |
| MYSQL_USER | Environment variable | No | CDC user (default: mysqluser) |
| POSTGRES_USER | Environment variable | Yes (PostgreSQL) | Database user (default: myuser) |
| POSTGRES_PASSWORD | Environment variable | Yes (PostgreSQL) | User password (default: 123456) |
| wal_level | PostgreSQL config | Yes (PostgreSQL) | Must be set to 'logical' |
Outputs
| Name | Type | Description |
|---|---|---|
| MySQL service | Docker container | MySQL 8.0 on port 3306 with binlog enabled |
| PostgreSQL service | Docker container | PostgreSQL 17 on port 5432 with logical WAL |
| Test data | Database rows | Pre-populated tables for CDC testing |
Usage Examples
MySQL CDC Docker Compose
services:
mysql:
image: mysql:8.0
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_USER: mysqluser
MYSQL_PASSWORD: 123456
MYSQL_DATABASE: mydb
command: --binlog-format=ROW --server-id=1
Create CDC Source in RisingWave
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_name VARCHAR,
total_amount DECIMAL,
order_date TIMESTAMPTZ
) WITH (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'root',
password = '123456',
database.name = 'mydb',
table.name = 'orders',
server.id = '1'
);