docker搭建kafaka
https://www.cnblogs.com/toov5/p/11406325.html
1,启动zk
docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
启动kafka
docker run --name kafka01 \ -p 9092:9092 \ -e KAFKA_BROKER_ID=0 \ -e KAFKA_ZOOKEEPER_CONNECT=172.17.13.22:2181 \ -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://172.17.13.22:9092 \ -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \ -d wurstmeister/kafka
创建主题
进入到容器中:
docker exec -it kafka01 /bin/bash
创建主题: my_log
/opt/kafka/bin/kafka-topics.sh --create --zookeeper 172.17.13.22:2181 --replication-factor 1 --partitions 1 --topic my_log # replication-factor 副本 # partitions 分区
查询主题:
bash-5.1# /opt/kafka/bin/kafka-topics.sh --zookeeper 172.17.13.22:2181 --list
修改分区数:
bash-5.1# /opt/kafka/bin/kafka-topics.sh --zookeeper 172.17.13.22:2181 --alter --topic my_log --partitions 16
查看分区详情:
bash-5.1# /opt/kafka/bin/kafka-topics.sh --zookeeper 172.17.13.22:2181 --describe
删除主题:
bash-5.1# /opt/kafka/bin/kafka-topics.sh --zookeeper 172.17.13.22:2181 --delete --topic my_log2
模拟生产者:
bash-5.1# /opt/kafka/bin/kafka-console-producer.sh --broker-list 172.17.13.22:9092 --topic my_log
模拟消费者:
bash-5.1# /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 172.17.13.22:9092 --topic my_log --from-beginning
查询主题详情:
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper 172.17.13.22:2181 --topic my_log