Change-data-capture from Postgres SQL to kafka topics using standalone mode Kafka-connect
Asked Answered
A

1

7

I have been trying to get data from postgres sql to kafka topics using the following command /bin connect-standalone.properties config/connect-standalone.properties postgres.sproperties, but am facing several issues with it here are the contents of my postgres.properties file:

name=cdc_demo
connector.class=io.debezium.connector.postgresql.PostgresConnector
tasks.max=1
plugin.name=decoderbufs
slot.name=debezium
slot.drop_on_stop=false
database.hostname=localhost
database.port=5432
database.user=postgres
database.password=XXXXX
database.dbname=snehildb
time.precision.mode=adaptive
database.sslmode=disable
database.server.name=localhost:5432/snehildb
table.whitelist=public.students
decimal.handling.mode=precise
topic.creation.enable=true`

Here are the contents of connect-standalone.properties:

# These are defaults. This file just demonstrates how to override some settings.
bootstrap.servers=localhost:9092

# The converters specify the format of data in Kafka and how to translate it into Connect data. Every 
Connect user will
# need to configure these based on the format they want their data in when loaded from or stored into 
Kafka
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
# Converter-specific settings can be passed in by prefixing the Converter's setting with the 
converter we want to apply
# it to
key.converter.schemas.enable=true
value.converter.schemas.enable=true

offset.storage.file.filename=/tmp/connect.offsets
# Flush much faster than normal, which is useful for testing/debugging
offset.flush.interval.ms=10000

# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for 
plugins
# (connectors, converters, transformations). The list should consist of top level directories that 
include
# any combination of: 
# a) directories immediately containing jars with plugins and their dependencies
# b) uber-jars with plugins and their dependencies
# c) directories immediately containing the package directory structure of classes of plugins and 
their dependencies
# Note: symlinks will be followed to discover dependencies or plugins.
# Examples:
# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
plugin.path=/home/azureuser/plugins

I am getting several warnings but here are three main errors that I am unable to resolve:

 ERROR Postgres server wal_level property must be "logical" but is: replica 
 (io.debezium.connector.postgresql.PostgresConnector:101)
 (org.apache.kafka.common.config.AbstractConfig:361)
 ERROR Failed to create job for config/postgres.properties 
 (org.apache.kafka.connect.cli.ConnectStandalone:110)
 ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:121)

I am new to Kafka and it would be very helpful if someone could point out my mistakes.

Arrowworm answered 7/4, 2021 at 11:46 Comment(0)
I
7

Debezium requires wal_level to be logical:

https://www.postgresql.org/docs/9.6/runtime-config-wal.html

Take a look inside the postgres connector at the class:

io.debezium.connector.postgresql.PostgresConnector.java in the debeizum repo:

https://github.com/debezium/debezium/blob/master/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/PostgresConnector.java

Imply answered 7/4, 2021 at 15:17 Comment(1)
Hi senjin.hajrulahovic, Thanks for pointing this out. I changed this property in postgres.conf and the first two errors are gone now, I am still getting the connector error though, I'll try to figure it out. Really appreciate the help!!.Arrowworm

© 2022 - 2024 — McMap. All rights reserved.