ElasticSearch 6.4升级ElasticSearch 7.8

背景:
目前ES集群的版本还是6.4,最新的ES版本已经到了7.8了,是时候更新迭代了,先把测试环境下的更新了。

通过官方文档了解到有2种升级方案https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html
1.滚动升级
首先升级到6.8再升级到7.8,这个好处是不用中断业务,一台一台升级
2.全新集群升级
这个在升级的过程中是会要关闭集群的,对业务有一定的影响

考虑到公司存储的只是普通的业务数据,定期7天删除,少量数据丢失也没啥影响。也可以暂时关闭相关业务程序,业务数据先堆积在rmq中,正常后再重启,这样数据就不会丢失了。
官方文档在此:https://www.elastic.co/guide/en/elasticsearch/reference/current/restart-upgrade.html

操作步骤如下:
1.在其中一个节点上执行以下内容
#禁用分片分配
curl -H “Content-Type: application/json” -XPUT ‘http://localhost:9200/_cluster/settings’ -d ‘{“persistent”:{“cluster.routing.allocation.enable”:“primaries”}}’
#索引编制并执行同步刷新
curl -XPOST ‘http://localhost:9200/_flush/synced’

2.在各个节点上执行
rpm -e elasticsearch (之前是用rpm包安装的。)
下载7.8版本的rpm包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-x86_64.rpm
下载成功后再安装
rpm -ivh elasticsearch-7.8.0-x86_64.rpm
修改elasticsearch.yml配置文件
由于7.8版本的配置文件与6.4的还是有区别,不能直接沿用之前的,所以根据自己的实现情况进行修改,path.data还是之前的存储路径不变。如果有敏感数据的,事先备份一下,免得要删库跑路了。
配置内容如下:
节点1:
cluster.name: elasticSearch_cluster
node.name: node1
node.master: true
node.data: true
path.data: /data
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: [“10.34.43.55”,“10.34.43.56”]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: [“node1”]
http.cors.enabled: true
http.cors.allow-origin: “"
indices.fielddata.cache.size: 4G
节点2:
cluster.name: elasticSearch_cluster
node.name: node2
node.master: false
node.data: true
path.data: /data
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: [“10.34.43.55”,“10.34.43.56”]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: [“node1”]
http.cors.enabled: true
http.cors.allow-origin: "

indices.fielddata.cache.size: 4G

这里需要重点介绍三个配置字段
discovery.seed_hosts: 填上各个节点的信息
discovery.zen.minimum_master_nodes:主要是为了防止裂变,算法为总集群数/2+1.如果有10节点,此外填6
cluster.initial_master_nodes:填上master的节点信息

修改jvm.options配置文件
原先默认的是
-Xms1g
-Xmx1g
我的内存是8G的
故改成
-Xms4g
-Xmx4g

3.重启服务
在节点上执行
service elasticsearch start
查看状态
curl ‘http://localhost:9200/_cat/health’
没有报错则重启另外一台
再次查看状态正常后最后则启用分片分配
curl -H “Content-Type: application/json” -XPUT ‘http://localhost:9200/_cluster/settings’ -d ‘{“persistent”:{“cluster.routing.allocation.enable”:null}}’

最后浏览一下数据看看是否正常,还有最重要的一步是相关项目涉及到操作ES的,都要看看是否正常,因为新版本返回的json结构有些与原先的不太一样。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值