kafka機器下線操作&上線操作

1.下線操作

1.步驟一

新建一個文件名為topics-to-move.json文件內(nèi)容為需要轉(zhuǎn)移的topic

{"topics": [
{"topic": "__consumer_offsets"},
{"topic": "click_stream_topic"},
{"topic": "directory_topic"},
{"topic": "DP_monitor_consumer_topic"},
{"topic": "DP_monitor_provider_topic"},
{"topic": "EC_user_event_rt_topic"},
{"topic": "kafka_topic"}
],
"version":1
}

2.步驟二

執(zhí)行以下操作命令,比如下線0號機器,把0上的數(shù)據(jù)都移到1,2上,腳本內(nèi)容

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topics-to-move.json --broker-list "1,2" --generate

image.png

將新生產(chǎn)的json串賦值到expand-cluster-reassignment.json文件中,

image.png

3.步驟三

開始執(zhí)行轉(zhuǎn)移數(shù)據(jù)操作

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment.json --execute
image.png

使用以下命令查看狀態(tài)

  bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment.json --verify

效果,如下圖所示,數(shù)據(jù)轉(zhuǎn)移完成


image.png

按照上述步驟將所有的0上的topic都轉(zhuǎn)移到1,2服務(wù)器上,0號機器下線升級系統(tǒng)

2.上線操作

與下線操作原理一樣

1.步驟一

執(zhí)行以下操作命令,把數(shù)據(jù)都轉(zhuǎn)移到0,1,2上,執(zhí)行以下腳本

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topics-to-move.json --broker-list "0,1,2" --generate
image.png

2.將內(nèi)容copy到expand-cluster-reassignment2.json文件中,執(zhí)行以下命令

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment2.json --execute
image.png

使用以下命令查看狀態(tài)

  bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment2.json --verify
image.png

效果數(shù)據(jù)恢復(fù)

image.png

3.總結(jié)

測試環(huán)境數(shù)據(jù)量較少,轉(zhuǎn)移非???,線上環(huán)境,topic較多,partitions數(shù)量也多,轉(zhuǎn)移數(shù)據(jù)較慢,一次不要操作太多topic,需要耐心等待觀察。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容