日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

kafka命令行操作

發布時間:2023/12/3 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 kafka命令行操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

【README】 kafka集群?

-- kafka集群 3臺機器 centos201 192.168.163.201 centos202?192.168.163.202 centos203?192.168.163.203

【1】主題topic 操作命令

序號

命令

?

1

kafka-topics.sh -- create

新增

2

kafka-topics.sh -- list

查看列表

3

kafka-topics.sh -- delete

刪除

4

kafka-topics.sh -- describe

描述

[root@centos201 ~]# kafka-topics.sh --list --zookeeper centos201:2181 [root@centos201 ~]# [root@centos201 ~]# kafka-topics.sh --create --zookeeper centos201:2181 --topic first --partitions 2 --replication-factor 2 Created topic "first". [root@centos201 ~]# [root@centos201 ~]# kafka-topics.sh --list --zookeeper centos201:2181 first-- log --partitions 2 2個分區 --replication-factor 2 2個副本

?

?1、創建topic后, topic 即 數據的分類; 其會存儲在磁盤,如下:

?

【2】看下 kafak partition 和 replica的數量問題,做個試驗?

1) 新建topic,該topic的數據分布在2個分區,每個分區2個副本,如下:

[root@centos201 logs]# kafka-topics.sh --create --zookeeper centos201:2181 --topic sichuan --partitions 2 --replication-factor 2 Created topic "sichuan".[root@centos201 logs]# kafka-topics.sh --describe --topic sichuan --zookeeper centos201:2181 Topic:sichuan PartitionCount:2 ReplicationFactor:2 Configs:Topic: sichuan Partition: 0 Leader: 2 Replicas: 2,3 Isr: 2,3Topic: sichuan Partition: 1 Leader: 3 Replicas: 3,1 Isr: 3,1 [root@centos201 logs]#

2)我們查看 centos201, 202, 203 的 kafka數據, 如下:?

201: sichuan-1

202: sichuan-0?

203:sichuan-0 sichuan-1?

3)在3臺機器,新建topic-beijing,設置4個分區,每個分區2個副本,如下:

[root@centos201 logs]# kafka-topics.sh --create --zookeeper centos201:2181 --topic beijing --partitions 4 --replication-factor 2 Created topic "beijing". [root@centos201 logs]# [root@centos201 logs]# kafka-topics.sh --describe --topic beijing --zookeeper centos201:2181 Topic:beijing PartitionCount:4 ReplicationFactor:2 Configs:Topic: beijing Partition: 0 Leader: 1 Replicas: 1,2 Isr: 1,2Topic: beijing Partition: 1 Leader: 2 Replicas: 2,3 Isr: 2,3Topic: beijing Partition: 2 Leader: 3 Replicas: 3,1 Isr: 3,1Topic: beijing Partition: 3 Leader: 1 Replicas: 1,3 Isr: 1,3 [root@centos201 logs]#

查看topic在磁盤的目錄結構?

-- 201 [root@centos201 logs]# ll total 268 drwxr-xr-x. 2 root root 141 Dec 21 00:07 beijing-0 drwxr-xr-x. 2 root root 141 Dec 21 00:07 beijing-2 drwxr-xr-x. 2 root root 141 Dec 21 00:07 beijing-3-- 202 [root@centos202 logs]# ll total 192 drwxr-xr-x. 2 root root 141 Dec 21 00:06 beijing-0 drwxr-xr-x. 2 root root 141 Dec 21 00:06 beijing-1-- 203 [root@centos203 logs]# ll total 188 drwxr-xr-x. 2 root root 141 Dec 20 16:07 beijing-1 drwxr-xr-x. 2 root root 141 Dec 20 16:07 beijing-2 drwxr-xr-x. 2 root root 141 Dec 20 16:07 beijing-3

?

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的kafka命令行操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。