![]() |
VOOZH | about |
Following the excellent tutorials on how to run a multi broker kafka cluster natively: http://www.michael-noll.com/blog/2013/03/13/running-a-multi-broker-apache-kafka-cluster-on-a-single-node/ and in vagrant: http://allthingshadoop.com/2013/12/07/using-vagrant-to-get-up-and-running-with-apache-kafka/
Here is the tutorial based on Docker and Compose:
docker-compose.yml with your docker host IP (KAFKA_ADVERTISED_HOST_NAME)docker-compose.yml. For example:
message.max.bytes parameter add KAFKA_MESSAGE_MAX_BYTES: 2000000 to the environment section.KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'$ docker-compose up
e.g. to start a cluster with two brokers
$ docker-compose scale kafka=2
This will start a single zookeeper instance and two Kafka instances. You can use docker-compose ps to show the running instances. If you want to add more Kafka brokers simply increase the value passed to docker-compose scale kafka=n
You can interact with your Kafka cluster via the Kafka shell:
$ start-kafka-shell.sh <DOCKER_HOST_IP> <ZK_HOST:ZK_PORT>
To test your setup, start a shell, create a topic and start a producer:
$ $KAFKA_HOME/bin/kafka-topics.sh --create --topic topic \
--partitions 4 --zookeeper $ZK --replication-factor 2
$ $KAFKA_HOME/bin/kafka-topics.sh --describe --topic topic --zookeeper $ZK
$ $KAFKA_HOME/bin/kafka-console-producer.sh --topic=topic \
--broker-list=`broker-list.sh`
Start another shell and start a consumer:
$ $KAFKA_HOME/bin/kafka-console-consumer.sh --topic=topic --zookeeper=$ZK
Install the Docker Toolbox and set KAFKA_ADVERTISED_HOST_NAME to the IP that is returned by the docker-machine ip command.
docker-compose logs/docker logs for the container and make sure you’ve got enough memory available on your host.