Elasticsearch:elasticsearch.service的作业失败 [英] Elasticsearch: Job for elasticsearch.service failed

查看:87
本文介绍了Elasticsearch:elasticsearch.service的作业失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试为项目设置 Elasticsearch 。我已经安装了 Elasticsearch 7.4.1 ,还安装了 Java ,即 openjdk 11.0.4

I am currently trying to setup Elasticsearch for a project. I have installed Elasticsearch 7.4.1 and I have also installed Java, that is openjdk 11.0.4.

但是当我尝试使用命令启动 Elasticsearch

But when I try to start Elasticsearch using the command

sudo systemctl start elasticsearch

我得到下面的错误


弹性搜索服务的作业失败,因为控制过程退出并显示错误代码。

Job for elasticsearch.service failed because the control process exited with error code.

请参见 systemctl状态

See "systemctl status elasticsearch.service" and "journalctl -xe" for details.

当我尝试运行命令时

systemctl status elasticsearch.service

我收到错误消息


●elasticsearch.service-Elasticsearch

● elasticsearch.service - Elasticsearch

已加载:已加载(/usr/lib/systemd/system/elasticsearch.service;已禁用; vend

Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vend

活动:自2019-11星期五以来失败(结果:退出代码) -01 06:09:54 UTC; 12s以前

Active: failed (Result: exit-code) since Fri 2019-11-01 06:09:54 UTC; 12s ago

Docs: http://www.elastic.co

进程:5960 ExecStart = / usr / share / elasticsearch / bin / elasticsearch -p $ {PID_DI

Process: 5960 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DI

主PID:5960(代码=已退出,状态= 1 / FAILURE)

Main PID: 5960 (code=exited, status=1/FAILURE)

我已经从计算机中删除/清除了 Elasticsearch ,然后重新安装了几次,但是

I have removed/purged Elasticsearch from my machine and re-installed several times, but it doesn't seem to fix the issue.

我尝试修改默认的 network.host 和< / etc / default / elasticsearch 中的code> host.port 设置为 network.host:0.0.0.0 http.port:9200 可以解决此问题,但还没有运气。

I have tried to modify the default network.host and host.port settings in /etc/default/elasticsearch to network.host: 0.0.0.0 and http.port: 9200 to fix the issue, but no luck yet.

我需要一些帮助。

推荐答案

这是我的解决方法

首先,使用以下命令在您的Nano编辑器中打开 /etc/elasticsearch/elasticsearch.yml

Firstly, Open /etc/elasticsearch/elasticsearch.yml in your nano editor using the command below:

sudo nano /etc/elasticsearch/elasticsearch.yml

您的网络设置应为:

# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200

为了使 Elasticsearch 允许来自本地主机的连接,并还监听端口 9200

In order for Elasticsearch to allow connections from localhost, and to also listen on port 9200.

下一步,运行下面的代码以确定错误原因:

Next, run the code below to determine the cause of the error:

journalctl -xe

错误1


没有足够的内存供Java运行时环境使用继续

There is insufficient memory for the Java Runtime Environment to continue

Soluti

作为JVM应用程序, Elasticsearch 主服务器进程仅利用专用于JVM的内存。所需的内存可能取决于所使用的JVM(32位或64位)。 JVM使用的内存通常包括:

As a JVM application, the Elasticsearch main server process only utilizes memory devoted to the JVM. The required memory may depend on the JVM used (32- or 64-bit). The memory used by JVM usually consists of:


  • 堆空间(通过 -Xms -Xmx

  • 元空间(受可用本机内存量限制)

  • 内部JVM (通常为数十Mb)

  • 依赖于操作系统的内存功能,例如内存映射文件

  • heap space (configured via -Xms and -Xmx)
  • metaspace (limited by the amount of available native memory)
  • internal JVM (usually tens of Mb)
  • OS-dependent memory features like memory-mapped files.

Elasticsearch主要取决于堆内存,该设置通过传递<$ c $来手动进行c> -Xms -Xmx (堆空间)选项(运行 Elasticsearch 服务器的JVM)。

Elasticsearch mostly depends on the heap memory, and this setting manually by passing the -Xms and -Xmx(heap space) option to the JVM running the Elasticsearch server.

解决方案

在以下位置打开 /etc/elasticsearch/jvm.options 您的nano编辑器,使用以下命令:

Open /etc/elasticsearch/jvm.options in your nano editor using the command below:

sudo nano /etc/elasticsearch/jvm.options

首先,取消注释 Xmx Xms 的值

接下来,修改 -Xms的值 -Xmx 占用的物理RAM不超过50%。这些设置的值取决于服务器上可用的RAM数量,Elasticsearch出于JVM堆以外的目的需要内存,因此为此留出空间很重要。

Next, modify the value of -Xms and -Xmx to no more than 50% of your physical RAM. The value for these settings depends on the amount of RAM available on your server and Elasticsearch requires memory for purposes other than the JVM heap and it is important to leave space for this.

最低要求:如果您的物理RAM为 = <1 GB

Minimum requirements: If your physical RAM is <= 1 GB

然后,您的设置应为:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms128m
-Xmx128m

OR

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms256m
-Xmx256m

中等要求:如果您的物理RAM为> = 2 GB < = 4 GB

Medium requirements: If your physical RAM is >= 2 GB but <= 4 GB

然后,您的设置应为:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms512m
-Xmx512m

OR

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms750m
-Xmx750m

大要求:如果您的物理RAM是> = 4 GB ,但< = 8 GB

Large requirements: If your physical RAM is >= 4 GB but <= 8 GB

然后,您的设置应为:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1024m
-Xmx1024m

OR

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms2048m
-Xmx2048m

注意:如果您的物理RAM为> = 8 GB ,则可以决定要使用多少堆空间分配给埃拉sticsearch。您可以分配 -Xms2048m -Xmx2048m -Xms4g -Xmx4g 甚至更高,以根据可用资源获得更好的性能。

Note: If your physical RAM is >= 8 GB you can decide how much heap space you want to allocate to Elasticsearch. You can allocate -Xms2048m and -Xmx2048m OR -Xms4g and -Xmx4g or even higher for better performance based on your available resources.

错误2


初始堆大小不等于最大堆大小

Initial heap size not equal to the maximum heap size

解决方案

确保 -Xms Xmx 的值相等。也就是说,由于您的物理RAM为 <= 1 GB ,因此您使用的是最低要求,而不是:

Ensure the value of -Xms and Xmx are equal. That is, say, you are using the minimum requirements since your physical RAM is <= 1 GB, instead of this:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms128m
-Xmx256m

应该是这样的:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms128m
-Xmx128m

或此:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms256m
-Xmx256m

错误3


默认发现设置不适合生产使用;必须至少配置[discovery.seed_hosts,discovery.seed_providers,cluster.initial_master_nodes]之一

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

解决方案

使用以下命令在您的nano编辑器中打开 /etc/elasticsearch/elasticsearch.yml

Open /etc/elasticsearch/elasticsearch.yml in your nano editor using the command below:

sudo nano /etc/elasticsearch/elasticsearch.yml

您的发现设置应为:

# 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: []

修复所有错误后,运行以下命令以启动并确认 Elasticsearch 的状态:

Once all the errors are fixed run the command below to start and confirm the status of Elasticsearch:

sudo systemctl start elasticsearch
sudo systemctl status elasticsearch

仅此而已。

我希望这对您有帮助

这篇关于Elasticsearch:elasticsearch.service的作业失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆