Replication 将数据从一个 primary 数据库复制到一个或多个 replica(备用)服务器——用于高可用性(主数据库故障时的故障转移)和读取扩展(分散读取查询)。PostgreSQL 主要使用基于 write-ahead log(WAL)的 streaming replication(物理复制)。
Streaming(物理)复制
Primary ──(streams WAL: the write-ahead log of changes)──▶ Replica(s)
✓ The primary handles all WRITES
✓ Replicas continuously apply the primary's WAL → stay in sync (near-real-time)
✓ Replicas can serve READ queries ("hot standby") → scale reads
Primary 将其 (write-ahead log——每项变更的记录)流传输到副本,副本应用它以保持同步。副本是只读副本,可以服务读取查询。
