Elasticsearch 5.1.1升级6.7.2小结(1)

1 升级过程

因为我们的ES版本低于5.6,所以需要通过全集群重启的方式来升级,升级过程主要参考官方文档:

https://www.elastic.co/guide/en/elasticsearch/reference/6.0/setup-upgrade.html

1.1 Disable shard allocation.关闭shard片重分配。

因为es的shard分片,包含主从分片,而主从分片一般在不同的节点。如果一台节点挂了(当然,升级过程中是我们主动关机),es会进行分片的重分配,因为全部是网络IO,慢到爆炸。所以我们首先要关闭shard片重分配。

方法很简单:

PUT _cluster/settings
 {
   "persistent": {
     "cluster.routing.allocation.enable": "none"
   }
 }

1.2 Stop indexing and perform a synced flush.

刷一下shard片:

POST _flush/synced

1.3 Shutdown all nodes.

关闭Elasticsearch服务,注意,要一台一台关:

sudo systemctl stop elasticsearch.service

1.4 升级Elasticsearch 版本

注意,这一步坑很多,我一条一条记录。

首先参考官网文档

https://www.elastic.co/guide/en/elasticsearch/reference/6.0/rpm.html

因为我们的服务器不能连接Internet,所以需要下载以下几个文件,特别是 elasticsearch-6.7.2.rpm.sha512 GPG-KEY-elasticsearch,这两个文件一定不能少。

其中GPG-KEY-elasticsearch可以通过以下来下载

wget  https://artifacts.elastic.co/GPG-KEY-elasticsearch

下载完成之后包含以下文件:

$ ls
elasticsearch-6.7.2.rpm  elasticsearch-6.7.2.rpm.sha512  GPG-KEY-elasticsearch  kibana-6.7.2-x86_64.rpm

然后引入es的公钥,因为我们是在本地的,需要改一下路径:

rpm --import ./GPG-KEY-elasticsearch

引入公钥之后,需要校验rpm包的完整性,这里采用sha512的方式。如果没有安装相关工具会报错,需要先安装sha校验工具:

sudo yum install perl-Digest-SHA

校验:

shasum -a 512 -c elasticsearch-6.7.2.rpm.sha512

然后第一个坑来了,按照官网的教程安装

sudo rpm --install elasticsearch-6.7.2.rpm

会出现文件冲突报错,原因是已经安装过老版本的es了。

        file /etc/init.d/elasticsearch from install of elasticsearch-0:6.7.2-1.noarch conflicts with file from package elasticsearch-0:5.1.1-1.noarch
        file /etc/sysconfig/elasticsearch from install of elasticsearch-0:6.7.2-1.noarch conflicts with file from package elasticsearch-0:5.1.1-1.noarch
        file /usr/share/elasticsearch/bin/elasticsearch from install of elasticsearch-0:6.7.2-1.noarch conflicts with file from package elasticsearch-0:5.1.1-1.noarch
...

再此我们使用来安装

sudo rpm --Uvh elasticsearch-6.7.2.rpm

装一半又报错了,可以看到elasticsearch.keystore不存在,我就创建了一个elasticsearch.keystore,安装即可成功。注意,这里是一个大坑,后面详说。

Preparing...                          ################################# [100%]
Updating / installing...
   1:elasticsearch-0:6.7.2-1          warning: /etc/elasticsearch/elasticsearch.yml created as /etc/elasticsearch/elasticsearch.yml.rpmnew
warning: /etc/sysconfig/elasticsearch created as /etc/sysconfig/elasticsearch.rpmnew
warning: /usr/lib/systemd/system/elasticsearch.service created as /usr/lib/systemd/system/elasticsearch.service.rpmnew
################################# [ 50%]
Cleaning up / removing...
   2:elasticsearch-0:5.1.1-1          warning: /etc/elasticsearch/scripts saved as /etc/elasticsearch/scripts.rpmsave
################################# [100%]
ES_PATH_CONF must be set to the configuration path
chown: cannot access ‘/etc/elasticsearch/elasticsearch.keystore’: No such file or directory
chmod: cannot access ‘/etc/elasticsearch/elasticsearch.keystore’: No such file or directory
md5sum: /etc/elasticsearch/elasticsearch.keystore: No such file or directory
warning: %posttrans(elasticsearch-0:6.7.2-1.noarch) scriptlet failed, exit status 1

创建之后,就安装成功啦:

Preparing...                          ################################# [100%]
        package elasticsearch-0:6.7.2-1.noarch is already installed

安装成功之后,我们就该启动elasticsearch集群了:

 sudo service elasticsearch start

但不幸的是启动失败,elasticsearch的9200端口无响应,查看启动状态,可以看到Active: failed。

[yuliangwang@LPT0268 ~]$ systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-06-28 16:50:18 CST; 24s ago
     Docs: http://www.elastic.co
  Process: 11905 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE)
  Process: 13440 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=203/EXEC)
 Main PID: 11905 (code=exited, status=1/FAILURE)

具体的填坑之旅,请听下回分解。 Elasticsearch 5.1.1升级6.7.2小结(2)

转载于:https://my.oschina.net/u/4156657/blog/3068089

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值