Elasticsearch 启动服务失败

Elasticsearch start service failed

我正在尝试在 Debian 9.13(带有 plesk)上启动 elasticsearch(版本 7.10.2),我需要它在 Magento 2.4.3 上进行搜索,但是当我启动 service elasticsearch start 时,该服务无法启动. 在这台服务器上我有 PHP 7.4.27.

使用命令 systemctl status elasticsearch.service 出现此错误:

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2022-02-17 09:36:37 CET; 12s ago
     Docs: https://www.elastic.co
  Process: 6384 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
 Main PID: 6384 (code=exited, status=1/FAILURE)
      CPU: 17.562s

Feb 17 09:36:37 plesk.myserver.com systemd-entrypoint[6384]:         at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
Feb 17 09:36:37 plesk.myserver.com systemd-entrypoint[6384]:         at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
Feb 17 09:36:37 plesk.myserver.com systemd-entrypoint[6384]:         at org.elasticsearch.cli.Command.main(Command.java:90)
Feb 17 09:36:37 plesk.myserver.com systemd-entrypoint[6384]:         at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
Feb 17 09:36:37 plesk.myserver.com systemd-entrypoint[6384]:         at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
Feb 17 09:36:37 plesk.myserver.com systemd-entrypoint[6384]: For complete error details, refer to the log at /var/log/elasticsearch/elasticsearch.log
Feb 17 09:36:37 plesk.myserver.com systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Feb 17 09:36:37 plesk.myserver.com systemd[1]: Failed to start Elasticsearch.
Feb 17 09:36:37 plesk.myserver.com systemd[1]: elasticsearch.service: Unit entered failed state.
Feb 17 09:36:37 plesk.myserver.com systemd[1]: elasticsearch.service: Failed with result 'exit-code'.

这是日志:

[2022-02-17T09:36:37,624][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [plesk.myserver.com] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: ElasticsearchException[failed to bind service]; nested: IndexFormatTooNewException[Format version is not supported (resource SimpleFSIndexInput(path="/var/lib/elasticsearch/nodes/0/_state/_gu.cfs") [slice=_gu.fdt]): 4 (needs to be between 1 and 3)];
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:174) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.10.2.jar:7.10.2]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.10.2.jar:7.10.2]
Caused by: org.elasticsearch.ElasticsearchException: failed to bind service
    at org.elasticsearch.node.Node.<init>(Node.java:729) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.node.Node.<init>(Node.java:289) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Bootstrap.<init>(Bootstrap.java:227) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:227) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.10.2.jar:7.10.2]
    ... 6 more
Caused by: org.apache.lucene.index.IndexFormatTooNewException: Format version is not supported (resource SimpleFSIndexInput(path="/var/lib/elasticsearch/nodes/0/_state/_gu.cfs") [slice=_gu.fdt]): 4 (needs to be between 1 and 3)
    at org.apache.lucene.codecs.CodecUtil.checkHeaderNoMagic(CodecUtil.java:216) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.codecs.CodecUtil.checkHeader(CodecUtil.java:198) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.codecs.CodecUtil.checkIndexHeader(CodecUtil.java:255) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.codecs.compressing.CompressingStoredFieldsReader.<init>(CompressingStoredFieldsReader.java:130) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.codecs.compressing.CompressingStoredFieldsFormat.fieldsReader(CompressingStoredFieldsFormat.java:123) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.codecs.lucene87.Lucene87StoredFieldsFormat.fieldsReader(Lucene87StoredFieldsFormat.java:131) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:127) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:83) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.StandardDirectoryReader.doBody(StandardDirectoryReader.java:66) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.StandardDirectoryReader.doBody(StandardDirectoryReader.java:58) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:720) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:81) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:63) ~[lucene-core-8.7.0.jar:8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:35:28]
    at org.elasticsearch.gateway.PersistedClusterStateService.nodeMetadata(PersistedClusterStateService.java:267) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.env.NodeEnvironment.loadNodeMetadata(NodeEnvironment.java:409) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:330) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.node.Node.<init>(Node.java:362) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.node.Node.<init>(Node.java:289) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Bootstrap.<init>(Bootstrap.java:227) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:227) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.10.2.jar:7.10.2]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.10.2.jar:7.10.2]
    ... 6 more

有人可以帮我吗?

我通过完全卸载 elasticsearch 及其所有配置解决了这个问题:

$ sudo apt-get remove elasticsearch
$ sudo apt-get --purge autoremove elasticsearch
$ sudo rm -rf /var/lib/elasticsearch/
$ sudo rm -rf /etc/elasticsearch

然后我安装了兼容Magento 2.4.3的7.6.2版本:

$ sudo apt-get install elasticsearch=7.6.2

现在可以使用了。