启动zk
docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
启动kafaka
docker run --name kafka01
-p 9092:9092
-e KAFKA_BROKER_ID=0
-e KAFKA_ZOOKEEPER_CONNECT=192.168.213.110:2181
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://172.17.13.22:9092
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092
-d wurstmeister/kafka
--创建主题
/opt/kafka/bin/kafka-topics.sh --create --zookeeper 192.168.213.110:2181 --replication-factor 1 --partitions 1 --topic my_log
--修改分区数目
/opt/kafka/bin/kafka-topics.sh --zookeeper 192.168.213.110:2181 --alter --topic my_log --partitions 16
--WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
--Adding partitions succeeded!
查看分区详情:
/opt/kafka/bin/kafka-topics.sh --zookeeper 192.168.213.110:2181 --describe
Topic: my_log TopicId: btD-SRhERdKnS3pEXMzicg PartitionCount: 16 ReplicationFactor: 1 Configs:
Topic: my_log Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 4 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 5 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 6 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 7 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 8 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 9 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 10 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 11 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 12 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 13 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 14 Leader: 0 Replicas: 0 Isr: 0
Topic: my_log Partition: 15 Leader: 0 Replicas: 0 Isr: 0
--查询主题
/opt/kafka/bin/kafka-topics.sh --zookeeper 192.168.213.110:2181 --list
查询主题详情:
/opt/kafka/bin/kafka-topics.sh --describe --zookeeper 192.168.213.110:2181 --topic my_log
ui管理工具
docker run -p 8080:8080 \
-e KAFKA_CLUSTERS_0_NAME=local \
-e KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092 \
-d provectuslabs/kafka-ui:latest
Then access the web UI at http://localhost:8080.