dockerkafka

1ȡ
docker pull wurstmeister/zookeeper  
docker pull wurstmeister/kafka 

2
docker run -di --network=docker-network --ip=172.19.0.60 --name=zk_01 -p 2181:2181  --privileged=true wurstmeister/zookeeper /bin/bash
docker run -di --network=host --name=kafka_01 -v /etc/localtime:/etc/localtime  --privileged=true wurstmeister/kafka:latest /bin/bash

3޸kafkaļserver.properties
cd /opt/kafka_2.12-2.5.0/config/
vi server.properties

server.propertiesļʾ
broker.id=0   										# ʾbrokerıţȺжbrokerÿbrokerıҪõĲͬ
listeners=PLAINTEXT://192.168.23.131:9092 			# brokderṩķڵַ
log.dirs=/tmp/kafka-logs  							# ôϢ־ļĵַ
zookeeper.connect=172.19.0.60:2181  				# KafkaZookeeperȺַѧZookeeperKafkaװ

4kafka
bin/kafka-server-start.sh config/server.properties

5
bin/kafka-topics.sh --zookeeper 172.19.0.60:2181 --create --topic itheima --partitions 2 --replication-factor 1				# ⣬ʾӣʾÿһеĸ()ܳbroker
bin/kafka-topics.sh --zookeeper 172.19.0.60:2181 --list															# 鿴е
bin/kafka-topics.sh --zookeeper 172.19.0.60:2181 --describe --topic itheima											# 鿴ϸϢ
bin/kafka-topics.sh --delete --zookeeper 172.19.0.60:2181 --topic itheima											# ɾ

bin/kafka-console-consumer.sh --bootstrap-server 192.168.23.131:9092 --topic itheima								# һ
bin/kafka-console-producer.sh --broker-list 192.168.23.131:9092 --topic itheima										# һ

޸ķ
ӷ
bin/kafka-topics.sh --alter --zookeeper 172.19.0.60:2181 --topic itheima --partitions 3

޸ķʱӷ partition ᱨ´Ϣ
bin/kafka-topics.sh --alter --zookeeper 172.19.0.60:2181 --topic heima --partitions 2