首先配置好zookeeper
修改kafka配置文件
config/server.properties文件中
broker.id=0
port=9092
host.name=192.168.112.91
log.dirs=/usr/local/src/kafka/kafka-logs
zookeeper.connect=master:2181,slave1:2181,slave2:2181
启动kafka
./bin/kafka-server-start.sh -daemon config/server.properties
创建指定topic
kafka-topics.sh --create -zookeeper master:2181 --topic 名称 --partitions 3 --replication-factor 1
kafka-topics.sh --create -zookeeper master:2181 --topic kafka_test --partitions 3 --replication-factor 1
查询所有topic信息
kafka-topics.sh --zookeeper master:2181 --list
启动指定生产者
kafka-console-producer.sh --broker-list master:9092 --topic kafka_test
启动指定消费者
kafka-console-consumer.sh --zookeeper master:2181 --topic kafka_test --from-beginning
标签:--,zookeeper,kafka,topic,2181,master
From: https://www.cnblogs.com/gudeman/p/17338224.html