进入kafka目录下:启动zk

./bin/zookeeperserverstart.shdaemon config/zookeeper.properties

进入kafka目录下:启动kafka

JMX_PORT=19997 bin/kafkaserverstart.shdaemon config/server.properties &

查看启动状态三张方式: jpsml

netstat -nalpt | grep 9092 

 lsofi:9092

创建topic

bin/kafkatopics.shcreatezookeeper lzmhdevnode1:2181,lzmhdevnode2:2181,lzmhdevnode3:2181 —replication-factor 2 —partitions 2 —topic rtb_ad_req_info

bin/kafkatopics.shcreatezookeeper lzmhdev10:2181,lzmhdev10:2182,lzmhdev10:2183 —replication-factor 2 —partitions 2 —topic ad_rtb_spark_log_sum

备注

create创建topic

zookeeper : zk集群 2181端口

replicationfactor副本

partitions : 分区

topic主题名称

查看主题详情

bin/kafkatopics.shdescribezookeeper lzmhdevnode1:2181,lzmhdevnode2:2181,lzmhdev-node3:2181 —topic test1

bin/kafkatopics.shdescribezookeeper lzmhdev10:2181,lzmhdev10:2182,lzmhdev10:2183 —topic ad_rtb_spark_log_sum

bin/kafka-topics.sh —describe –zookeeper lzmhqa01:2181,lzmhqa01:2182,lzmhqa01:2183 —topic ad_rtb_spark_log_sum

备注

describe : 详情

bin/kafka-topics.sh —describe –zookeeper lzmhdev10:2181 —topic ad_rtb_spark_log_sum

查看主题list

bin/kafka-topics.sh —list –zookeeper lzmhdev-node1:2181,lzmhdev-node2:2181,lzmhdev-node3:2181

bin/kafka-topics.sh –zookeeper lzmhdev-node1:2181,lzmhdev-node2:2181,lzmhdev-node3:2181 –list

bin/kafka-topics.sh –zookeeper lzmhdev10:2181,lzmhdev10:2182,lzmhdev10:2183 –list

bin/kafka-topics.sh –zookeeper lzmhqa01:2181,lzmhqa01:2182,lzmhqa01:2183 –list

删除主题

bin/kafka-topics.sh –zookeeper lzmhdev-node1:2181,lzmhdev-node2:2181,lzmhdev-node3:2181 —delete –topic test

bin/kafka-topics.sh –zookeeper lzmhdev-node1:2181 —delete –topic sparktest001

bin/kafka-topics.sh –zookeeper lzmhdev10:2181,lzmhdev10:2182,lzmhdev10:2183 —delete –topic ad_rtb_ad_report_info

bin/kafka-topics.sh –zookeeper lzmhqa01:2181,lzmhqa01:2182,lzmhqa01:2183 —delete –topic ad_rtb_ad_report_info

查看消费组list

bin/kafka-consumergroups.sh —bootstrapserver lzmhdev10:9092,lzmhdev09:9092 —list

bin/kafka-consumergroups.sh —bootstrapserver lzmhqa01:9092 —list

查看消费组信息

bin/kafka-consumergroups.sh –describe —bootstrapserver lzmhdev10:9092 —group adSparkLogCountgDspGroupId

bin/kafka-consumergroups.sh –describe —bootstrapserver lzmhdev10:9092 —group adDataPersistGroupId

bin/kafka-consumergroups.sh –describe —bootstrapserver lzmhqa01:9092 —group adDataPersistGroupId

删除消费组

bin/kafka-consumergroups.sh —bootstrapserver lzmhdev10:9092,lzmhdev09:9092 –delete —group adDataPersistGroupId

bin/kafka-consumer-groups.sh —bootstrapserver lzmhqa01:9092 –delete —group adSparkLogCountGroupId

设置为最初偏移量

bin/kafka-consumer-groups.sh —bootstrapserver lzmhdev10:9092,lzmhdev09:9092 –group adDataPersistGroupId –topic ad_rtb_spark_log_sum —resetoffsets –to-earliest –execute

bin/kafka-consumer-groups.sh —bootstrapserver lzmhqa01:9092 –group adSparkLogCountGroupId –topic rtb_ad_req_info —resetoffsets –to-earliest –execute

设置任意偏移

bin/kafka-consumer-groups.sh —bootstrapserver lzmhdev10:9092,lzmhdev09:9092 –group adDataPersistGroupId –topic ad_rtb_spark_log_sum —resetoffsets –to-offset 4 –execute

bin/kafka-consumer-groups.sh —bootstrapserver lzmhqa01:9092 –group adSparkLogCountGroupId –topic rtb_ad_req_info —reset-offsets –to-offset 5210857 –execute

bin/kafka-consumer-groups.sh —bootstrapserver lzmhqa01:9092 –group lzctest –topic rtb_ad_req_info —reset-offsets –to-offset 13573951 –execute

bin/kafka-consumer-groups.sh —bootstrapserver lzmhqa01:9092 –group lzctest –topic rtb_ad_rep_info –reset-offsets –to-offset 21728285 –execute

——————————————————————————–

创建生产者

bin/kafka-consoleproducer.sh —brokerlist lzmhdev-node1:9092,lzmhdev-node2:9092,lzmhdev-node3:9092 –topic test2

bin/kafka-consoleproducer.sh —brokerlist PLAINTEXT://lzmhdev-node3:9092 –topic test2

bin/kafka-consoleproducer.sh —brokerlist lzmhdev-node1:9092 –topic sparktest001

bin/kafka-consoleproducer.sh —broker-list lzmhdev10:9092,lzmhdev09:9092 –topic ad_rtb_spark_log_sum

bin/kafka-consoleproducer.sh –broker-list lzmhqa01:9092 –topic rtb_ad_req_info

——————————————————————————–

创建消费者

bin/kafka-console-consumer.sh —bootstrap-server lzmhdev-node1:9092,lzmhdev-node2:9092,lzmhdev-node3:9092 –topic test2 –from-beginning –consumer-property group.id=test-group

bin/kafka-console-consumer.sh —bootstrap-server lzmhdev-node1:9092,lzmhdev-node2:9092,lzmhdev-node3:9092 –topic input –from-beginning

bin/kafka-console-consumer.sh —bootstrap-server lzmhdev-node1:9092,lzmhdev-node2:9092,lzmhdev-node3:9092 –topic pTest2 –from-beginning

bin/kafka-console-consumer.sh —bootstrap-server PLAINTEXT://lzmhdev-node3:9092 –topic test2 –from-beginning

bin/kafka-console-consumer.sh –bootstrap-server lzmhdev-node1:9092 –topic sparksink001 –from-beginning

bin/kafka-console-consumer.sh –bootstrap-server lzmhdev10:9092 –topic ad_rtb_spark_log_sum –from-beginning –consumer-property group.id=ad_rtb_log

bin/kafka-console-consumer.sh –bootstrap-server lzmhdev10:9092,lzmhdev09:9092 –topic ad_rtb_spark_log_sum –from-beginning –consumer-property group.id=ad_rtb_log

bin/kafka-console-consumer.sh –bootstrap-server lzmhdev10:9092,lzmhdev09:9092 –topic ad_rtb_spark_log_sum –from-beginning –consumer-property group.id=lzctest

bin/kafka-console-consumer.sh –bootstrap-server lzmhqa01:9092 –topic rtb_ad_rep_info –from-beginning –consumer-property group.id=lzctest

原文地址:https://blog.csdn.net/chenyubei/article/details/130399119

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_19645.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注