Kafka Shell基本命令

2021-09-14 08:46:41 字數 2179 閱讀 2010

出處:

建立kafka topic

bin/kafka-topics.sh --zookeeper node01:2181 --create --topic t_cdr --partitions 30  --replication-factor 2
注:partitions指定topic分割槽數,replication-factor指定topic每個分割槽的副本數

replication-factor副本

bin/kafka-topics.sh --zookeeper node01:2181 --list
bin/kafka-topics.sh --zookeeper node01:2181 --describe --topic t_cdr
bin/kafka-console-producer.sh --broker-list node86:9092 --topic t_cdr
bin/kafka-console-consumer.sh  --zookeeper node01:2181  --topic t_cdr --from-beginning
bin/kafka-run-class.sh kafka.tools.getoffsetshell --topic hive-mdatabase-hostsltable  --time -1 --broker-list node86:9092 --partitions 0
注:time為-1時表示最大值,time為-2時表示最小值

為topic t_cdr 增加10個分割槽

bin/kafka-topics.sh --zookeeper node01:2181  --alter --topic t_cdr --partitions 10
bin/kafka-run-class.sh kafka.admin.deletetopiccommand --zookeeper node01:2181 --topic t_cdr
這個會顯示出consumer group的offset情況, 必須引數為--group, 不指定--topic,預設為所有topic

displays the: consumer group, topic, partitions, offset, logsize, lag, owner for the specified set of topics and consumer group

bin/kafka-run-class.sh kafka.tools.consumeroffsetchecker

required argument: [group]

option description

------ -----------

--broker-info print broker info

--group consumer group.

--help print this message.

--topic comma-separated list of consumer

topics (all topics if absent).

--zkconnect zookeeper connect string. (default: localhost:2181)

example,

bin/kafka-run-class.sh kafka.tools.consumeroffsetchecker --group pv

group topic pid offset logsize lag owner

pv page_visits 0 21 21 0 none

pv page_visits 1 19 19 0 none

pv page_visits 2 20 20 0 none

Kafka Shell基本命令

bin kafka topics.sh zookeeper node01 2181 create topic t cdr partitions 30 replication factor 2 注 partitions指定topic分割槽數,replication factor指定topic每個分割槽...

mysql基本命令總結 mysql基本命令總結

1.在ubuntu上安裝mysql sudo apt get install mysql server sudo apt get install mysql client 2.安裝結束後,用命令驗證是否安裝並啟動成功 sudo netstat tap grep mysql 通過上述命令檢查之後,如果...

kafka shell 命令列操作

kafka的命令列操作 1 產看當前集群中已存在的主題topic bin kafka topics.sh list zookeeper bigdata 2181 2 建立主題topic bin kafka topics.sh create zookeeper bigdata 2181 replica...