Elasticsearch升级踩坑记之升级elasticsearch2.x到elasticsearch5.x

时间:2022-07-23
本文章向大家介绍Elasticsearch升级踩坑记之升级elasticsearch2.x到elasticsearch5.x,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一开始是尝试使用rolling upgrade的方式升级,但是后来发现从2.x升级到5.x是一个大的升级,需要采用full restart upgrade的方式升级,参考连接中的表格: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/setup-upgrade.html

先将想要升级的版本对应的tar.gz包下载下来,解压,将旧版2.x的elasticsearch.yml文件复制到5.x的config目录下,覆盖相应的elasticsearch.yml文件。数据目录和日志目录都不用改,5.xelasticsearch启动后可以直接使用2.x的elasticsearch data目录下的数据,二者是兼容的。

修改系统配置:
Vim /etc/sysctl.conf
设置
fs.file-max=655350
vm.max_map_count=655360
保存之后sysctl -p使设置生效

将之前的65535修改成655350
vi /etc/security/limits.conf 
*               soft    nofile          655350
*               hard    nofile             655350

以上步骤完成后,关闭2.x旧版机器,节点全部关闭,退出elastic用户重新登录(必须退出重新登录系统配置才能生效),启动5.x新版elasticsearch所有节点。当节点全部加入集群,集群状态有yellow变成green时,集群更新完成。

查看集群健康状态

[root@localhost nodes]# curl -XGET 192.168.1.146:9200/_cat/health?pretty
1520927394 15:49:54 es_test green 3 3 84 42 0 0 0 0 - 100.0% 
[root@localhost nodes]# curl -XGET 192.168.1.146:9200/_cat/nodes
192.168.1.146 192.168.1.146  3 45 0.02 d m node-1 
192.168.1.151 192.168.1.151 12 94 0.38 d m node-2 
192.168.1.152 192.168.1.152  9 67 0.21 d * node-3 

查看版本

[root@localhost 0]# curl -XGET 192.168.1.146:9200
{
  "name" : "node-1",
  "cluster_name" : "es_test",
  "cluster_uuid" : "9Ud3N-NNS_C4PWF7YKp73g",
  "version" : {
    "number" : "5.6.8",
    "build_hash" : "688ecce",
    "build_date" : "2018-02-16T16:46:30.010Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}