您好,登錄后才能下訂單哦!
這篇文章主要介紹“Elasticsearch 5.1.1怎么升級6.7.2”,在日常操作中,相信很多人在Elasticsearch 5.1.1怎么升級6.7.2問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Elasticsearch 5.1.1怎么升級6.7.2”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
接上文啟動失敗,仔細檢視安裝過程,安裝過程中的幾個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
很顯然,因為配置文件已經存在,elasticsearch安裝過程并沒有幫你覆蓋,而是將新的配置文件以.rpmnew結尾存在同路徑下。所以,我們需要手工來合并elasticsearch的配置文件。這個屬于elasticsearch安裝的過程,相信做升級的人都有所了解,我就不詳述了。
配置文件修改好之后,你以為就可以啟動了嗎?Naive!反手就是一個報錯:
[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)
可以看到錯誤并沒有消除,并且/var/log/elasticsearch/
目錄下沒有任何日志。這個問題我搞了很久,突發奇想,我去$ES_HOME/bin
目錄直接執行elasticsearch腳本,結果終于看到錯誤信息了:
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.
原來是我們剛才創建的elasticsearch.keystore這個貨導致的,通過查閱文檔發現,不能手動創建elasticsearch.keystore文件,因為他是ES自帶的密鑰庫相關的文件,必須使用命令來創建,
sudo bin/elasticsearch-keystore create
官方說明:
https://www.elastic.co/guide/en/elasticsearch/reference/current/secure-settings.html
通過官方文檔也能解釋,為什么我們修改配置文件沒有影響報錯。因為elasticsearch本身是先加載elasticsearch.keystore,再去加載配置文件的。
再啟動ES,然而還是報錯(內心崩潰,經過一個周末的修復才康復):
[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)
好消息是,終于我們有log了,打開/var/log/elasticsearch/
,摘錄有問題的信息:
[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
可以看到鎖定內存有關。這個是因為我們在配置中添加了關閉swap的配置:
bootstrap.memory_lock: true
關閉swap可以防止OS將內存也置換到磁盤中,根據官方文檔的說法,可以防止很慢的GC:
https://www.elastic.co/guide/en/elasticsearch/reference/6.7/setup-configuration-memory.html
根據文檔,來配置/etc/systemd/system/elasticsearch.service.d/override.conf
,設置值為:
[Service] LimitMEMLOCK=infinity
然后刷新
sudo systemctl daemon-reload
再次啟動后終于成功:
[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" }
依次升級集群內的每臺機器后,啟動集群,通過GET _cat/health
查看集群狀態。此時集群狀態是red,通過GET _cat/shards
可以看到主分片都已經started了,但是從分片還是失效狀態,通過以下命令恢復集群routing
PUT _cluster/settings { "transient": { "cluster.routing.allocation.enable": "all" } }
可以看到集群變為yellow,開始恢復:
1561970784 08:46:24 psylocke-fws-oy yellow 1 1 17 17 0 0 15 0 - 53.1%
到此,關于“Elasticsearch 5.1.1怎么升級6.7.2”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。