1

I am looking for a Kafka source connector for Day0 load from Postgres to Kafka.

Came across Debezium postgres connector.

Docker image,

debezium/connect:1.4

docker run -it --rm --name postgres-connect -p 8083:8083 -e BOOTSTRAP_SERVERS=host1:8080 -e GROUP_ID=test-1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets -e STATUS_STORAGE_TOPIC=my_connect_statuses debezium/connect:1.4

How to pass the postgres host details and kafka sasl config?

Any help would be appreciated.

4
  • For SASL config: please see answer stackoverflow.com/a/64355810/7109598 Commented Jan 19, 2021 at 9:57
  • 1
    Postgres host details should be passed via connector config Commented Jan 19, 2021 at 9:58
  • @IskuskovAlexander I am new to kafka connect. Can you tell me how to pass the SASL config file and postgress config to the docker container? Commented Jan 21, 2021 at 19:07
  • please see some details in the posted answer Commented Jan 24, 2021 at 16:00

1 Answer 1

2
+50

1. SASL configuration

1.1. In common case you need to add the following properties to your connect-distributed.properties:

sasl.mechanism=PLAIN
security.protocol=SASL_PLAINTEXT

sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
  username="connect" \
  password="connect-secret";

producer.sasl.mechanism=PLAIN
producer.security.protocol=SASL_PLAINTEXT
producer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
  username="connect" \
  password="connect-secret";

consumer.sasl.mechanism=PLAIN
consumer.security.protocol=SASL_PLAINTEXT
consumer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
  username="connect" \
  password="connect-secret";

Source: StackOverflow answer "ACL configuration in Kafka connect is not working"

Reference: Kafka Connect Security docs

1.2. For debezium/connect docker image you can try to pass SASL config directly via environment variables (using these transformation steps):

docker run -it --rm --name postgres-connect -p 8083:8083 \
  -e BOOTSTRAP_SERVERS=host1:8080 -e GROUP_ID=test-1 \
  -e CONFIG_STORAGE_TOPIC=my_connect_configs \
  -e OFFSET_STORAGE_TOPIC=my_connect_offsets \
  -e STATUS_STORAGE_TOPIC=my_connect_statuses \
  -e CONNECT_SASL_MECHANISM=PLAIN \
  -e CONNECT_SECURITY_PROTOCOL=SASL_PLAINTEXT \
  -e CONNECT_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="connect" password="connect-secret"; \
  -e CONNECT_PRODUCER_SASL_MECHANISM=PLAIN \
  -e CONNECT_PRODUCER_SECURITY_PROTOCOL=SASL_PLAINTEXT \
  -e CONNECT_PRODUCER_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="connect" password="connect-secret"; \
  -e CONNECT_CONSUMER_SASL_MECHANISM=PLAIN \
  -e CONNECT_CONSUMER_SECURITY_PROTOCOL=SASL_PLAINTEXT \
  -e CONNECT_CONSUMER_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="connect" password="connect-secret"; \
debezium/connect:1.4

2. PostgreSQL host configaration

Host details should be passed via Kafka Connect REST API using connector config:

curl -i -X PUT -H "Content-Type:application/json" \
    http://localhost:8083/connectors/debezium_postgres_source/config \
    -d '{
    "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
    "tasks.max": "1",
    "database.hostname": "source-db",
    "database.port": "5432",
    "database.user": "postgresusersource",
    "database.password": "postgrespw",
    "database.dbname" : "sourcedb",
    "database.server.name": "dbserver1"
}'    
Sign up to request clarification or add additional context in comments.

2 Comments

Calling REST API for Postgres config --> Do we need to call this whenever the docker container gets restarted for some reason?
All metadata of connector stores in Kafka. So, if you haven't lose this info, I don't have to call this method again. Also you can check status of connector via REST API (curl -XGET localhost:8083/connectors/debezium_postgres_source/status)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.