kafka命令行操作
生活随笔
收集整理的這篇文章主要介紹了
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 | 描述 |
?
?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命令行操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手机充电怎么充不进去怎回事
- 下一篇: 转:聊聊开发中幂等性问题(*)