1、创建slot
$ pg_recvlogical -U postgres -d postgres --slot test --create-slot
2019-04-05 13:11:35.149 CST [20380] LOG: logical decoding found consistent point at 0/1635DB8
2019-04-05 13:11:35.149 CST [20380] DETAIL: There are no running transactions.
2、开始接收解码的数据, -f - 将解码的内容打印到标准输出。
$ pg_recvlogical -U postgres -d postgres --slot test --start -f -
2019-04-05 13:29:41.443 CST [20650] LOG: starting logical decoding for slot "test"
2019-04-05 13:29:41.443 CST [20650] DETAIL: Streaming transactions committing after 0/1635DF0, reading WAL from 0/1635DB8.
2019-04-05 13:29:41.443 CST [20650] LOG: logical decoding found consistent point at 0/1635DB8
2019-04-05 13:29:41.443 CST [20650] DETAIL: There are no running transactions.
3、在另外一个窗口,执行insert操作