Elasticsearch 5.x 无法启动

Mad*_*ist 4 python java django django-haystack elasticsearch

我一直在尝试安装 Elasticsearch,对于 7.x 版本来说,这似乎很容易,而对于 5.x 版本来说则很麻烦。整个考验的存在是因为 Elasticseach、Django Haystack、Django CMS 和其他东西之间存在大量的兼容性要求。如果有人有一张漂亮的桌子或者有办法解决这个问题,我会很高兴听到。

\n\n

至于实际问题,安装 ES 5.x 后,我似乎无法让它工作。

\n\n
user@user-desktop:~/sites/project-web/project$ sudo systemctl restart elasticsearch\nuser@user-desktop:~/sites/project-web/project$ curl -X GET localhost:9200\ncurl: (7) Failed to connect to localhost port 9200: Connection refused\nuser@user-desktop:~/sites/project-web/project$ \n
Run Code Online (Sandbox Code Playgroud)\n\n

未注释的实体/etc/elasticsearch/elasticsearch.yml

\n\n
# ======================== Elasticsearch Configuration =========================\n#\n# NOTE: Elasticsearch comes with reasonable defaults for most settings.\n#       Before you set out to tweak and tune the configuration, make sure you\n#       understand what are you trying to accomplish and the consequences.\n#\n# The primary way of configuring a node is via this file. This template lists\n# the most important settings you may want to configure for a production cluster.\n#\n# Please consult the documentation for further information on configuration options:\n# https://www.elastic.co/guide/en/elasticsearch/reference/index.html\n#\n# ---------------------------------- Cluster -----------------------------------\n#\n# Use a descriptive name for your cluster:\n#\ncluster.name: project-search\n#\n# ------------------------------------ Node ------------------------------------\n#\n# Use a descriptive name for the node:\n#\nnode.name: node-1\n#\n# Add custom attributes to the node:\n#\n#node.attr.rack: r1\n#\n# ----------------------------------- Paths ------------------------------------\n#\n# Path to directory where to store the data (separate multiple locations by comma):\n#\n#path.data: /path/to/data\n#\n# Path to log files:\n#\n#path.logs: /path/to/logs\n# ----------------------------------- Memory -----------------------------------\n#\n# Lock the memory on startup:\n#\n#bootstrap.memory_lock: true\n#\n# Make sure that the heap size is set to about half the memory available\n# on the system and that the owner of the process is allowed to use this\n# limit.\n#\n# Elasticsearch performs poorly when the system is swapping the memory.\n#\n# ---------------------------------- Network -----------------------------------\n#\n# Set the bind address to a specific IP (IPv4 or IPv6):\n#\nnetwork.host: 0.0.0.0\n#\n# Set a custom port for HTTP:\n#\nhttp.port: 9200\ntransport.host: localhost\ntransport.tcp.port: 9300\n#\n# For more information, consult the network module documentation.\n# --------------------------------- Discovery ----------------------------------\n#\n# Pass an initial list of hosts to perform discovery when new node is started:\n# The default list of hosts is ["127.0.0.1", "[::1]"]\n#\n#discovery.zen.ping.unicast.hosts: ["host1", "host2"]\ndiscovery.zen.ping.unicast.hosts: ["0.0.0.0"]\n#discovery.seed_hosts:["0.0.0.0"]\n#\n# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):\n#\ndiscovery.zen.minimum_master_nodes: 1\n#\n# For more information, consult the zen discovery module documentation.\n#\n# ---------------------------------- Gateway -----------------------------------\n#\n# Block initial recovery after a full cluster restart until N nodes are started:\n#\n#gateway.recover_after_nodes: 3\n#\n# For more information, consult the gateway module documentation.\n#\n# ---------------------------------- Various -----------------------------------\n#\n# Require explicit names when deleting indices:\n#\n#action.destructive_requires_name: true\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是失败时的状态:

\n\n
user@user-desktop:~/sites/project-web/project$ systemctl status elasticsearch.service \n\xe2\x97\x8f elasticsearch.service - Elasticsearch\n   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)\n   Active: failed (Result: exit-code) since Sun 2019-11-24 15:39:25 CST; 3min 54s ago\n     Docs: http://www.elastic.co\n  Process: 19098 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_DI\n  Process: 19097 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)\n Main PID: 19098 (code=exited, status=1/FAILURE)\n\nNov 24 15:39:24 user-desktop systemd[1]: Starting Elasticsearch...\nNov 24 15:39:24 user-desktop systemd[1]: Started Elasticsearch.\nNov 24 15:39:24 user-desktop elasticsearch[19098]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.\nNov 24 15:39:25 user-desktop systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE\nNov 24 15:39:25 user-desktop systemd[1]: elasticsearch.service: Failed with result \'exit-code\'.\n
Run Code Online (Sandbox Code Playgroud)\n\n

/var/log/elasticsearch/project-search.log我发现以下错误:

\n\n
[2019-11-24T15:46:44,319][INFO ][o.e.n.Node               ] [node-1] initializing ...\n[2019-11-24T15:46:44,410][ERROR][o.e.b.Bootstrap          ] Exception\norg.elasticsearch.ElasticsearchException: java.io.IOException: failed to read [id:0, legacy:false, file:/var/lib/elasticsearch/nodes/0/_state/node-0.st]\n        at org.elasticsearch.ExceptionsHelper.maybeThrowRuntimeAndSuppress(ExceptionsHelper.java:196) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.gateway.MetaDataStateFormat.loadLatestState(MetaDataStateFormat.java:335) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.env.NodeEnvironment.loadOrCreateNodeMetaData(NodeEnvironment.java:418) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:267) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.16.jar:5.6.16]\nCaused by: java.io.IOException: failed to read [id:0, legacy:false, file:/var/lib/elasticsearch/nodes/0/_state/node-0.st]\n        at org.elasticsearch.gateway.MetaDataStateFormat.loadLatestState(MetaDataStateFormat.java:328) ~[elasticsearch-5.6.16.jar:5.6.16]\n        ... 14 more\nCaused by: java.lang.IllegalArgumentException: [node_meta_data] unknown field [node_version], parser not found\n        at org.elasticsearch.common.xcontent.ObjectParser.getParser(ObjectParser.java:399) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.common.xcontent.ObjectParser.parse(ObjectParser.java:159) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.common.xcontent.ObjectParser.apply(ObjectParser.java:183) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.env.NodeMetaData$1.fromXContent(NodeMetaData.java:110) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.env.NodeMetaData$1.fromXContent(NodeMetaData.java:94) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.gateway.MetaDataStateFormat.read(MetaDataStateFormat.java:203) ~[elasticsearch-5.6.16.jar:5.6.16]\n        at org.elasticsearch.gateway.MetaDataStateFormat.loadLatestState(MetaDataStateFormat.java:323) ~[elasticsearch-5.6.16.jar:5.6.16]\n        ... 14 more\n
Run Code Online (Sandbox Code Playgroud)\n\n

有人能告诉我这是怎么回事吗?任何有关解决此问题并让 ES 正常工作的帮助将不胜感激。

\n

c74*_*kds 7

看起来好像是 elasticSearch 版本之间不一致的问题。如果您之前使用 ES 7.0 版本对数据进行了索引,那么现在磁盘中该实例中的数据与 ES 5.0 版本不兼容。