欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用Kafka動態(tài)調(diào)整topic分區(qū)partition

 更新時間:2022年12月27日 11:38:38   作者:russle  
這篇文章主要介紹了利用Kafka動態(tài)調(diào)整topic分區(qū)partition問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

Kafka動態(tài)調(diào)整topic分區(qū)partition

在使用kafka時,初期創(chuàng)建topic時所指定的topic屬性有時會需要修改,如何動態(tài)修改kafka topic屬性?kafka提供了命令行工具—kafka-topics.sh.

kafka-topics.sh工具介紹

kafka-topics.sh工具也是我們用來創(chuàng)建topic、查看topic詳情的工具。

直接運行kafka-topics.sh可以看出,它是用來創(chuàng)建、刪除、查看以及更新topic的

root@ubuntu:/opt/kafka_2.11-1.1.0/bin# ./kafka-topics.sh
Create, delete, describe, or change a topic.
Option Description

–alter Alter the number of partitions,
replica assignment, and/or
configuration for the topic.
–config <String: name=value> A topic configuration override for
…

更新或者修改topic

注意:我的kafka版本是1.1.0, 并且我只有一個broker。

1, 首先我們創(chuàng)建一個topic,然后查看詳情

root@ubuntu:/opt/kafka_2.11-1.1.0/bin# ./kafka-topics.sh --create --zookeeper 192.168.119.131:2181 --replication-factor 1 --partitions 4 --topic yqtopic1
Created topic “yqtopic1”.
root@ubuntu:/opt/kafka_2.11-1.1.0/bin#

root@ubuntu:/opt/kafka_2.11-1.1.0/bin# ./kafka-topics.sh --describe --zookeeper 192.168.119.131:2181 --topic yqtopic1
Topic:yqtopic1 PartitionCount:4 ReplicationFactor:1 Configs:
Topic: yqtopic1 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 3 Leader: 0 Replicas: 0 Isr: 0
root@ubuntu:/opt/kafka_2.11-1.1.0/bin#

2,修改剛創(chuàng)建的topic,并查看修改的情況

將分區(qū)數(shù)有4修改為12

root@ubuntu:/opt/kafka_2.11-1.1.0/bin# ./kafka-topics.sh --alter --zookeeper 192.168.119.131:2181 --topic yqtopic1 --partitions 12
WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
Adding partitions succeeded!
root@ubuntu:/opt/kafka_2.11-1.1.0/bin#

root@ubuntu:/opt/kafka_2.11-1.1.0/bin# ./kafka-topics.sh --describe --zookeeper 192.168.119.131:2181 --topic yqtopic1 Topic:yqtopic1 PartitionCount:12 ReplicationFactor:1 Configs:
Topic: yqtopic1 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 4 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 5 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 6 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 7 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 8 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 9 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 10 Leader: 0 Replicas: 0 Isr: 0
Topic: yqtopic1 Partition: 11 Leader: 0 Replicas: 0 Isr: 0
root@ubuntu:/opt/kafka_2.11-1.1.0/bin# ls -al /tmp/kafka-logs/
total 72
drwxr-xr-x 14 root root 4096 Oct 13 14:34 .
drwxrwxrwt 17 root root 4096 Oct 13 14:34 …
-rw-r–r-- 1 root root 0 Oct 13 14:10 cleaner-offset-checkpoint
-rw-r–r-- 1 root root 0 Oct 13 14:10 .lock
-rw-r–r-- 1 root root 4 Oct 13 14:33 log-start-offset-checkpoint
-rw-r–r-- 1 root root 54 Oct 13 14:10 meta.properties
-rw-r–r-- 1 root root 163 Oct 13 14:33 recovery-point-offset-checkpoint
-rw-r–r-- 1 root root 163 Oct 13 14:34 replication-offset-checkpoint
drwxr-xr-x 2 root root 4096 Oct 13 14:20 yqtopic1-0
drwxr-xr-x 2 root root 4096 Oct 13 14:20 yqtopic1-1
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-10
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-11
drwxr-xr-x 2 root root 4096 Oct 13 14:20 yqtopic1-2
drwxr-xr-x 2 root root 4096 Oct 13 14:20 yqtopic1-3
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-4
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-5
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-6
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-7
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-8
drwxr-xr-x 2 root root 4096 Oct 13 14:33 yqtopic1-9
root@ubuntu:/opt/kafka_2.11-1.1.0/bin#

修改后的截圖如下

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Hystrix?Dashboard斷路監(jiān)控儀表盤的實現(xiàn)詳細(xì)介紹

    Hystrix?Dashboard斷路監(jiān)控儀表盤的實現(xiàn)詳細(xì)介紹

    這篇文章主要介紹了Hystrix?Dashboard斷路監(jiān)控儀表盤的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-09-09
  • 利用maven deploy上傳本地jar至私服的方法

    利用maven deploy上傳本地jar至私服的方法

    這篇文章主要介紹了利用maven deploy上傳本地jar至私服的方法,本文結(jié)合實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-02-02
  • Java定時器問題實例解析

    Java定時器問題實例解析

    這篇文章主要結(jié)合實例介紹了java當(dāng)中的定時器的一些問題,有需要的朋友可以參考一下
    2017-04-04
  • idea搭建mybatis環(huán)境配置全過程

    idea搭建mybatis環(huán)境配置全過程

    本文介紹了如何以IDEA搭建MyBatis環(huán)境配置的方法,包括步驟和注意事項,通過本文的介紹,可以輕松地以IDEA搭建MyBatis環(huán)境配置,提高開發(fā)效率
    2023-10-10
  • 淺談一下Java中的悲觀鎖和樂觀鎖

    淺談一下Java中的悲觀鎖和樂觀鎖

    這篇文章主要介紹了一下Java中的悲觀鎖和樂觀鎖,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04
  • spring boot裝載自定義yml文件

    spring boot裝載自定義yml文件

    這篇文章主要為大家詳細(xì)介紹了spring boot裝載自定義yml文件的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • Java解析XML格式數(shù)據(jù)的方法詳解

    Java解析XML格式數(shù)據(jù)的方法詳解

    這篇文章主要介紹了Java解析XML格式數(shù)據(jù)的方法,并展示了較為常用的Java dom來解析XML的例子,需要的朋友可以參考下
    2015-10-10
  • Java 利用binarySearch實現(xiàn)抽獎計算邏輯

    Java 利用binarySearch實現(xiàn)抽獎計算邏輯

    這篇文章主要介紹了Java 利用binarySearch實現(xiàn)抽獎計算邏輯,幫助大家更好的理解和使用Java,感興趣的朋友可以了解下
    2020-12-12
  • Java中this,static,final,const用法詳解

    Java中this,static,final,const用法詳解

    這篇文章主要介紹了Java中this,static,final,const用法詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-07-07
  • 在安卓系統(tǒng)中插入表情到光標(biāo)位置的代碼詳解

    在安卓系統(tǒng)中插入表情到光標(biāo)位置的代碼詳解

    這篇文章主要介紹了在安卓系統(tǒng)中插入表情到光標(biāo)位置的代碼詳解,利用Java代碼在EditText控件中實現(xiàn),需要的朋友可以參考下
    2015-07-07

最新評論