首頁>技術>

基礎設施環境

Kafka 環境

Kafka 版本

K8S 1.16

Strimzi Kafka

2.6

場景Kafka 無法動態修改副本,這個時候如果想增加副本數只能透過Kafka 分割槽重分配工具。Kafka 叢集加入新Broker,這個時候原有的Topic 分割槽不會自動分配到新Broker中,因此需要手動遷移。遷移過程遷移本身是需要手動操作的,但是過程是自動的。遷移過程中,Kafka會將新增Broker作為正在遷移分割槽的Follower。新增節點會複製該分割槽的現有資料。複製完成後並加入ISR中,那麼其中一個副本的現有分割槽會被刪除。遷移工具kafka-reassign-partitions.sh (分割槽重分配):用於Broker之前分割槽遷移工具模式 —generate: —execute: —verify:遷移過程檢視Topic 狀態( 推薦使用—bootstrap-server 引數)
[kafka@really-kafka-cluster-zookeeper-0 bin]$ ./kafka-topics.sh  --bootstrap-server kafka-cluster-kafka-bootstrap:9092 --describe  --topic CRM-EVENTSTopic: CRM-EVENTS	PartitionCount: 6	ReplicationFactor: 3	Configs: message.format.version=2.6-IV0,max.message.bytes=52428800,unclean.leader.election.enable=false	Topic: CRM-EVENTS	Partition: 0	Leader: 1	Replicas: 1,2,0	Isr: 1,0,2	Topic: CRM-EVENTS	Partition: 1	Leader: 2	Replicas: 1,2,0	Isr: 2,0,1	Topic: CRM-EVENTS	Partition: 2	Leader: 0	Replicas: 1,2,0	Isr: 0,1,2	Topic: CRM-EVENTS	Partition: 3	Leader: 1	Replicas: 1,2,0	Isr: 1,0,2	Topic: CRM-EVENTS	Partition: 4	Leader: 2	Replicas: 1,2,0	Isr: 2,0,1	Topic: CRM-EVENTS	Partition: 5	Leader: 0	Replicas: 1,2,0	Isr: 0,1,2[kafka@really-kafka-cluster-zookeeper-0 bin]$ ./kafka-topics.sh --describe --zookeeper localhost:12181  --topic CRM-EVENTSTopic: CRM-EVENTS	PartitionCount: 6	ReplicationFactor: 3	Configs: 	Topic: CRM-EVENTS	Partition: 0	Leader: 1	Replicas: 1,2,0	Isr: 1,0,2	Topic: CRM-EVENTS	Partition: 1	Leader: 2	Replicas: 1,2,0	Isr: 2,0,1	Topic: CRM-EVENTS	Partition: 2	Leader: 0	Replicas: 1,2,0	Isr: 0,1,2	Topic: CRM-EVENTS	Partition: 3	Leader: 1	Replicas: 1,2,0	Isr: 1,0,2	Topic: CRM-EVENTS	Partition: 4	Leader: 2	Replicas: 1,2,0	Isr: 2,0,1	Topic: CRM-EVENTS	Partition: 5	Leader: 0	Replicas: 1,2,0	Isr: 0,1,2
副本擴容

Json 檔案

{    "version": 1,    "partitions": [        {            "topic": "CRM-EVENTS",            "partition": 0,            "replicas": [                1,                2,                0            ]        },        {            "topic": "CRM-EVENTS",            "partition": 1,            "replicas": [                1,                2,                0            ]        },        {            "topic": "CRM-EVENTS",            "partition": 2,            "replicas": [                1,                2,                0            ]        },        {            "topic": "CRM-EVENTS",            "partition": 3,            "replicas": [                1,                2,                0            ]        },        {            "topic": "CRM-EVENTS",            "partition": 4,            "replicas": [                1,                2,                0            ]        },        {            "topic": "CRM-EVENTS",            "partition": 5,            "replicas": [                1,                2,                0            ]        }    ]}

關係圖

執行命令
./kafka-reassign-partitions.sh  --zookeeper kafka-cluster-zookeeper-nodes:12181   --reassignment-json-file /tmp/crm-events.json  --execute./kafka-reassign-partitions.sh  --zookeeper kafka-cluster-zookeeper-nodes:12181   --reassignment-json-file /tmp/crm-events.json  --verify
全域性預設配置:
num.partitions=6default.replication.factor=3

5
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 實戰執行手冊——如何建立一個私密語音聊天室,用聲音傳遞思想