Elasticsearch安装启动问题总结-Elasticsearch

使用root用户启动失败

错误日志:

warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_171/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_171/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
[2021-05-28T17:36:25,500][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [master] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116) ~[elasticsearch-cli-7.13.0.jar:7.13.0]
	at org.elasticsearch.cli.Command.main(Command.java:79) ~[elasticsearch-cli-7.13.0.jar:7.13.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81) ~[elasticsearch-7.13.0.jar:7.13.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:101) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:168) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:397) ~[elasticsearch-7.13.0.jar:7.13.0]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.13.0.jar:7.13.0]
	... 6 more

错误原因

elasticsearch默认不允许root用户启动。

解决方案

创建一个专有用户,授权,然后启动elasticsearch。

  • 创建用并授权elasticsearch文件夹权限
[root@master jdk.app]# adduser elastic
[root@master jdk.app]# chown -R elastic:elastic /usr/local/elasticsearch-7.16.2/
# 切换到新用户并启动
[root@master jdk.app]# su elastic
[elastic@master jdk.app]$ cd ..
[elastic@master elasticsearch-7.16.2]$ bin/elasticsearch -d

To bypass this problem by running Elasticsearch without machine learning functionality set [xpack.ml.enabled: false].

错误日志

ElasticsearchException[Failure running machine learning native code. This could be due to running on an unsupported OS or distribution, missing OS libraries, or a problem with the temp directory. To bypass this problem by running Elasticsearch without machine learning functionality set [xpack.ml.enabled: false].]
        at org.elasticsearch.xpack.ml.MachineLearning.createComponents(MachineLearning.java:700)
        at org.elasticsearch.node.Node.lambda$new$16(Node.java:560)
        at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at org.elasticsearch.node.Node.<init>(Node.java:564)
        at org.elasticsearch.node.Node.<init>(Node.java:278)

解决方案

修改config目录下的elasticsearch.yml文件,增加一条配置:
xpack.ml.enabled: false

# ======================== 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
xpack.ml.enabled: false
#
# ------------------------------------ Node ------------------------------------

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方案

切换到root用户,因为要修改/etc/sysctl.conf或者用sudo vi /etc/sysctl.conf,修改文件,再文件末尾加上vm.max_map_count=655360。
并执行sysctl -p,使修改文件部分生效。
ES重启即可。

the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

原因

意思是需要 有默认的配置给生产环境使用,discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes,这三个至少要配置一个。

解决方案

在config/elasticsearch.yml文件中添加配置:
discovery.seed_hosts: [“计算机ip:9200”]

# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
network.bind_host: 192.168.230.128
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#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: ["192.168.230.128:9200"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:

参考

Elasticsearch | 03 安装配置启动失败原因总结
Elasticsearch安装启动常见问题

你可能感兴趣的:(ElasticStack,elasticsearch,搜索引擎,big,data)