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)

相關文章
相關標籤/搜索