安装postgresql
参照Ubuntu上安装postgresql安装好postgresql
修改配置文件
这里采用debezium的pgoutput的形式,由于pgsql是11所以可以无侵入,下面打开逻辑复制功能
postgresql.conf
wal_level = logical
max_wal_senders = 10
max_replication_slots = 10
其中第一行需要修改,后两行放开注释就可以了
pg_hba.conf
local all postgres trust
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 0.0.0.0/0 trust
host all all ::1/128 trust
local replication postgres trust
host replication postgres 127.0.0.1/32 trust
host replication postgres ::1/128 trust
这个都要改成trust,另外我把all改成postgres了
重启生效
systemctl restart postgresql
debezium
connector
使用postgresql的logical来同步数据的话需要在创建connector时body里加入"plugin.name":"pgoutput"
查看kafka消息
list-topics
docker run --rm -e ZOOKEEPER_CONNECT=127.0.0.1:2181 debezium/kafka list-topics
watch_topic
docker run --rm -e ZOOKEEPER_CONNECT=127.0.0.1:2181 -e KAFKA_BROKER=127.0.0.1:9092 debezium/kafka watch-topic postgres.public.table_name