這篇文章主要介紹“Elasticsearch 5.1.1怎么升級(jí)6.7.2”,在日常操作中,相信很多人在Elasticsearch 5.1.1怎么升級(jí)6.7.2問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Elasticsearch 5.1.1怎么升級(jí)6.7.2”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
創(chuàng)新互聯(lián)公司成都網(wǎng)站建設(shè)按需定制,是成都網(wǎng)站營(yíng)銷推廣公司,為三維植被網(wǎng)提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計(jì)服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計(jì)、前端HTML5制作、后臺(tái)程序開發(fā)等。成都網(wǎng)站維護(hù)熱線:18982081108
接上文啟動(dòng)失敗,仔細(xì)檢視安裝過(guò)程,安裝過(guò)程中的幾個(gè)warning引起了我的注意:
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
很顯然,因?yàn)榕渲梦募呀?jīng)存在,elasticsearch安裝過(guò)程并沒(méi)有幫你覆蓋,而是將新的配置文件以.rpmnew結(jié)尾存在同路徑下。所以,我們需要手工來(lái)合并elasticsearch的配置文件。這個(gè)屬于elasticsearch安裝的過(guò)程,相信做升級(jí)的人都有所了解,我就不詳述了。
配置文件修改好之后,你以為就可以啟動(dòng)了嗎?Naive!反手就是一個(gè)報(bào)錯(cuò):
[root@LPT0268 elasticsearch]# service elasticsearch start Starting elasticsearch (via systemctl): [ OK ] [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:51:37 CST; 4s 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: 13624 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=203/EXEC) Main PID: 11905 (code=exited, status=1/FAILURE)
可以看到錯(cuò)誤并沒(méi)有消除,并且/var/log/elasticsearch/
目錄下沒(méi)有任何日志。這個(gè)問(wèn)題我搞了很久,突發(fā)奇想,我去$ES_HOME/bin
目錄直接執(zhí)行elasticsearch腳本,結(jié)果終于看到錯(cuò)誤信息了:
Jul 01 10:18:06 LPT0268 elasticsearch[1345]: Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.io.EOFException: read past EOF: SimpleFSIndexInput(path="/etc/ela...rch.keystore") Jul 01 10:18:06 LPT0268 elasticsearch[1345]: Likely root cause: java.io.EOFException: read past EOF: SimpleFSIndexInput(path="/etc/elasticsearch/elasticsearch.keystore") Jul 01 10:18:06 LPT0268 elasticsearch[1345]: at org.apache.lucene.store.BufferedIndexInput.refill(BufferedIndexInput.java:336) Jul 01 10:18:06 LPT0268 elasticsearch[1345]: at org.apache.lucene.store.BufferedIndexInput.readByte(BufferedIndexInput.java:54) Jul 01 10:18:06 LPT0268 elasticsearch[1345]: at org.apache.lucene.store.BufferedChecksumIndexInput.readByte(BufferedChecksumIndexInput.java:41) Jul 01 10:18:06 LPT0268 elasticsearch[1345]: at org.apache.lucene.store.DataInput.readInt(DataInput.java:101) Jul 01 10:18:06 LPT0268 elasticsearch[1345]: at org.apache.lucene.codecs.CodecUtil.checkHeader(CodecUtil.java:194) Jul 01 10:18:06 LPT0268 systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE Jul 01 10:18:06 LPT0268 systemd[1]: Unit elasticsearch.service entered failed state. Jul 01 10:18:06 LPT0268 systemd[1]: elasticsearch.service failed. Hint: Some lines were ellipsized, use -l to show in full.
原來(lái)是我們剛才創(chuàng)建的elasticsearch.keystore這個(gè)貨導(dǎo)致的,通過(guò)查閱文檔發(fā)現(xiàn),不能手動(dòng)創(chuàng)建elasticsearch.keystore文件,因?yàn)樗荅S自帶的密鑰庫(kù)相關(guān)的文件,必須使用命令來(lái)創(chuàng)建,
sudo bin/elasticsearch-keystore create
官方說(shuō)明:
https://www.elastic.co/guide/en/elasticsearch/reference/current/secure-settings.html
通過(guò)官方文檔也能解釋,為什么我們修改配置文件沒(méi)有影響報(bào)錯(cuò)。因?yàn)閑lasticsearch本身是先加載elasticsearch.keystore,再去加載配置文件的。
再啟動(dòng)ES,然而還是報(bào)錯(cuò)(內(nèi)心崩潰,經(jīng)過(guò)一個(gè)周末的修復(fù)才康復(fù)):
[yuliangwang@LPT0268 bin]$ systemctl status elasticsearch ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/elasticsearch.service.d └─override.conf Active: failed (Result: exit-code) since Mon 2019-07-01 11:04:32 CST; 20s ago Docs: http://www.elastic.co Process: 4898 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=78) Main PID: 4898 (code=exited, status=78)
好消息是,終于我們有l(wèi)og了,打開/var/log/elasticsearch/
,摘錄有問(wèn)題的信息:
[2019-07-01T10:54:12,406][WARN ][o.e.b.JNANatives ] [unknown] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory [2019-07-01T10:54:12,409][WARN ][o.e.b.JNANatives ] [unknown] This can result in part of the JVM being swapped out. [2019-07-01T10:54:12,409][WARN ][o.e.b.JNANatives ] [unknown] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536 [2019-07-01T10:54:12,409][WARN ][o.e.b.JNANatives ] [unknown] These can be adjusted by modifying /etc/security/limits.conf, for example: # allow user 'elasticsearch' mlockall elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited [2019-07-01T10:54:12,409][WARN ][o.e.b.JNANatives ] [unknown] If you are logged in interactively, you will have to re-login for the new limits to take effect. ...... [2019-07-01T10:54:21,051][ERROR][o.e.b.Bootstrap ] [G1bC4Hf] node validation exception [1] bootstrap checks failed [1]: memory locking requested for elasticsearch process but memory is not locked
可以看到鎖定內(nèi)存有關(guān)。這個(gè)是因?yàn)槲覀冊(cè)谂渲弥刑砑恿岁P(guān)閉swap的配置:
bootstrap.memory_lock: true
關(guān)閉swap可以防止OS將內(nèi)存也置換到磁盤中,根據(jù)官方文檔的說(shuō)法,可以防止很慢的GC:
https://www.elastic.co/guide/en/elasticsearch/reference/6.7/setup-configuration-memory.html
根據(jù)文檔,來(lái)配置/etc/systemd/system/elasticsearch.service.d/override.conf
,設(shè)置值為:
[Service] LimitMEMLOCK=infinity
然后刷新
sudo systemctl daemon-reload
再次啟動(dòng)后終于成功:
[root@LPT0268 elasticsearch]# sudo service elasticsearch restart Restarting elasticsearch (via systemctl): [ OK ] [root@LPT0268 elasticsearch]# systemctl status elasticsearch ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/elasticsearch.service.d └─override.conf Active: active (running) since Mon 2019-07-01 13:57:51 CST; 14s ago Docs: http://www.elastic.co Main PID: 15294 (java) CGroup: /system.slice/elasticsearch.service ├─15294 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negat... └─15375 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
9200端口返回版本為6.7.2,:
{ "name": "G1bC4Hf", "cluster_name": "psylocke-fws-oy", "cluster_uuid": "PDI23Ik4TAGx10mMocqGLQ", "version": { "number": "6.7.2", "build_flavor": "default", "build_type": "rpm", "build_hash": "56c6e48", "build_date": "2019-04-29T09:05:50.290371Z", "build_snapshot": false, "lucene_version": "7.7.0", "minimum_wire_compatibility_version": "5.6.0", "minimum_index_compatibility_version": "5.0.0" }, "tagline": "You Know, for Search" }
依次升級(jí)集群內(nèi)的每臺(tái)機(jī)器后,啟動(dòng)集群,通過(guò)GET _cat/health
查看集群狀態(tài)。此時(shí)集群狀態(tài)是red,通過(guò)GET _cat/shards
可以看到主分片都已經(jīng)started了,但是從分片還是失效狀態(tài),通過(guò)以下命令恢復(fù)集群routing
PUT _cluster/settings { "transient": { "cluster.routing.allocation.enable": "all" } }
可以看到集群變?yōu)閥ellow,開始恢復(fù):
1561970784 08:46:24 psylocke-fws-oy yellow 1 1 17 17 0 0 15 0 - 53.1%
到此,關(guān)于“Elasticsearch 5.1.1怎么升級(jí)6.7.2”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!