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 ...
随机推荐
- 如何高效完成ECS多环境部署?
简介:通过本文,你可以了解到,如何通过云效流水线有效拉通开发与运维,打破二者之间的壁垒墙,让开发与运维高效联动.在软件开发和部署过程中,我们的软件往往需要在不同的运行环境中运行,例如:开发人员本地开 ...
- 代码安全无忧—云效Codeup代码加密技术发展之路
简介: 从代码服务及代码安全角度出发,看看云效代码加密技术如何解决这一问题 代码数据存在云端,如何保障它的安全? 部分企业管理者对于云端代码托管存在一丝担心:我的代码存在云端服务器,会不会被泄露? 接 ...
- C# 获取指定文件夹中所有的文件(包括子文件夹的文件)
有个需求中需要播放指定路径的声音,但你必须要有该路径的声音才可以播放,如果没有该文件则播放默认的声音,该方法用于初始化应用的时候获取指定目录的所有文件,便于后来播放声音的时判断路径是否存在. usin ...
- vue引入一个单独的数据文件
1.新建一个address.js的文件 2.文件内const citys = { "北京市": ["东城区","西城区",& ...
- 将字节数组输入流拷贝成字节数组输出流,将ByteArrayInputStream转成ByteArrayOutputStream
/** 将 ByteArrayInputStream 拷贝成 ByteArrayOutputStream * 将 字节数组输入流 拷贝成 字节数组输出流 */ public static ByteAr ...
- Ubuntu 安装谷歌中文输入法
Ubuntu 安装谷歌中文输入法 下载谷歌拼音:sudo apt-get install fcitx-googlepinyin 点击设置: 第一次打开需要点击安装: 设置完成后重启系统 点击右上角键盘 ...
- scp本地服务器和远程服务器拷贝文件
上传本地文件到服务器 scp 本地路径 用户名@远程服务器ip:远程路径 下载文件 scp 用户名@远程服务器ip:远程路径 本地路径 -r 是上传下载本地目录到远程 远程文件
- jeecg-boot中导出excel冲突问题
jeecg-boot自带的库是autopoi,如果自定义导出excel引入poi,则需要POI版本要保持一致,否则会出现冲突的情况,导致这2个都用不了的情况. Autopoi底层用的是POI库,poi ...
- three.js教程6-加载外部三维模型gltf
1.建模软件 3D美术常用的三维建模软件,比如Blender.3damx.C4D.maya等等 Blender(轻量.免费.开源) 3damx C4D maya 机械相关:SW.UG等 建筑相关:草图 ...
- ES 2024 新特性
ECMAScript 2024 新特性 ECMAScript 2024, the 15th edition, added facilities for resizing and transferrin ...