kafka服务端的最常见命令
2024-12-11 本文已影响0人
hemingkung
kafka的一些常用命令:
1、生产-消费
①生产者发送消息至指定的topic(topic1)
kafka-console-producer.sh --broker-list localhost:9092 --topic topic1
②消费者消费指定topic(topic1)的消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic1
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic1 --from-beginning
2、kafka启动
①需改配置信息
broker_id 集群下需要修改
logs_dir需要修改
zookeeper_connect:配置成集群/kafka
②以配置信息启动
kafka-server-start.sh config/server.properties
3、topic信息创建查询
创建一个16分区 4副本的
kafka-topics.sh --create --topic topic1 --bootstrap-server localhost:9092 --partitions 16 --replication-factor 4
查看创建的topic1分区明细
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic topic1