使用docker快速搭建kafka环境

1.下载docker镜像

zookeeker: docker pull zookeeper:latest
kafka: docker pull wurstmeister/kafka:latest

2.创建并启动容器

2.1 先启动zookeeper:

docker run -d --name zookeeper --publish 2181:2181 \
--volume /etc/localtime:/etc/localtime \
 zookeeper:latest

2.2 zookeeper启动完成后再启动kafka:

docker run -d --name kafka --publish 9092:9092 \
--link zookeeper \
--env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
--env KAFKA_ADVERTISED_HOST_NAME=kafka所在宿主机的IP \
--env KAFKA_ADVERTISED_PORT=9092 \
--volume /etc/localtime:/etc/localtime \
wurstmeister/kafka:latest

https://kafka.apache.org/

你可能感兴趣的:(kafka,docker,zookeeper)