首页 技术 正文
技术 2022年11月9日
0 收藏 820 点赞 2,133 浏览 1296 个字
  • kafka启动
bin/kafka-server-start.sh -daemon config/server.properties
  • 创建topic
bin/kafka-topics.sh -zookeeper localhost:2181 --create --partitions 1 --replication-factor 1 --topic test

--partitions指定分区数,--replication-factor表示副本数

  • 查看topic列表
bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-topics.sh --list --bootstrap-server localhost:9092

— 查看集群描述

bin/kafka-topics.sh --describe --zookeeper localhost:2181
  • 删除topic
./bin/kafka-topics --delete --zookeeper localhost:2181 --topic test
  • 生产消息
bin/kafka-producer-perf-test.sh --topic test --throughput -1 --record-size 10 --num-records 500000 --producer-props bootstrap.servers=localhost:9092
  • 消费消息
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
  • 获取topic消息数
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test --time -1
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test --time -2

--time -1表示要获取topic所有分区当前的最大位移, --time -2表示获取当前最早位移。两个命令输出相减便可得到所有分区当前的消息总数。在没有删除过消息的情况下,第二个命令的结果是0。

  • 查询消费组列表
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
  • 查询某个消费组的消费详情
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-group
  • 压力测试
bin/kafka-producer-perf-test.sh --topic test --num-records 100 --record-size 1 --throughput 100 --producer-props bootstrap.servers=localhost:9092
上一篇: MS入门学习笔记
下一篇: udp组播的实现
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,487
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,486
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,126
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289