Skip to content

Commit 995fedb

Browse files
committed
fix
1 parent 3426fc4 commit 995fedb

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

201704/20170413_01.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## PostgreSQL 内核层逻辑订阅给业务架构带来了什么
1+
## PostgreSQL 逻辑订阅 - 给业务架构带来了什么希望
22
33
### 作者
44
digoal
@@ -125,6 +125,34 @@ http://www.cybertec.at/en/products/walbouncer-enterprise-grade-partial-replicati
125125

126126
![pic](../201612/20161205_02_pic_003.png)
127127

128+
## 逻辑订阅例子
129+
逻辑订阅只需简单两步即可完成。
130+
131+
1\. 建表、发布
132+
133+
```
134+
src=# create table public.t1(id int primary key, info text, crt_time timestamp);
135+
CREATE TABLE
136+
137+
src=# create publication pub1 for table public.t1;
138+
CREATE PUBLICATION
139+
```
140+
141+
2\. 建表、订阅
142+
143+
```
144+
dst=# create table public.t1(id int primary key, info text, crt_time timestamp);
145+
CREATE TABLE
146+
147+
dst=# create subscription sub1_from_pub1 connection 'hostaddr=xxx.xxx.xxx.xxx port=1922 user=postgres dbname=src' publication pub1 with (enabled, create slot, slot name='sub1_from_pub1');
148+
NOTICE: created replication slot "sub1_from_pub1" on publisher
149+
CREATE SUBSCRIPTION
150+
```
151+
152+
详情请参考
153+
154+
[《PostgreSQL 10.0 preview 逻辑订阅 - 原理与最佳实践》](../201702/20170227_01.md)
155+
128156
## 逻辑订阅的冲突解决
129157
逻辑订阅,本质上是事务层级的复制,需要在订阅端执行SQL。
130158

0 commit comments

Comments
 (0)