Elasticsearch 5.1.1升级6.7.2小结(1)

1 升级过程

由于咱们的ES版本低于5.6,因此须要经过全集群重启的方式来升级,升级过程主要参考官方文档:html

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

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

由于es的shard分片,包含主从分片,而主从分片通常在不一样的节点。若是一台节点挂了(固然,升级过程当中是咱们主动关机),es会进行分片的重分配,由于所有是网络IO,慢到爆炸。因此咱们首先要关闭shard片重分配。shell

方法很简单:json

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 版本

注意,这一步坑不少,我一条一条记录。elasticsearch

首先参考官网文档ide

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

由于咱们的服务器不能链接Internet,因此须要下载如下几个文件,特别是 elasticsearch-6.7.2.rpm.sha512 GPG-KEY-elasticsearch,这两个文件必定不能少。post

其中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)

相关文章
相关标签/搜索