elasticsearch 5.2 升级5.6.9过程记录

参考官方文档:

https://www.elastic.co/guide/en/elasticsearch/reference/5.6/rolling-upgrades.html

1,Disable shard allocation (关闭自动分片,避免节点停止时,数据大量复制到其他节点)

curl -X PUT “localhost:9201/_cluster/settings” -H ‘Content-Type: application/json’ -d’

{

  “transient”: {

    “cluster.routing.allocation.enable”: “none”

  }

}

2,Stop non-essential indexing and perform a synced flush (手动执行同步刷新操作,使节点重启后可以从本地快速恢复数据(仅对冷索引有效),大量减少节点间的数据拷贝)

curl -X POST “localhost:9201/_flush/synced”

3,Stop and upgrade a single node(更新一个节点的服务以及插件)

参考playbook:

– name: u”stop service”

  shell: “/etc/init.d/elasticsearch stop”

– name: u”stop master service”

  shell: “/etc/init.d/elasticsearch-master stop”

– name: u”部署安装包”

  copy: src=”elasticsearch-5.6.9.deb” dest=”/tmp/elasticsearch-5.6.9.deb” owner=root group=root mode=0440

– name: u”移除默认安装目录下的jvm config,否则dpkg安装时会卡住”

  shell: “mv /etc/elasticsearch/jvm.options /etc/elasticsearch/jvm.options.bak “

– name: u”初始化包”

  shell: “dpkg -i /tmp/elasticsearch-5.6.9.deb”

– name: u”delete old plugins”

  shell: “rm -rf /usr/share/elasticsearch/plugins/*”

– name: u”安装扩展ik”

  copy: src=”ik” dest=”/usr/share/elasticsearch/plugins/” owner=root group=root mode=0644

– name: u”安装扩展pinyin”

  copy: src=”pinyin” dest=”/usr/share/elasticsearch/plugins/” owner=root group=root mode=0644

– name: ES java config

  template:

    src=jvm.options.j2

    dest=/etc/elasticsearch/jvm.options

    owner=root group=root mode=644

– name: u”start service”

  shell: “/etc/init.d/elasticsearch start”

– name: u”start master service”

  shell: “/etc/init.d/elasticsearch-master start”

4,Wait for the node to join the cluster:

curl -X GET “localhost:9201/_cat/nodes”

5,Reenable shard allocation

curl -X PUT “localhost:9201/_cluster/settings” -H ‘Content-Type: application/json’ -d’

{

  “transient”: {

    “cluster.routing.allocation.enable”: “all”

  }

}

6,Wait for the node to recover

curl -X GET “localhost:9201/_cat/health”(GREEN)

7,Repeat (重复1-6操作下一个节点)

When the cluster is stable and the node has recovered, repeat the above steps for all remaining nodes.

—————————————————————-

可选:

如需更新插件:x-pack  

参考官方文档:

https://www.elastic.co/guide/en/elasticsearch/reference/5.6/installing-xpack-es.html

1、停止服务并移除老版本插件

2、安装当前版本插件:

    2.1、在线更新:bin/elasticsearch-plugin install x-pack

    2.2、离线更新:

        2.2.1、downloadhttps://artifacts.elastic.co/downloads/packs/x-pack/x-pack-5.6.9.zip

        2.2.3、bin/elasticsearch-plugin install file:///path/to/file/x-pack-5.6.9.zip

3、在/etc/elasticsearch/elasticsearch.yml 里添加一行配置:xpack_security_enabled: “false”

去掉password验证功能

4、启动es服务并等待节点加入集群(此时可以先操作第4步)

5、申请免费试用1年的license,填写信息后会收到license下载邮件,进入邮件指定地址下载对应版本的license

6、为es的运行用户elasticsearch设置登录密码

passwd  elasticsearch

7、激活x-pack:

curl -XPUT -u elasticsearch ‘http://127.0.0.1:9201/_xpack/license?acknowledge=true’ -H “Content-Type: application/json” -d @arteezy-xie-61d89843-332f-41b7-9b75-72ef99fa0513-v5.json

curl -XPUT -u elasticsearch ‘http://127.0.0.1:9202/_xpack/license?acknowledge=true’ -H “Content-Type: application/json” -d @arteezy-xie-61d89843-332f-41b7-9b75-72ef99fa0513-v5.json

(输入上一步为elasticsearch设置的登录密码)

PS:仅做监控和报警的话,强烈建议投入prometheus的怀抱,官方grafana的监控demo接入即用,数据丰富多样,多集群维护同样方便。当然,你需要先安装一个prometheus…

    原文作者:Arteezy_Xie
    原文地址: https://www.jianshu.com/p/de846eb61496
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞