kafka2.8脱离ZooKeeper


在config目录下多了一个kraft目录,在该目录中有一套新的配置文件,可以直接脱离ZooKeeper运行

 

配置kraft目录中的server.properties文件

单机的话主要是修改下面的配置

advertised.listeners=PLAINTEXT://localhost:9092

将localhost修改为IP。如果不改为IP,其他服务器连接不上

advertised.listeners=PLAINTEXT://10.10.14.237:9092

 

通过现在三行命令,即可开启一个单机的broker

/usr/local/kafka/bin/kafka-storage.sh random-uuid

/usr/local/kafka/bin/kafka-storage.sh format -t 1DViwWWpQf63N6bhJFAgzQ -c /usr/local/kafka/config/kraft/server.properties

/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/kraft/server.properties

#后台启动
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/kraft/server.properties

这样脱离ZooKeeper的kafka就启动了,当前版本还是测试阶段,所以官方不推荐使用。

 

创建一个topic

/usr/local/kafka/bin/kafka-topics.sh --create --topic test --partitions 3 --replication-factor 1 --bootstrap-server localhost:9092

查看topic信息

/usr/local/kafka/bin/kafka-topics.sh --describe --topic test --bootstrap-server localhost:9092

删除topic

/usr/local/kafka/bin/kafka-topics.sh --delete --topic test --bootstrap-server localhost:9092

发送

/usr/local/kafka/bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test

接收

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

 查看topic有多少条数据

/usr/local/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test

 获取所有topic列表

/usr/local/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM