docker学习:docker---kafka安装

下载zookeeper镜像与kafka镜像:

docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka

本地启动zookeeper

docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper  

本地启动kafka

docker run -d --name kafka --publish 9092:9092 --link zookeeper --env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 --env KAFKA_ADVERTISED_HOST_NAME=localhost --env KAFKA_ADVERTISED_PORT=9092
id

kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 2 --topic kafka_demo

kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --patitions 2  --topic kafka_test

docker run -d --name zookeeper -p 2180:2181 -v /usr/local/zookeeper/data:/data -v /usr/local/zookeeper/log:/datalog zookeeper

docker run -d --name kafka --publish 9092:9092 --link zookeeper --env KAFKA_ZOOKEEPER_CONNECT=192.168.2.99:2180 --env KAFKA_ADVERTISED_HOST_NAME=192.168.2.99 --env KAFKA_ADVERTISED_PORT=9092 --env KAFKA_LOG_DIRS=/kafka/kafka-logs-1 -v /usr/local/kafka/logs:/kafka/kafka-logs-1 wurstmeister/kafka

posted @ 2021-12-14 10:23  Carl-  阅读(19)  评论(0编辑  收藏  举报