Elasticsearch 未从 Mac 上的本地 docker 安装加载

问题描述 投票:0回答:1

我正在尝试在本地运行elasticsearch,因此我安装了docker,然后按照此guide部署了elasticsearch图像。

在 docker 中启动它时,我可以看到以下信息:

2024-05-20 21:04:48 {"@timestamp":"2024-05-20T18:04:48.744Z", "log.level": "INFO", "message":"JVM 参数 [-Des .networkaddress.cache.ttl=60、-Des.networkaddress.cache.negative.ttl=10、-Djava.security.manager=允许、-XX:+AlwaysPreTouch、-Xss1m、-Djava.awt.headless=true、- Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false,-Dlog4j2.disable.jmx=true,-Dlog4j2.formatMsgNoLookups=true,-Djava.locale.providers=SPI,COMPAT,--add-opens=java.base/java.io=org。 elasticsearch.preallocate, --enable-native-access=org.elasticsearch.nativeaccess, -Des.cgroups.hierarchy.override=/, -XX:ReplayDataFile=logs/replay_pid%p.log, -Des.distribution.type=docker , -XX:+UseG1GC, -Djava.io.tmpdir=/tmp/elasticsearch-15934422589274926101, --add-modules=jdk.incubator.vector, -XX:+HeapDumpOnOutOfMemoryError, -XX:+ExitOnOutOfMemoryError, -XX:HeapDumpPath=数据,-XX:ErrorFile=logs/hs_err_pid%p.log,-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,level,pid,tags:filecount=32,filesize =64m, -Xms3920m, -Xmx3920m, -XX:MaxDirectMemorySize=2055208960, -XX:G1HeapRegionSize=4m, -XX:InitiatingHeapOccupancyPercent=30, -XX:G1ReservePercent=15, --module-path=/usr/share/elasticsearch/ lib, --add-modules=jdk.net, --add-modules=ALL-MODULE-PATH, -Djdk.module.main=org.elasticsearch.server]", "ecs.version": "1.2.0" ,"service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.node.Node" ,"elasticsearch.node.name":"032a36703b3d","elasticsearch.cluster.name":"docker-cluster"}

完整日志

加载时出现““无法访问此页面”:http://localhost:9200/

我尝试更改

中的一些值

/usr/share/elasticsearch/config/jvm.options

但我还没弄清楚问题所在!

我曾尝试启用:

-Xms4g

-Xmx4g

或增加以下方面的内存: Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,level,pid,tags:filecount=32,filesize=64m

################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.13/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## which should be named with .options suffix, and the min and
## max should be set to the same value. For example, to set the
## heap to 4 GB, create a new file in the jvm.options.d
## directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.13/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

# Leverages accelerated vector hardware instructions; removing this may
# result in less optimal vector performance
20-:--add-modules=jdk.incubator.vector

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# exit right after heap dump on out of memory error
-XX:+ExitOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## GC logging
-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,level,pid,tags:filecount=32,filesize=64m

我也尝试添加这一行:

网络.主机:127.0.0.1

在:

/usr/share/elasticsearch/config/elasticsearch.yml

也没有帮助!

docker elasticsearch jvm
1个回答
0
投票

所以你基本上是在尝试创建一个单节点elasticsearch,所有安全设置都已预先完成。

从 Elasticsearch 8.0 开始,默认启用安全性。首次启动 Elasticsearch 时,会自动配置 TLS 加密,为弹性用户生成密码,并创建 Kibana 注册令牌,以便您可以将 Kibana 连接到安全集群。

如果我是你,我首先会清理所有容器。然后,按照您的参考文档的建议,我会添加

docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.13.4
docker run --name elasticsearch -e ES_JAVA_OPTS="-Xms4g -Xmx4g" --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -t docker.elastic.co/elasticsearch/elasticsearch:8.13.4

所以你设置如上

-e ES_JAVA_OPTS="-Xms4g -Xmx4g"

此文档更广泛:https://www.elastic.co/guide/en/elasticsearch/reference/8.5/docker.html

© www.soinside.com 2019 - 2024. All rights reserved.