Kafka 命令整理

2021-10-10 20:35:41 字數 2535 閱讀 8699

## 建立主題(4個分割槽,2個副本)

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 4 --topic test

## 查詢集群描述

bin/kafka-topics.sh --describe --zookeeper

## topic列表查詢

bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list

## topic列表查詢(支援0.9版本+)

bin/kafka-topics.sh --list --bootstrap-server localhost:9092

## 新消費者列表查詢(支援0.9版本+)

bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --list

## 新消費者列表查詢(支援0.10版本+)

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list

## 顯示某個消費組的消費詳情(僅支援offset儲存在zookeeper上的)

bin/kafka-run-class.sh kafka.tools.consumeroffsetchecker --zookeeper localhost:2181 --group test

## 顯示某個消費組的消費詳情(0.9版本 - 0.10.1.0 之前)

bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --describe --group test-consumer-group

## 顯示某個消費組的消費詳情(0.10.1.0版本+)

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-group

## 生產者

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

## 消費者

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test

## 新生產者(支援0.9版本+)

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test --producer.config config/producer.properties

## 新消費者(支援0.9版本+)

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --new-consumer --from-beginning --consumer.config config/consumer.properties

## 高階點的用法

bin/kafka-******-consumer-shell.sh --brist localhost:9092 --topic test --partition 0 --offset 1234 --max-messages 10

bin/kafka-preferred-replica-election.sh --zookeeper zk_host:port/chroot
bin/kafka-producer-perf-test.sh --topic test --num-records 100 --record-size 1 --throughput 100  --producer-props bootstrap.servers=localhost:9092
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic topic1 --partitions 2
建立規則json

cat > increase-replication-factor.json <

執行bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --execute

驗證

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --verify

kafka相關命令整理

1 啟動kafka zookeeper服務命令 nohup bin zookeeper server start.sh config zookeeper.properties dev null 2 1 2 啟動kafka broker服務命令 nohup bin kafka server start...

kafka常用命令整理

kafka常用命令 在launcher上,cd usr local kafka 2.11 0.9.0.0 bin 檢視topic的list kafka topics.sh zookeeper 192.168.1.60 2181,192.168.1.61 2181,192.168.1.62 2181 ...

kafka 學習整理

一 什麼是吞吐量 吞吐量是指對網路 裝置 埠 虛電路或其他設施,單位時間內成功地傳送 資料的數量 二 什麼是kafka kafka是一種高吞吐量的分布式發布訂閱訊息系統,可以處理消費者規模的 中的所有動作流資料。簡單大白話理解 舉個例子,生產者生產雞蛋,消費者消費雞蛋,生產者生產乙個雞蛋,消費者就消...