2

我想为我的弹性搜索设置密码。我还没有付费或开始免费试用,所以我想我默认使用的是基本计划。我已按照官方指南在 ubuntu EC2 上安装 elasticsearch。我不认为我已经安装了 OSS 版本,但是当我运行时:

/usr/share/elasticsearch$ sudo bin/elasticsearch-plugin list --verbose
Plugins directory: /usr/share/elasticsearch/plugins

它不打印 xpack。

我尝试删除和安装 ElasticSearch clean,以防我设置错误。我对 elasticsearch.yml 所做的唯一事情是添加:xpack.security.enabled:true

systemctl start elasticsearch.service但是通过输出此错误消息启动弹性搜索:

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-11-13 02:53:44 UTC; 9min ago
     Docs: http://www.elastic.co
  Process: 20330 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
 Main PID: 20330 (code=exited, status=1/FAILURE)

Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         at org.yaml.snakeyaml.scanner.ScannerImpl.needMoreTokens(ScannerImpl.java:280)
Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:225)
Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:557)
Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:157)
Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:167)
Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:340)
Nov 13 02:53:44 ip-172-31-47-37 elasticsearch[20330]:         ... 13 more
Nov 13 02:53:44 ip-172-31-47-37 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Nov 13 02:53:44 ip-172-31-47-37 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Nov 13 02:53:44 ip-172-31-47-37 systemd[1]: Failed to start Elasticsearch

同样在我添加之后xpack.security.enabled:true,列表插件会显示此错误消息:

/usr/share/elasticsearch$ sudo bin/elasticsearch-plugin list --verbose
Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: MarkedYAMLException[while scanning a simple key
 in 'reader', line 90, column 1:
    xpack.security.enabled:true
    ^
could not find expected ':'
 in 'reader', line 91, column 1:

    ^

 at [Source: sun.nio.ch.ChannelInputStream@6155d082; line: 37, column: 34]]; nested: ScannerException[while scanning a simple key
 in 'reader', line 90, column 1:
    xpack.security.enabled:true
    ^
could not find expected ':'
 in 'reader', line 91, column 1:

    ^
];
        at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1097)
        at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1070)
        at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:83)
        at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:95)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
        at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:77)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)
Caused by: com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException: while scanning a simple key
 in 'reader', line 90, column 1:
    xpack.security.enabled:true
    ^
could not find expected ':'
 in 'reader', line 91, column 1:

    ^

 at [Source: sun.nio.ch.ChannelInputStream@6155d082; line: 37, column: 34]
        at com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException.from(MarkedYAMLException.java:27)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:343)
        at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:52)
        at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:645)
        at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:620)
        at org.elasticsearch.common.settings.Settings.access$400(Settings.java:82)
        at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1093)
        ... 9 more
Caused by: while scanning a simple key
 in 'reader', line 90, column 1:
    xpack.security.enabled:true
    ^
could not find expected ':'
 in 'reader', line 91, column 1:

    ^

        at org.yaml.snakeyaml.scanner.ScannerImpl.stalePossibleSimpleKeys(ScannerImpl.java:465)
        at org.yaml.snakeyaml.scanner.ScannerImpl.needMoreTokens(ScannerImpl.java:280)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:225)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:557)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:157)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:167)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:340)
        ... 14 more

这是我的 elasticsearch.yml:

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

xpack.security.enabled:true

我需要做什么才能成功启动弹性搜索?先感谢您

4

1 回答 1

1

尝试在冒号后为您的 xpack 设置添加一个空格。xpack.security.enabled:真

yaml 文件的语法可能非常具体。 https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html

“字典用一个简单的键表示:值形式(冒号后面必须跟一个空格)”

于 2019-11-13T05:02:46.260 回答