Hi,
I’m trying to run kafka-connect with docker. But weird thing is when I run just one kafka broker, it works perfectly fine. However, when I spin up more than 2 kafka broker, the status of kafka-connect becomes unhealthy. The host machine I use is Debian 10.
Here’s the logs of kafka-connect:
I did see an ERROR saying that Topic ‘docker-connect-offsets’ supplied via the ‘offset.storage.topic’ property is required to have ‘cleanup.policy=compact’ to guarantee consistency and durability of source connector offsets, but found the topic currently has ‘cleanup.policy=delete’. Continuing would likely result in eventually losing source connector offsets and problems restarting this Connect cluster in the future. Change the ‘offset.storage.topic’ property in the Connect worker configurations to use a topic with ‘cleanup.policy=compact’
But I’m not sure if that’s the reason which caused kafka-connect unhealthy.
Here’s my docker-compose file:
version: “3”
services:
zookeeper1:
# image: zookeeper
# image: wurstmeister/zookeeper
image: confluentinc/cp-zookeeper
restart: always
container_name: zookeeper1
hostname: zookeeper1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888
volumes:
- ./zoo1/data:/data
- ./zoo1/datalog:/datalog
zookeeper2:
# image: zookeeper
# image: wurstmeister/zookeeper
image: confluentinc/cp-zookeeper
restart: always
container_name: zookeeper2
hostname: zookeeper2
ports:
- 2182:2182
environment:
ZOO_MY_ID: 2
ZOOKEEPER_CLIENT_PORT: 2182
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888
volumes:
- ./zoo2/data:/data
- ./zoo2/datalog:/datalog
kafka1:
# image: wurstmeister/kafka
image: confluentinc/cp-kafka
restart: always
container_name: kafka1
ports:
- 9092:9092
- 9093:9093
- 9094:9094
depends_on:
- zookeeper1
- zookeeper2
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: INSIDE://0.0.0.0:9092,HOST://0.0.0.0:9093,OUTSIDE://0.0.0.0:9094
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka1:9092,HOST://localhost:9093,OUTSIDE://${HOST_IP}:9094
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,HOST:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_ZOOKEEPER_CONNECT: "zookeeper1:2181,zookeeper2:2182"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_MESSAGE_MAX_BYTES: 2000000
KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
volumes:
- ./kafka1/data:/var/lib/kafka/data
kafka2:
# image: wurstmeister/kafka
image: confluentinc/cp-kafka
restart: always
container_name: kafka2
ports:
- 9095:9095
- 9096:9096
- 9097:9097
depends_on:
- zookeeper1
- zookeeper2
environment:
KAFKA_BROKER_ID: 2
KAFKA_LISTENERS: INSIDE://0.0.0.0:9095,HOST://0.0.0.0:9096,OUTSIDE://0.0.0.0:9097
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka2:9095,HOST://localhost:9096,OUTSIDE://${HOST_IP}:9097
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,HOST:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_ZOOKEEPER_CONNECT: "zookeeper1:2181,zookeeper2:2182"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_MESSAGE_MAX_BYTES: 2000000
KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
volumes:
- ./kafka2/data:/var/lib/kafka/data
kafka_manager:
image: hlebalbau/kafka-manager:stable
container_name: kakfa-manager
restart: always
ports:
- "9000:9000"
environment:
ZK_HOSTS: "zookeeper1:2181,zookeeper2:2182"
APPLICATION_SECRET: "random-secret"
command: -Dpidfile.path=/dev/null
kafka-connect:
image: confluentinc/cp-kafka-connect-base
container_name: kafka-connect
restart: always
depends_on:
- zookeeper1
- zookeeper2
- kafka1
- kafka2
ports:
- 8083:8083
environment:
CONNECT_BOOTSTRAP_SERVERS: "kafka1:9092,kafka2:9095"
CONNECT_REST_PORT: 8083
CONNECT_GROUP_ID: compose-connect-group
CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs
CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets
CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status
CONNECT_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
CONNECT_REST_ADVERTISED_HOST_NAME: "kafka-connect"
CONNECT_LOG4J_ROOT_LOGLEVEL: "INFO"
CONNECT_LOG4J_APPENDER_STDOUT_LAYOUT_CONVERSIONPATTERN: "[%d] %p %X{connector.context}%m (%c:%L)%n"
CONNECT_LOG4J_LOGGERS: "org.apache.kafka.connect.runtime.rest=WARN,org.reflections=ERROR"
CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "1"
CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "1"
CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "1"
CONNECT_PLUGIN_PATH: '/usr/share/java,/usr/share/confluent-hub-components/'
command:
- bash
- -c
- |
# Install connector plugins
# This will by default install into /usr/share/confluent-hub-components/ so make
# sure that this path is added to the plugin.path in the environment variables
confluent-hub install --no-prompt confluentinc/kafka-connect-elasticsearch:11.0.0
# Launch the Kafka Connect worker
/etc/confluent/docker/run &
# Don't exit
sleep infinity
volumes:
- $PWD/data:/data
kafka-connect-ui:
image: landoop/kafka-connect-ui
container_name: kafka-connect-ui
ports:
- 8000:8000
environment:
CONNECT_URL: http://kafka-connect:8083
Any idea if I’m missing something? Thanks