Single Kafka-docker broker instance is working fine with the downloaded image for wurstmeister. Execution of below command result displayed as done on cmd prompt:
docker-compose scale kafka=2
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting mskafka_kafka_1 ... done
Creating mskafka_kafka_2 ... done
Although, the state of the container is Exit 1
docker-compose ps
The system cannot find the path specified.
Name Command State Ports
------------------------------------------------------------------------------------------------------------------
mskafka_apache_1 /bin/sh -c apache2ctl -D F ... Up 0.0.0.0:8080->80/tcp
mskafka_kafka_1 start-kafka.sh Up 0.0.0.0:9092->9093/tcp
mskafka_kafka_2 start-kafka.sh Exit 1
mskafka_postgres_1 docker-entrypoint.sh postgres Up 5432/tcp
mskafka_zookeeper_1 /bin/sh -c /usr/sbin/sshd ... Up 0.0.0.0:2181->2181/tcp, 22/tcp, 2888/tcp, 3888/tcp
Configuration file : docker-compose.yml
kafka:
image: wurstmeister/kafka:2.11-2.0.0
links:
- zookeeper
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
# KAFKA_ADVERTISED_PORT: 9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_CREATE_TOPICS: "order:5:1"
ports:
- "9092"
Container logs shows below stack trace:
[2018-12-27 11:12:42,035] INFO [LogDirFailureHandler]: Starting (kafka.server.ReplicaManager$LogDirFailureHandler)
[2018-12-27 11:12:42,056] ERROR [KafkaServer id=1002] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
java.lang.IllegalArgumentException: requirement failed: Configured end points kafka:9092 in advertised listeners are already registered by broker 1001
at scala.Predef$.require(Predef.scala:224)
at kafka.server.KafkaServer$$anonfun$createBrokerInfo$2.apply(KafkaServer.scala:384)
at kafka.server.KafkaServer$$anonfun$createBrokerInfo$2.apply(KafkaServer.scala:382)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at kafka.server.KafkaServer.createBrokerInfo(KafkaServer.scala:382)
at kafka.server.KafkaServer.startup(KafkaServer.scala:256)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
at kafka.Kafka$.main(Kafka.scala:75)
at kafka.Kafka.main(Kafka.scala)
[2018-12-27 11:12:42,065] INFO [KafkaServer id=1002] shutting down (kafka.server.KafkaServer)
Environment Details: 1. OS - Windows 10 2. Docker kafka image : wurstmeister/kafka:2.11-2.0.0
Is there any configuration changes missing?
You cannot scale a Kafka broker like it's just some web-app or API.
At least these properties need to be unique for each broker
KAFKA_BROKER_ID
(this is already handled for you)KAFKA_ADVERTISED_HOST_NAME
and KAFKA_ADVERTISED_PORT
to know where on the network that broker exists (these are deprecated, and the advertised listeners config should be used instead)KAFKA_ADVERTISED_LISTENERS
is how clients know how to reach a specific broker; if this is allowed to be the same for multiple brokers, then only one of them would ever get any producer/consumer requests. The HOSTNAME_COMMAND
can be used to set this, but you'll have to do something special for the portsNote that the default replication factors of internal topics is only 1, and scaling from 1 to 3 brokers will not change this
If you look in the wurstmeister (and confluentinc/cp-docker-images) repos, they have multi-broker compose files, or you can look into using Strimzi / Bitnami Kubernetes operators for Kafka
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With