Kafka 1.0.0集群增加节点
原有环境
| 主机名 | IP 地址 | 安装路径 | 系统 |
| sht-sgmhadoopdn-01 | 172.16.101.58 |
/opt/kafka_2.12-1.0.0 /opt/kafka(软连接) |
CentOS Linux release 7.3.1611 (Core) |
| sht-sgmhadoopdn-02 | 172.16.101.59 | ||
| sht-sgmhadoopdn-03 | 172.16.101.60 |
向集群增加节点
sht-sgmhadoopdn-04(172.16.101.66)
过程
一. 新节点配置和集群节点环境一致
二. zookeeper配置
1. 集群各节点增加新节点的zookeeper配置
tickTime=
initLimit=
syncLimit=
dataDir=/opt/kafka/data
clientPort=
server.=sht-sgmhadoopdn-::
server.=sht-sgmhadoopdn-::
server.=sht-sgmhadoopdn-::
server.=sht-sgmhadoopdn-::
2. 新节点创建server-id
# echo > /opt/kafka/data/myid
3. 启动zookeeper
# /opt/kafka/bin/zookeeper-server-start.sh -daemon /opt/kafka/config/zookeeper.properties
4. 查看新节点zookeeper状态
# echo stat | nc sht-sgmhadoopdn- | grep Mode
Mode: follower
三. kafka配置
1.新节点配置文件server.properties
broker.id=
listeners=PLAINTEXT://172.16.101.66:9092
advertised.listeners=PLAINTEXT://172.16.101.66:9092
log.dirs=/opt/kafka/data
zookeeper.connect=sht-sgmhadoopdn-:,sht-sgmhadoopdn-:,sht-sgmhadoopdn-:,sht-sgmhadoopdn-:
2. 向集群中所有节点kafka配置文件增加对新zookeeper节点的支持
zookeeper.connect=sht-sgmhadoopdn-:,sht-sgmhadoopdn-:,sht-sgmhadoopdn-:,sht-sgmhadoopdn-:
3. 启动kafka
/opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties
4. 查看集群
# echo dump | nc sht-sgmhadoopdn- | grep broker
/brokers/ids/
/brokers/ids/
/brokers/ids/
/brokers/ids/
四. 分区重分配
1. 查看现有集群的topic以及分区方案
# kafka-topics.sh --zookeeper 172.16.101.58:,172.16.101.59:,172.16.101.60:,172.16.101.66: --list
__consumer_offsets
test-topic # kafka-topics.sh --zookeeper 172.16.101.58:,172.16.101.59:,172.16.101.60:,172.16.101.66: --describe --topic test-topic
Topic:test-topic PartitionCount: ReplicationFactor: Configs:
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
可以看到test-topic的6个分区均集中在在老集群中,新添加的节点并未参与分区方案。
现在将执行分区重分配,将数据均匀分散在左右节点上
2. 创建json文件
# cat topics-to-move.json
{"topics":[{"topic":"test-topic"}],"version":}
3. 产生分区分配方案
[root@sht-sgmhadoopdn-01 kafka]# kafka-reassign-partitions.sh --zookeeper 172.16.101.58:2182,172.16.101.59:2182,172.16.101.60:2182,172.16.101.66:2182 --topics-to-move-json-file topics-to-move.json --broker-list "0,1,2,3" --generate
Current partition replica assignment
{"version":1,"partitions":[{"topic":"test-topic","partition":0,"replicas":[1,2,0],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":5,"replicas":[0,1,2],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":3,"replicas":[1,2,0],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":2,"replicas":[0,1,2],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":4,"replicas":[2,0,1],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":1,"replicas":[2,0,1],"log_dirs":["any","any","any"]}]} Proposed partition reassignment configuration
{"version":1,"partitions":[{"topic":"test-topic","partition":0,"replicas":[3,0,1],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":5,"replicas":[0,2,3],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":3,"replicas":[2,3,0],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":2,"replicas":[1,2,3],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":4,"replicas":[3,1,2],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":1,"replicas":[0,1,2],"log_dirs":["any","any","any"]}]}
注意“Proposed partition reassignment configuration”为kafka提供的分区方案,实际上并没有真正执行,我们将该分区方案保存为另外一个文件expand_cluster_reassignment.json,然后再真正执行这个分区方案。
4. 执行分区重分配
# kafka-reassign-partitions.sh --zookeeper 172.16.101.58:,172.16.101.59:,172.16.101.60:,172.16.101.66: --reassignment-json-file expand_cluster_reassignment.json --execute
Current partition replica assignment {"version":,"partitions":[{"topic":"test-topic","partition":,"replicas":[,,],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":,"replicas":[,,],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":,"replicas":[,,],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":,"replicas":[,,],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":,"replicas":[,,],"log_dirs":["any","any","any"]},{"topic":"test-topic","partition":,"replicas":[,,],"log_dirs":["any","any","any"]}]} Save this to use as the --reassignment-json-file option during rollback
Successfully started reassignment of partitions.
通过--verify查看分区进程
# kafka-reassign-partitions.sh --zookeeper 172.16.101.58:,172.16.101.59:,172.16.101.60:,172.16.101.66: --reassignment-json-file expand_cluster_reassignment.json --verify
Status of partition reassignment:
Reassignment of partition test-topic- is still in progress
Reassignment of partition test-topic- completed successfully
Reassignment of partition test-topic- is still in progress
Reassignment of partition test-topic- is still in progress
Reassignment of partition test-topic- is still in progress
Reassignment of partition test-topic- is still in progress
5. 等到上述分区过程结束后,再次查看topic分区情况
# kafka-topics.sh --zookeeper 172.16.101.58: --describe --topic test-topic
Topic:test-topic PartitionCount: ReplicationFactor: Configs:
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Topic: test-topic Partition: Leader: Replicas: ,, Isr: ,,
Kafka 1.0.0集群增加节点的更多相关文章
- Docker swarm集群增加节点和删除节点
Docker swarm集群增加节点 docker swarm初始化 docker swarm init docker swarm 增加节点 在已经初始化的机器上执行:# docker swarm j ...
- Redis集群增加节点和删除节点
本文主要是承接上一篇文章Redis集群的离线安装成功以后,我们如何进行给集群增加新的主从节点(集群扩容)以及如何从集群中删除节点(集群缩容),也就是集群的伸缩,集群伸缩的原理是控制虚拟槽和数据在节点之 ...
- kubeadm 生成的token过期后,集群增加节点
通过kubeadm初始化后,都会提供node加入的token: You should now deploy a pod network to the cluster. Run "kubect ...
- Hadoop集群 增加节点/增加磁盘
在虚拟机中新建一个机器. 设置静态IP 将修改/etc/hosts 192.168.102.10 master 192.168.102.11 slave-1 192.168.102.12 slave- ...
- 全网最新的nacos 2.1.0集群多节点部署教程
原文链接:全网最新的nacos 2.1.0集群多节点部署教程-语雀 基本信息 进度整理中 版本 2.1.0 版本发布日期 2022-04-29 git revision number b5845313 ...
- centos7多节点部署redis4.0.11集群
1.服务器集群服务器 redis节点node-i(192.168.0.168) 7001,7002node-ii(192.168.0.169) 7003,7004node-iii(192.168.0. ...
- Redis-5.0.5集群配置
版本:redis-5.0.5 参考:http://redis.io/topics/cluster-tutorial. 集群部署交互式命令行工具:https://github.com/eyjian/re ...
- Redis-4.0.11集群配置
版本:redis-3.0.5 redis-3.2.0 redis-3.2.9 redis-4.0.11 参考:http://redis.io/topics/cluster-tutorial. 集群 ...
- Hadoop1.0之集群搭建
VirtualBox虚拟机 下载地址 下载择操作系统对应的基础安装包 下载扩展包(不区分操作系统) http://www.oracle.com/technetwork/cn/server-storag ...
随机推荐
- 多线程之CEvent
最近工作中要维护一个windows模块,用到了mfc中的CEvent类.这算是很久很久以前的老朋友了吧,估计和我超过10年没见过面了,不过工作就是工作,技术上来不得半点含糊,所以还是重新认识一下这位老 ...
- Delphi中Move、CopyMemory操作
字串转字节数组 一.CopyMemory var s:PAnsiChar; ary:TArray<Byte>; bt:Byte; begin s:='Form Delphi'; SetLe ...
- get_class __class__ get_called_class 分析记录
首先看代码: class A { use T { T::say as aTsay; } public function say() { echo 'a__class__:' . __CLASS__ . ...
- 【DOM练习】淘宝购物车
HTML: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...
- centos7安装pip
转自:https://www.cnblogs.com/mangoVic/p/6428369.html 默认情况下,centos7是没有pip的,可以通过如下命令安装 首先安装epel扩展源: yum ...
- 利用multiprocessing.managers开发跨进程生产者消费者模型
研究了下multiprocessing.managers,略有收获,随笔一篇: 核心思路是构造一个manager进程,这个进程可以通过unix socket或tcp socket与其它进程通信:因为利 ...
- Redis连接池
package com.lee.utils; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; impor ...
- 第十六节 BOM基础
打开.关闭窗口 open:蓝色理想运行代码功能 <button onclick="window.open('http://www.baidu.com')">打开窗口&l ...
- opencv学习之路(34)、SIFT特征匹配(二)
一.特征匹配简介 二.暴力匹配 1.nth_element筛选 #include "opencv2/opencv.hpp" #include <opencv2/nonfree ...
- Vue学习(一)Vue目录结构
安装教程网上一大把,可以自己搜索.记录下学习过程. 认识下Vue的目录结构,取自:https://www.cnblogs.com/dragonir/p/8711761.html vue 文件目录结构详 ...