安装启动kafka

vim kafka/config/server.properties

#确保唯一
broker.id=0
#允许删除主题
delete.topic.enable=true
# 指定数据文件所在目录
log.dirs=/var/local/kafka/logs
#zookeeper 的连接地址
zookeeper.connect=localhost:2181

启动kafka

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

#查看进程,带上全类名

jps -l 

#创建主题,一个分区,一个备份

bin/kafka-topics.sh --create --zookeeper localhost:2181 --partitions 1 --replication-factor 1 --topic first

#查看kafka的主题

bin/kafka-topics.sh --list --zookeeper localhost:2181

#生产者产生数据

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic first

#启动消费者

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic first --from-beginning

不跟zk交互,改跟kafka交互,提高效率

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first --from-beginning

猜你喜欢

转载自www.cnblogs.com/dongma/p/9912348.html
今日推荐