坚持动作,降低要求,保持学习惯性

孟令正的博客

即使再小的帆也能远航

kafka3.0版本命令

本文章向大家介绍kafka3.0常用命令,主要包括kafka3.0常用命令使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

kafka集群不依赖Kraft启动

不需要修改id之类
1、先启动zookeeper(3台)

cd /opt/bdp/kafka_2.13-3.0.1

2、进入kafka的安装目录(三台)

cd /opt/bdp/kafka_2.13-3.0.1

3、启动(三台)

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

2、原(也是正确的)

1、进入kafka的bin目录:先启动内置zookeeper

执行命令:zookeeper-server-start.sh ../config/zookeeper.properties

后台运行命令:zookeeper-server-start.sh -daemon ../config/zookeeper.properties

2、启动kafka

执行命令:./kafka-server-start.sh ../config/server.properties,主义前面 ./ ,不然启动不了。

后台启动命令:./kafka-server-start.sh -daemon ../config/server.properties

3、常用命令

生产命令:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic frist0401

消费命令:
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic frist0401

查看当前服务器中的所有 topic

bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
bin/kafka-topics.sh --bootstrap-server node01:9092,node02:9092,node03:9092 --list

创建topic

bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --partitions 1 --replication-factor 1 --topic first0406

3、查看 first 主题的详情

bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic first0406

4、修改分区数(注意:分区数只能增加,不能减少)

bin/kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic first --partitions 3

5、再次查看 first 主题的详情

bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic first

6、删除 topic

bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic first

posted @ 2023-03-13 16:32  mlzheng  阅读(287)  评论(0)    收藏  举报