지속적 복제 / CDC 구성(무중단 전환)
Oracle
# CDC-based replication with Oracle GoldenGate (outline)
# 1) Enable supplemental logging on the source:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
# 2) Extract (capture changes from redo) and Replicat (apply to the target) processes:
# GGSCI> ADD EXTRACT ext1, INTEGRATED TRANLOG, BEGIN NOW
# GGSCI> ADD REPLICAT rep1, INTEGRATED
# Alternative: initial load with Data Pump + incremental capture with GoldenGateOracle에서 무중단/이기종 CDC의 표준 도구는 Oracle GoldenGate다. Extract 프로세스가 redo log에서 변경을 캡처하고 Replicat이 이를 대상에 적용하며, supplemental logging을 활성화해야 한다. 일반적인 마이그레이션: 초기 적재는 Data Pump로 수행하고, 이후 GoldenGate가 변경을 대상으로 스트리밍하여 다운타임이 거의 없는 전환을 가능하게 한다.
PostgreSQL
-- Source (publisher): create a publication (wal_level must be logical)
CREATE PUBLICATION migration_pub FOR ALL TABLES;
-- Target (subscriber): create a subscription (initial copy + continuous stream)
CREATE SUBSCRIPTION migration_sub
CONNECTION 'host=source dbname=shop user=repl password=***'
PUBLICATION migration_pub;PostgreSQL은 내장 논리 복제로 CDC를 제공한다. 소스에서 CREATE PUBLICATION, 대상에서 CREATE SUBSCRIPTION을 실행한다. 구독이 시작되면 기존 데이터를 복사(initial copy)한 뒤 WAL에서 변경을 지속적으로 스트리밍한다. wal_level=logical이 필요하다. 대규모/복잡한 시나리오에는 pglogical이나 Debezium이 권장된다.
MySQL
-- Source: binlog must be enabled and in ROW format (log_bin, binlog_format=ROW)
-- Grant a replication user: GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
-- Define the source on the target (start from the binlog position of the initial load):
CHANGE REPLICATION SOURCE TO
SOURCE_HOST='source', SOURCE_USER='repl', SOURCE_PASSWORD='***',
SOURCE_LOG_FILE='binlog.000001', SOURCE_LOG_POS=1547;
START REPLICA;MySQL에서 무중단 전환은 binlog 기반 복제로 수행한다. 초기 적재는 mysqldump --source-data로 수행하고 binlog 위치/GTID를 기록한다. 대상에서는 CHANGE REPLICATION SOURCE TO(8.0.23+ 구문, 이전에는 CHANGE MASTER TO)로 해당 위치부터 복제를 시작한다. START REPLICA는 변경을 지속적으로 적용한다. GTID 기반 구성이 더 안전하다.
SQL Server
-- Option A: Transactional Replication (publisher->distributor->subscriber) — SSMS wizard
-- Option B: Change Data Capture (track changes as tables)
EXEC sys.sp_cdc_enable_db; -- enable CDC at database level
EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo', @source_name = N'customer',
@role_name = NULL; -- enable CDC at table level
-- Changes are read from the cdc.dbo_customer_CT table and moved to the target.SQL Server의 지속적 복제에는 두 가지 주요 경로가 있다. 대상으로 직접 스트리밍하려면 Transactional Replication(publisher/subscriber)을 구성한다. 자체 ETL로 변경을 옮기려면 Change Data Capture(sp_cdc_enable_db + sp_cdc_enable_table)를 활성화하고 _CT 테이블에서 읽는다. 이기종 대상에는 CDC를 AWS DMS/Debezium과 결합한다.
MongoDB
// Watch changes live with Change Streams (requires a replica set/sharded cluster)
const cs = db.customer.watch([], { fullDocument: "updateLookup" });
while (cs.hasNext()) { printjson(cs.next()); } // apply to the target
// Official tool for managed cluster-to-cluster replication/migration: mongosync
// mongosync --cluster0 "mongodb://source" --cluster1 "mongodb://target"MongoDB에서는 CDC에 Change Streams를 사용한다. db.collection.watch()는 oplog에서 insert/update/delete 이벤트를 실시간으로 스트리밍하며 이를 대상에 적용한다(replica set 필요). 클러스터 간 전체 지속 마이그레이션/복제에는 MongoDB 공식 Cluster-to-Cluster Sync 도구인 mongosync(Atlas 전용이 아니며 자체 관리 클러스터에서도 동작)가 초기 적재 + 지속 동기화를 관리한다.
Redis
# Make the target instance a replica of the source (live synchronization)
# On the target Redis:
REPLICAOF source_host 6379
# Monitor sync status:
INFO replication # master_link_status must be up
# Once the cutover is complete, make the target standalone:
REPLICAOF NO ONERedis에서 무중단 전환은 기본 복제로 수행한다. 대상 서버에서 REPLICAOF <source host port>(이전 SLAVEOF)를 실행하면 대상이 먼저 전체 RDB를 받은 뒤 명령 스트림으로 지속 동기화된다. INFO replication으로 master_link_status:up을 확인하고, 전환이 완료되면 REPLICAOF NO ONE으로 대상을 standalone으로 만든다.
Elasticsearch
# Incremental reindex from the old cluster to the new one within the same version family
POST _reindex?wait_for_completion=false
{ "source": { "remote": { "host": "http://old:9200" }, "index": "customer",
"query": { "range": { "updated_at": { "gt": "<last-cursor>" } } } },
"dest": { "index": "customer" } }
# Licensed feature: Cross-Cluster Replication (CCR) — continuous following
# On the target (follower) cluster: PUT /customer/_ccr/follow { "remote_cluster": "old", "leader_index": "customer" }Elasticsearch의 실질적인 지속 복제 기능은 Cross-Cluster Replication(CCR)이다. 대상 클러스터가 소스의 leader index를 팔로우하며 변경을 지속적으로 가져온다(상용/Platinum 라이선스 필요). 라이선스가 없으면 주기적인 remote reindex(시간/시퀀스 필드 기반 증분)로 거의 지속적인 동기화를 구현한다.