# zookeeper-kafka-cluster **Repository Path**: sh08090314/zookeeper-kafka-cluster ## Basic Information - **Project Name**: zookeeper-kafka-cluster - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-11 - **Last Updated**: 2021-01-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 拉取镜像 ```yaml # 拉取 zookeeper 3.4 镜像 docker pull zookeeper:3.4 # 拉取 Kafka 镜像 # 不指定版本默认拉取最新版本的镜像 docker pull wurstmeister/kafka docker pull sheepkiller/kafka-manager # kafka开源的web管理界面 ``` ## 初始化、启动集群 ```yaml ./inizk-cluster.sh ``` # 测试 ## 登录kafka1 创建 topic 发布消息 ```yaml docker exec -it kafka1 bash 在容器中执行 cd /opt/kafka_2.13-2.6.0/bin # 创建 topic 主题 kafka-topics.sh --create --topic test1 --replication-factor 3 --partitions 2 --zookeeper 10.251.251.12:2184 # 查看 主题列表 kafka-topics.sh --list --zookeeper 10.251.251.12:2184 # 使用 主题发布消息 sh /opt/kafka_2.13-2.6.0/bin/kafka-console-producer.sh --broker-list 10.251.251.12:9092 --topic test1 ``` ## 登录kafka2连接topic并接收消息 ```yaml # 登录 docker exec -it kafka2 bash # 连接 test1 topic sh /opt/kafka_2.13-2.6.0/bin/kafka-console-consumer.sh --bootstrap-server 10.251.251.12:9092 --topic test1 --from-beginning ``` ## 删除所有 docker 容器重新来过 ```yaml docker rm -f $(docker ps -a |awk '{print $1}') ``` [概念说明参考 https://blog.csdn.net/J_KF_MySQL/article/details/109579304](https://blog.csdn.net/J_KF_MySQL/article/details/109579304)