测试前需要先设置2个参数:
wal_level=logical,需要重启
max_replication_slots 默认10个,够用了,暂时不需要修改。
1、创建一个复制槽,名称为logical_slot,使用插件:test_decoding
postgres=# SELECT pg_create_logical_replication_slot('logical_slot', 'test_decoding');
2019-04-05 12:34:12.053 CST [18658] LOG: logical decoding found consistent point at 0/1614040
2019-04-05 12:34:12.053 CST [18658] DETAIL: There are no running transactions.
2019-04-05 12:34:12.053 CST [18658] STATEMENT: SELECT pg_create_logical_replication_slot('logical_slot', 'test_decoding');
pg_create_logical_replication_slot
------------------------------------
(logical_slot,0/1614078)
(1 row)
2、查看当前复制槽状态
postgres=# select * from pg_replication_slots where slot_name='logical_slot';
-[ RECORD