您好,登錄后才能下訂單哦!
這篇文章主要講解了“Elasticsearch 5.1.1如何升級(jí)到6.7.2”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“Elasticsearch 5.1.1如何升級(jí)到6.7.2”吧!
因?yàn)槲覀兊腅S版本低于5.6,所以需要通過(guò)全集群重啟的方式來(lái)升級(jí),升級(jí)過(guò)程主要參考官方文檔:
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/setup-upgrade.html
因?yàn)閑s的shard分片,包含主從分片,而主從分片一般在不同的節(jié)點(diǎn)。如果一臺(tái)節(jié)點(diǎn)掛了(當(dāng)然,升級(jí)過(guò)程中是我們主動(dòng)關(guān)機(jī)),es會(huì)進(jìn)行分片的重分配,因?yàn)槿渴蔷W(wǎng)絡(luò)IO,慢到爆炸。所以我們首先要關(guān)閉shard片重分配。
方法很簡(jiǎn)單:
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.enable": "none" } }
刷一下shard片:
POST _flush/synced
關(guān)閉Elasticsearch服務(wù),注意,要一臺(tái)一臺(tái)關(guān):
sudo systemctl stop elasticsearch.service
注意,這一步坑很多,我一條一條記錄。
首先參考官網(wǎng)文檔
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/rpm.html
因?yàn)槲覀兊?a title="服務(wù)器" target="_blank" href="http://kemok4.com/">服務(wù)器不能連接Internet,所以需要下載以下幾個(gè)文件,特別是 elasticsearch-6.7.2.rpm.sha512 GPG-KEY-elasticsearch,這兩個(gè)文件一定不能少。
其中GPG-KEY-elasticsearch可以通過(guò)以下來(lái)下載
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的公鑰,因?yàn)槲覀兪窃诒镜氐?,需要改一下路徑?/p>
rpm --import ./GPG-KEY-elasticsearch
引入公鑰之后,需要校驗(yàn)rpm包的完整性,這里采用sha512的方式。如果沒(méi)有安裝相關(guān)工具會(huì)報(bào)錯(cuò),需要先安裝sha校驗(yàn)工具:
sudo yum install perl-Digest-SHA
校驗(yàn):
shasum -a 512 -c elasticsearch-6.7.2.rpm.sha512
然后第一個(gè)坑來(lái)了,按照官網(wǎng)的教程安裝
sudo rpm --install elasticsearch-6.7.2.rpm
會(huì)出現(xiàn)文件沖突報(bào)錯(cuò),原因是已經(jīng)安裝過(guò)老版本的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 ...
再此我們使用來(lái)安裝
sudo rpm --Uvh elasticsearch-6.7.2.rpm
裝一半又報(bào)錯(cuò)了,可以看到elasticsearch.keystore不存在,我就創(chuàng)建了一個(gè)elasticsearch.keystore,安裝即可成功。注意,這里是一個(gè)大坑,后面詳說(shuō)。
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
創(chuàng)建之后,就安裝成功啦:
Preparing... ################################# [100%] package elasticsearch-0:6.7.2-1.noarch is already installed
安裝成功之后,我們就該啟動(dòng)elasticsearch集群了:
sudo service elasticsearch start
但不幸的是啟動(dòng)失敗,elasticsearch的9200端口無(wú)響應(yīng),查看啟動(dòng)狀態(tài),可以看到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如何升級(jí)到6.7.2”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)Elasticsearch 5.1.1如何升級(jí)到6.7.2這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。