当前位置: 首页 > news >正文

Elasticsearch7.x 集群迁移文档

一、集群样例信息

集群名称:escluster-ali-test

1、源集群:(source_cluster)
节点IP节点名称节点角色是否为master节点
10.200.112.149es2.gj1.china-job.cndata,master
10.200.112.151es1.gj1.china-job.cndata,master
10.200.112.153es3.gj1.china-job.cndata,master
2、目标集群:(target_cluster)
节点IP节点名称节点角色是否为master节点
172.31.2.84es1.gj2.china-job.cndata,master
172.31.0.147es2.gj2.china-job.cndata,master
172.31.0.94es3.gj2.china-job.cndata,master

二、操作步骤

1、集群改造

源集群和目标集群合并成一个大集群,修改目标集群的配置信息。

1.1、目标集群改造
  • 关闭目标集群(配置变更前需保证集群是关闭的)
  • 修改目标集群所有节点的集群名称,与源集群名称一样 cluster.name: target_cluster
  • 修改目标集群所有节点dscovery.zen.ping.unicast.hosts:,把源集群节点IP加入。
    ##指向老节点
    cluster.initial_master_nodes: [“es1.gj1.china-job.cn”,“es2.gj1.china-job.cn”,“es3.gj1.china-job.cn”]
    discovery.zen.ping.unicast.hosts: [“10.200.112.149”, “10.200.112.151”,“10.200.112.153”,“172.31.2.84”, “172.31.0.147”,“172.31.0.94”]

discovery.seed_hosts:

  • 192.168.1.10:9300
  • 192.168.1.11
  • seeds.mydomain.com
    cluster.initial_master_nodes:
  • master-node-a
  • master-node-b
  • master-node-c
1.2、关闭源集群索引均衡功能

防止目标集群节点还未全部加入完成,数据开始迁移。

curl -XPUT "http://10.200.112.149:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
{"transient" :{"cluster.routing.rebalance.enable" : "none"}
}'
1.3、启动目标集群加入到源集群

同时保证集群运行的状态为green。

1.4、检查

检查新集群健康状态、节点信息、索引状态

curl -XGET "http://10.200.112.149:9200/_cluster/health?pretty"
curl -XGET "http://10.200.112.149:9200/_cat/nodes?v"
curl -XGET "http://10.200.112.149:9200/_cat/indices?v"

2、数据迁移

1、均衡开启和节点下线

开启均衡和源集群节点数据下线,数据会迁移到目标集群

curl -XPUT "http://172.31.2.84:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"transient": {"cluster.routing.allocation.exclude._ip": "10.200.112.149,10.200.112.151,10.200.112.153","cluster.routing.rebalance.enable" : "all"}
}'或者
curl -XPUT "http://172.31.2.84:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"transient": {"cluster.routing.allocation.exclude._name": "es2.gj1.china-job.cn,es1.gj1.china-job.cn,es3.gj1.china-job.cn","cluster.routing.rebalance.enable" : "all"}
}'
2、检查数据迁移状态,节点迁移结束标准:
curl -X GET '172.31.2.84:9200/_nodes/10.200.112.149/stats/indices/docs?pretty'
curl -X GET '172.31.2.84:9200/_nodes/10.200.112.151/stats/indices/docs?pretty'
curl -X GET '172.31.2.84:9200/_nodes/10.200.112.153/stats/indices/docs?pretty' 

源集群所有节点数据迁移完成,执行结果都为:

"indices" : {"docs" : {"count" : 0,"deleted" : 0}}
3、参数调整

迁移中,可能有IO,网络资源不足情况,可以做一些调整https://www.elastic.co/guide/en/elasticsearch/reference/6.5/shards-allocation.html

  • cluster.routing.allocation.node_concurrent_incoming_recoveries
  • cluster.routing.allocation.node_concurrent_outgoing_recoveries
  • cluster.routing.allocation.node_concurrent_recoveries
  • cluster.routing.allocation.node_initial_primaries_recoveries
curl -XPUT "http://172.31.2.84:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"transient": {"cluster.routing.allocation.cluster_concurrent_rebalance": 6,"cluster.routing.allocation.node_concurrent_recoveries": 10}
}'
4、调整恢复速度

如果索引恢复速度慢,可以对恢复速度进行修改:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/recovery.html

  • indices.recovery.max_bytes_per_sec
curl -XPUT "http://172.31.2.84:9200/_cluster/settings?flat_settings=true&pretty" -H 'Content-Type: application/json' -d'
{"transient": {"indices.recovery.max_bytes_per_sec": "60mb"}
}'

三、更改客户端连接到目标集群节点

将所有连接迁移ES集群的客户端应用ES集群连接配置,由老集群节点调整为新集群节点信息,即:“10.200.112.149”, “10.200.112.151”,“10.200.112.153” 变更为 “172.31.2.84”, “172.31.0.147”,“172.31.0.94”

客户端切换完成后,检查客户端服务与ES集群连接是否正常,对ES的读写是否异常。

四、更改新节点配置文件,并重启(业务需要停止读写)

cluster.initial_master_nodes: [“es1.gj2.china-job.cn”,“es2.gj2.china-job.cn”,“es3.gj2.china-job.cn”,“es3.gj1.china-job.cn”]
discovery.zen.ping.unicast.hosts: [“10.200.112.149”, “10.200.112.151”,“10.200.112.153”,“172.31.2.84”, “172.31.0.147”,“172.31.0.94”]

五、源集群关闭

1、先关闭源集群非master节点

同时检查当前运行集群状态是否为green;如果出现异常,停止操作,恢复当前关闭节点。

操作顺序操作动作
110.200.112.151
210.200.112.153

2、最后关闭源集群master节点

[10.200.112.149, 10.200.112.151,10.200.112.153,172.31.2.84, 172.31.0.147,172.31.0.94]
同时检查当前运行集群状态是否为green。如果出现异常,可以配置discovery.zen.ping.unicast.hosts: [“10.200.112.149”, “10.200.112.151”,“10.200.112.153”,“172.31.2.84”, “172.31.0.147”,“172.31.0.94”],恢复当前关闭节点。

操作顺序操作动作
110.200.112.149

3、检查

关闭所有源集群节点后,检查目标集群是否健康,索引数据是否正常;如果没有问题,分离成功,数据迁移完毕。

六、更改新节点配置文件,并重启

cluster.initial_master_nodes: [“es1.gj2.china-job.cn”,“es2.gj2.china-job.cn”,“es3.gj2.china-job.cn”]
discovery.zen.ping.unicast.hosts: [“172.31.2.84”, “172.31.0.147”,“172.31.0.94”]

七、恢复目标集群配置正常

1、取消节点下线配置

curl -XPUT "http://172.31.2.84:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"transient": {"cluster.routing.allocation.exclude._name": null}
}'curl -XPUT "http://172.31.2.84:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"transient": {"cluster.routing.allocation.cluster_concurrent_rebalance": null,"cluster.routing.allocation.node_concurrent_recoveries": null}
}'

八、可能风险

  1. 在迁移数据时,ES节点物理机出现异常,丢失数据
  2. 网络出现异常,出现脑裂
http://www.lryc.cn/news/436226.html

相关文章:

  • 高空抛物检测算法的应用场景解析
  • Leetcode 无重复字符的最长子串
  • 用命令行的方式启动.netcore webapi
  • Spring6详细学习笔记(IOC+AOP)
  • @RequestMapping 基于哪个库进行通信
  • GPIO(General Purpose Input/Output)输入/输出
  • 两个pdf合并成一个pdf,这些pdf合并小技巧了解下
  • Transformer学习(2):自注意力机制
  • 分类预测|基于粒子群优化径向基神经网络的数据分类预测Matlab程序PSO-RBF 多特征输入多类别输出 含基础RBF程序
  • 【React】Vite 构建 React
  • 算法刷题:300. 最长递增子序列、674. 最长连续递增序列、718. 最长重复子数组
  • 【linux】一种基于虚拟串口的方式使两个应用通讯
  • 并行程序设计基础——并行I/O(3)
  • 性能测试-jmeter脚本录制(十五)
  • 关系型数据库 - MySQL I
  • 解锁AI写作新境界:5款工具让你的论文创作事半功倍
  • 一文读懂多组学联合分析产品在医学领域的应用
  • js react 笔记 2
  • 快速使用react 全局状态管理工具--redux
  • 活动系统开发之采用设计模式与非设计模式的区别-非设计模式
  • JVM面试(六)垃圾收集器
  • 固态硬盘装系统有必要分区吗?
  • 网络安全架构师
  • 如何本地部署Ganache并使用内网穿透配置公网地址远程连接测试网络
  • 算法岗/开发岗 实况
  • Nginx跨域运行案例:云台控制http请求,通过 http server 代理转发功能,实现跨域运行。(基于大华摄像头WEB无插件开发包)
  • 【数据分析预备】Pandas
  • MATLAB-基于高斯过程回归GPR的数据回归预测
  • 欧洲国际眼科盛会,中国眼科专家周进斩获六项屈光大奖
  • MySQL——数据库的高级操作(二)用户管理(2)创建普通用户