Kafka on docker

  • Install zookeeper
  1. Download zk
docker pull wurstmeister/zookeeper
  1. Start zk
docker run --network db_network -d --name zookeeper --publish 2181:2181 --volume /etc/localtime:/etc/localtime wurstmeister/zookeeper
  • Install kafka
  1. Download kafka
docker pull wurstmeister/kafka
  1. Start kafka
docker run --network db_network -d --name kafka --publish 9092:9092 --link zookeeper --env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 --env KAFKA_ADVERTISED_HOST_NAME=kafka --env KAFKA_ADVERTISED_PORT=9092 --volume /etc/localtime:/etc/localtime wurstmeister/kafka:latest
  • Verify
$ kafka-topics.sh --zookeeper zookeeper:2181 --list
$ kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic binlog_test
$ kafka-console-producer.sh --broker-list localhost:9092 --topic binlog_test
$ kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic binlog_test --from-beginning

你可能感兴趣的:(Kafka on docker)