docker 安装kafka 并测试

参考链接

安装zookeeper

下载zookeeper

docker pull zookeeper

启动zookeeper

docker run -itd --name zookeeper -p 2181:2181 镜像id

下载zookeeper可视化界面

安装kafka

下载kafka

docker pull wurstmeister/kafka

启动kafka

docker run  -d --name kafka \
--add-host kafka:192.168.142.128 \
--link zookeeper \
    -p 9092:9092 \
    -e KAFKA_BROKER_ID=0 \
    -e KAFKA_ZOOKEEPER_CONNECT=192.168.142.128:2181 \
    -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.142.128:9092 \
    -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka

docker run  -d --name kafka \
--link zookeeper \
    -p 9092:9092 \
    -e KAFKA_BROKER_ID=0 \
    -e KAFKA_ZOOKEEPER_CONNECT=192.168.142.132:2181 \
    -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.142.132:9092 \
    -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka



测试

创建topic

bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic test1

生产者

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test1

消费者

bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic test1 --from-beginning

查看topic 信息

bin/kafka-topics.sh --zookeeper zookeeper:2181 --describe --topic test1

查看topic

bin/kafka-topics.sh --list --zookeeper zookeeper:2181

遇到的问题

posted @ 2021-02-26 13:40  溢性循环  阅读(524)  评论(0编辑  收藏  举报