Cross-Cluster Replication¶
Overview
Cross-cluster replication, also called logical replication, is a method of data replication across multiple clusters.
About
CrateDB uses a “publish and subscribe” model where subscribers pull data from the publications of the publisher they subscribed to.
Details
Logical replication is useful for different use cases.
Consolidating data from multiple clusters into a single one for aggregated reports.
Ensure high availability if one cluster becomes unavailable.
Replicating between different compatible versions of CrateDB. Replicating tables created on a cluster with higher major/minor version to a cluster with lower major/minor version is not supported.
Reference Manual
SQL Functions
System Tables
SQL Logical Replication
Synopsis¶
Create a publication others can subscribe to.
CREATE PUBLICATION temperature_publication FOR TABLE doc.temperature_data;
Verify publication has been created.
SELECT * FROM pg_publication;
Create a subscription.
CREATE SUBSCRIPTION temperature_subscription
CONNECTION 'crate://cratedb.example.net:5432?user=crate&mode=pg_tunnel'
PUBLICATION temperature_publication;
Verify operational status of subscription.
SELECT subname, r.srrelid::TEXT, srsubstate, srsubstate_reason
FROM pg_subscription s
LEFT JOIN pg_subscription_rel r ON s.oid = r.srsubid;
Learn¶
Learn how to set up logical replication between CrateDB clusters.
Logical replication using Docker
Hands-on tutorial exercising publishing and subscribing end-to-end.
Uses a workstation setup based on two instances running on Docker or Podman.
Logical replication on CrateDB Cloud
Notes about configuring the feature in the context of Cloud clusters.
It mostly works out of the box.