配置文件 server.properties
broker.id=0
listeners=PLAINTEXT://:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/home/lixinlei/data/kafka
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=localhost:2181/kafka
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
启动 Broker
bin/kafka-server-start.sh -daemon config/server.properties
创建 Topic
./kafka-topics.sh --zookeeper localhost:2181/kafka --create --topic topic-demo --replication-factor 1 --partitions 4
显示 Topic 信息
./kafka-topics.sh --zookeeper localhost:2181/kafka --describe --topic topic-demo
Consumer 监听 Topic
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic-demo
Producer 发消息到 Broker
./kafka-console-producer.sh --broker-list localhost:9092 --topic topic-demo