linux系统,kafka常用命令
kafka版本过高所致,2.2+=的版本,已经不需要依赖zookeeper来查看/创建topic,新版本使用 --bootstrap-server替换老版本的 --zookeeper-server。
[root@kwephis1160698 bin]# ./kafka-topics.sh --list --zookeeper localhost:2181
Exception in thread "main" joptsimple.UnrecognizedOptionException: zookeeper is not a recognized option
at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510)
at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56)
at joptsimple.OptionParser.parse(OptionParser.java:396)
at kafka.admin.TopicCommand$TopicCommandOptions.<init>(TopicCommand.scala:567)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:47)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
1、开启动./kafka-server-start.sh ../config/server.properties
后台启动./kafka-server-start.sh -daemon ../config/server.properties
或./kafka-server-start.sh ../config/server.properties &
2、停止./kafka-server-stop.sh
3、查看topic列表
./kafka-topics.sh --bootstrap-server localhost:9092 --list
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --list
__consumer_offsets
test
4、创建topic,指定分区数、副本数
./kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test_002
[root@071-009-058-079 bin]# ./kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 3 --topic test_002
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic test_002.
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --list
__consumer_offsets
test
test_002
5、查看topic详情,包括 Partition 个数,副本数,ISR 信息
./kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic test
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic test
Topic: test TopicId: P_594pX_Q7q5ggCdCCjJ4Q PartitionCount: 1 ReplicationFactor: 1 Configs:
Topic: test Partition: 0 Leader: 0 Replicas: 0 Isr: 0
6、修改指定 Topic 的 Partition 个数
./kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic test_002 --partitions 5
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --list
__consumer_offsets
test
test_002
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic test_002
Topic: test_002 TopicId: QLwblYmBSx2HbTsppVokUQ PartitionCount: 3 ReplicationFactor: 1 Configs:
Topic: test_002 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: test_002 Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: test_002 Partition: 2 Leader: 0 Replicas: 0 Isr: 0
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic test_002 --partitions 5
[root@071-009-058-079 bin]#
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic test_002
Topic: test_002 TopicId: QLwblYmBSx2HbTsppVokUQ PartitionCount: 5 ReplicationFactor: 1 Configs:
Topic: test_002 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: test_002 Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: test_002 Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: test_002 Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic: test_002 Partition: 4 Leader: 0 Replicas: 0 Isr: 0
7、删除Topic
./kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic test_002
只会删除zookeeper中的元数据,消息文件须手动删除
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --list
__consumer_offsets
test
test_002
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic test_002
[root@071-009-058-079 bin]# ./kafka-topics.sh --bootstrap-server localhost:9092 --list
__consumer_offsets
test
8、控制台生产消息./kafka-console-producer.sh --broker-list localhost:9092 --topic test
[root@071-009-058-079 bin]# ./kafka-console-producer.sh --broker-list localhost:9092 --topic test
>hello
>nihao
>haha
9、控制台消费消息
a)消费消息从头开始
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic test
b)消费从最新的开始
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --offset latest --partition 0
10、其它(暂未详细补充)
./kafka-run-class.sh kafka.tools.GetOffsetShell --topic test01 --time -1 --broker-list 0.0.0.0:9092 --partitions 2
结果:test01:2:12495
彻底删除topic,要到zookeeper客户端
--(1)删除kafka存储目录(server.properties文件log.dirs配置,默认为"/tmp/kafka-logs")相关topic目录
--(2)如果配置了delete.topic.enable=true直接通过命令删除,如果命令删除不掉,直接通过zookeeper-client 删除掉broker下的topic即可。
step1:cd /usr/local/zookeeper-3.6.2/bin/
step2:进入zookeeper客户端
# ./zkCli.sh
step3:查看有哪些topics./zkCli.sh./
# ls /brokers/topics
step4:删除某一topic
# deleteall /brokers/topics/test02
./kafka-consumer-groups.sh --bootstrap-server kafkadev:9091 --list --command-config ../config/producer.properties
./kafka-consumer-groups.sh --bootstrap-server 0.0.0.0:9092,0.0.0.0:9092,0.0.0.0:9092 --list --command-config ../config/producer.properties
查看kafka服务是否启动
jps -l
ps -ef|grep kafka
linux系统,kafka常用命令的更多相关文章
- Linux 系统巡检常用命令
Linux系统巡检常用命令 # uname -a # 查看内核/操作系统# cat /etc/centos-release # 查看centos操作系统版本# cat /proc/cpuinfo ...
- linux系统的常用命令
linux系统中常用的命令如下(以后经常补充): cd .. 返回上一级 cd use 进入use目录
- 用xshell操作linux系统的常用命令
(1)命令ls——列出文件 ls -la 给出当前目录下所有文件的一个长列表,包括以句点开头的“隐藏”文件 ls a* 列出当前目录下以字母a开头的所有文件 ls -l *.doc 给出当前目录下以. ...
- linux系统学习(常用命令)
今天调休,闲来无事,研究一下linux系统. Linux常用命令: 一:文件管理 ctrl+alt:在虚拟机与windows之间切换ctrl+g:进入linux输入模式 pwd:查看当前目录 ls:列 ...
- Linux系统巡检常用命令-乾颐堂
Linux系统需要定期巡检,以检查服务器软硬件使用情况,相当于对人的体检,确保可以及时发现问题.解决问题,降低损失,常用的巡检命令如下: # uname -a # 查看内核/操作系统/CPU信息 # ...
- Linux系统之-常用命令及技巧
一. 通用命令:1.date :print or set the system date and time2. stty -a: 可以查看或者打印控制字符(Ctrl-C, Ctrl-D, Ctrl-Z ...
- Linux系统一些常用命令(持续增加)
这些命令什么的全是从网上找的,防止忘记,留下来备忘 1.linux服务器如何从另一台服务器拷东西:可以用scp命令scp user@remote.machine:/remote/path /local ...
- LINUX系统一一常用命令
前言 LINUX UNIX Centos RedHat Ubuntu SHELL shell脚本 shell shell命令 类似windows系统的bat 批处理文件 里面都是脚本 CentOS6. ...
- Linux 系统监控常用命令
简介 列举操作系统级监控常用的几个方法,建议收藏使用 CPU top 命令可用于监控系统整体负载,包括cpu.内存使用等,能够实时显示系统中各个进程的资源占用状况 输出样例 top - 19:37:4 ...
- linux系统最常用命令(持续更新)
1.重启服务器 ubuntu系统重启apache:/etc/init.d/apache2 restart linux重启nginx: service nginx restart 重新加载:servic ...
随机推荐
- 力扣128(java&python)-最长连续序列(中等)
题目: 给定一个未排序的整数数组 nums ,找出数字连续的最长序列(不要求序列元素在原数组中连续)的长度. 请你设计并实现时间复杂度为 O(n) 的算法解决此问题. 示例 1: 输入:nums = ...
- 玩转DB里的数据 — 阿里云DMS任务编排之简介和实操
1.任务编排介绍 数据库是企业IT系统里的重要基础设施,里面存储了大量有价值的数据资产,如:交易数据.客户数据.订单数据,等等.其实,数据库在企业里一直扮演着一个数据生产者(Producer)的角色, ...
- ADBPG&Greenplum成本优化之磁盘水位管理
简介:本文我们将通过一个实际的磁盘空间优化案例来说明,如何帮助客户做成本优化. 作者 | 玉翮 来源 | 阿里技术公众号 一 背景描述 目前,企业的核心数据一般都以二维表的方式存储在数据库中.在 ...
- 巧用友盟+U-APM 实现移动端性能优化—启动速度
简介: 移动端性能对用户体验.留存有着至关重要的影响,作为开发者是不是被这样吐槽过,"这个 APP 怎么这么大?"."怎么一直在 APP 封面图转悠,点不进去" ...
- win10 uwp 笔迹书写预测 墨迹书写加速
在 UWP 的 InkCanvas 里自带了预测书写轨迹的功能,开启此功能可以进行书写预测,从而减少书写延迟.本文将告诉大家如何在 UWP 的 InkCanvas 里开启笔迹书写预测功能 在 UWP ...
- 记因为 NVIDIA 显驱错误而让 WPF 应用启动闪退问题
本文记录一个因为 NVIDIA 显卡驱动错误而让 WPF 应用启动闪退问题 表现是 WPF 应用程序,在启动时,立刻闪退.在事件管理器看到的异常代码是 0xC0000005(Access Violat ...
- nginx+uwsgi介绍
一.nginx+uwsgi介绍 pip list # 查看安装过的模块 rpm -q nginx # 查看是否安装某款服务 pip install django == 1.11.11 # 安装djan ...
- LVGL 日志
一.启动日志 在 lv_conf.h 中将 LV_USE_LOG 设置为 1,如下图所示: 二.日志级别 在文件 lvgl/src/misc/lv_log.h 中定义了日志等级,等级是从小到大,所以 ...
- Unity 热更--AssetBundle学习笔记 1.0【AB包资源加载工具类的实现】
工具类封装 通过上文中对AB包加载API的了解和简单使用,对AB包资源加载的几种方法进行封装,将其写入单例类中,如代码展示. 确保每个AB资源包只加载一次: 在LoadAssetBundleManag ...
- ansible(4)--ansible的command和shell模块
1. command模块 功能:在远程主机执行 shell 命令:为默认模块,可省略 -m 选项: 注意:不支持管道命令 |: command模块的常用参数如下: 参数 说明 chdir DIR 执行 ...