节点服役
创建需要均衡到新节点的topic,生成均衡计划
[ atguigu@hadoop102 kafka] $ vim topics-to-move.json
{
"topics" : [
{ "topic" : "first" }
] ,
"version" : 1
}
[ atguigu@hadoop102 kafka] $ bin/kafka-reassign-partitions.sh --
bootstrap-server hadoop102:9092 --topics-to-move-json-file
topics-to-move.json --broker-list "0,1,2,3" --generate
Current partition replica assignment
{ "version" :1,"partitions" :[ { "topic" : "first" ,"partition" :0,"replic
as" :[ 0,2 ,1] ,"log_dirs" :[ "any" ,"any" ,"any" ] } ,{ "topic" : "first" ,"par
tition" :1,"replicas" :[ 2,1 ,0] ,"log_dirs" :[ "any" ,"any" ,"any" ] } ,{ "to
pic" : "first" ,"partition" :2,"replicas" :[ 1,0 ,2] ,"log_dirs" :[ "any" ,"
any" ,"any" ] } ] }
Proposed partition reassignment configuration
{ "version" :1,"partitions" :[ { "topic" : "first" ,"partition" :0,"replic
as" :[ 2,3 ,0] ,"log_dirs" :[ "any" ,"any" ,"any" ] } ,{ "topic" : "first" ,"par
tition" :1,"replicas" :[ 3,0 ,1] ,"log_dirs" :[ "any" ,"any" ,"any" ] } ,{ "to
pic" : "first" ,"partition" :2,"replicas" :[ 0,1 ,2] ,"log_dirs" :[ "any" ,"
any" ,"any" ] } ] }
根据生成的均衡计划创建topic副本存储计划执行文件
[ atguigu@hadoop102 kafka] $ vim increase-replication-factor.json
{ "version" :1,"partitions" :[ { "topic" : "first" ,"partition" :0,"replic
as" :[ 2,3 ,0] ,"log_dirs" :[ "any" ,"any" ,"any" ] } ,{ "topic" : "first" ,"par
tition" :1,"replicas" :[ 3,0 ,1] ,"log_dirs" :[ "any" ,"any" ,"any" ] } ,{ "to
pic" : "first" ,"partition" :2,"replicas" :[ 0,1 ,2] ,"log_dirs" :[ "any" ,"
any" ,"any" ] } ] }
执行topic副本存储计划执行文件
[ atguigu@hadoop102 kafka] $ bin/kafka-reassign-partitions.sh --
bootstrap-server hadoop102:9092 --reassignment-json-file
increase-replication-factor.json --execute
验证副本存储计划
[ atguigu@hadoop102 kafka] $ bin/kafka-reassign-partitions.sh --
bootstrap-server hadoop102:9092 --reassignment-json-file
increase-replication-factor.json --verify
Status of partition reassignment:
Reassignment of partition first-0 is complete.
Reassignment of partition first-1 is complete.
Reassignment of partition first-2 is complete.
Clearing broker-level throttles on brokers 0,1 ,2,3
Clearing topic-level throttles on topic first
节点退役