溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

【Kafka】常用命令

發(fā)布時(shí)間:2020-08-05 19:33:38 來(lái)源:網(wǎng)絡(luò) 閱讀:449 作者:巧克力黒 欄目:大數(shù)據(jù)

創(chuàng)建Topic

kafka-topics.sh --create --bootstrap-server localhost:9092 --topic abtest  --partitions 2 --replication-factor 1   

查看Topic都有哪些

kafka-topics.sh --list --zookeeper localhost:2181

生產(chǎn)者,將文件中的數(shù)據(jù)寫(xiě)入Kafka生產(chǎn)者

kafka-console-producer.sh --broker-list localhost:9092 --topic order_topic < abc.txt

消費(fèi)者,從最開(kāi)始的位移,消費(fèi)Topic中的數(shù)據(jù)

kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic order_topic  --from-beginning

重置Consumer Group的Offset到最新位移

kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group group_name_1 --reset-offsets --topic order_topic --to-latest --execute

查看消費(fèi)者組Consumer Group位移

[homework@test ~]$ kafka-consumer-groups.sh --bootstrap-server  host1:9092,host2:9092  --describe --group groupname_1

TOPIC                 PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID     HOST            CLIENT-ID

order                 5          20781271        20781556        285             -               -               -
order                 1          10553765        10554032        267             -               -               -
order                 2          10634508        10634808        300             -               -               -
order                 7          10375128        10375355        227             -               -               -
order                 6          10435147        10435467        320             -               -               -
order                 0          10640342        10640643        301             -               -               -
order                 3          13762141        13762478        337             -               -               -
order                 8          11176468        11176707        239             -               -               -
order                 4          10443088        10443320        232             -               -               -
向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI