apache kafka遷移與擴容工具用法

來源:互聯網
上載者:User

標籤:apache kafka遷移與擴容   kafka遷移與擴容   kafka擴容   kafka新增分區   kafka遷移topic   

 kafka遷移與擴容工具使用

參考官網site:https://cwiki.apache.org/confluence/display/KAFKA/Replication+tools#Replicationtools-6.ReassignPartitionsTool

說明:

當我們對kafka叢集擴容時,需要滿足2點要求:

  1. 將指定topic遷移到叢集內新增的node上。
  2. 將topic的指定partition遷移到新增的node上。
1. 遷移topic到新增的node上假如現在一個kafka叢集運行三個broker,broker.id依次為101,102,103,後來由於業務資料突然暴增,需要新增三個broker,broker.id依次為104,105,106.目的是要把push-token-topic遷移到新增node上。指令碼(json格式)如下所示:[email protected]:$  ./bin/kafka-reassign-partitions.sh --zookeeper 192.168.2.225:2183/config/mobile/mq/mafka
--topics-to-move-json-file  migration-push-token-topic.json --broker-list"104,105,106"  --execute

 指令碼migration-push-token-topic.json檔案內容如下:

{
"topics":
[
{
"topic": "push-token-topic"
}
],
"version":1
}

2.topic修改(replicats-factor)副本個數

lizh[email protected]:$ ./bin/kafka-reassign-partitions.sh --zookeeper   192.168.2.225:2183/config/mobile/mq/mafka

--reassignment-json-file  replicas-update-push-token-topic.json  --execute

假如初始時push-token-topic為一個副本,為了提高可用性,需要改為2副本模式。

指令碼replicas-push-token-topic.json檔案內容如下:

{
        "partitions":
                [
                {
                        "topic": "log.mobile_nginx",
                        "partition": 0,
                        "replicas": [101,102,104]
                },
                {
                        "topic": "log.mobile_nginx",
                        "partition": 1,
                        "replicas": [102,103,106]
                },
{
"topic": "xxxx",
"partition": 數字,
"replicas": [數組]
}                
],             
        "version":1
}

3.topic的分區擴容用法

a.先擴容分區數量,指令碼如下:

例如:push-token-topic初始分區數量為12,目前到增加到15個

[email protected]:$ ./bin/kafka-topics.sh --zookeeper 192.168.2.225:2183/config/mobile/mq/mafka  --alter   --partitions 15   --topic   push-token-topic

b.設定topic分區副本

[email protected]:$ ./bin/kafka-reassign-partitions.sh --zookeeper  192.168.2.225:2183/config/mobile/mq/mafka

--reassignment-json-file partitions-extension-push-token-topic.json  --execute

指令碼partitions-extension-push-token-topic.json檔案內容如下:

{        "partitions":                [                {                        "topic": "push-token-topic",                        "partition": 12,                        "replicas": [101,102]                },                {                        "topic": "push-token-topic",                        "partition": 13,                        "replicas": [103,104]                },                {                        "topic": "push-token-topic",                        "partition": 14,                        "replicas": [105,106]                }                ],                     "version":1}




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.