我已经使用eks kubernetes集群在aws中部署了Elastic-search容器。尽管只有3个索引,但容器的内存使用量一直在增加,而且使用率并不高。我正在使用FluentD将集群容器日志转储到弹性搜索中。除此之外,没有使用elastic-search。我尝试使用-Xms512m -Xmx512m
应用最小/最大堆大小。它成功地应用了,但内存使用量在24小时内几乎翻了一番。我不确定还需要配置哪些其他选项。我尝试将docker镜像从elasticsearch:6.5.4
更改为elasticsearch:6.5.1
。但问题依然存在。我还尝试了-XX:MaxHeapFreeRatio=50
java选项。
查看来自kibana的屏幕截图。
编辑:以下是Elastic-search启动时的日志:
[2019-03-18T13:24:03,119][WARN ][o.e.b.JNANatives ] [es-79c977d57-v77gw] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2019-03-18T13:24:03,120][WARN ][o.e.b.JNANatives ] [es-79c977d57-v77gw] This can result in part of the JVM being swapped out.
[2019-03-18T13:24:03,120][WARN ][o.e.b.JNANatives ] [es-79c977d57-v77gw] Increase RLIMIT_MEMLOCK, soft limit: 16777216, hard limit: 16777216
[2019-03-18T13:24:03,120][WARN ][o.e.b.JNANatives ] [es-79c977d57-v77gw] These can be adjusted by modifying /etc/security/limits.conf, for example:
# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
[2019-03-18T13:24:03,120][WARN ][o.e.b.JNANatives ] [es-79c977d57-v77gw] If you are logged in interactively, you will have to re-login for the new limits to take effect.
[2019-03-18T13:24:03,397][INFO ][o.e.e.NodeEnvironment ] [es-79c977d57-v77gw] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/xvda1)]], net usable_space [38.6gb], net total_space [96.8gb], types [ext4]
[2019-03-18T13:24:03,397][INFO ][o.e.e.NodeEnvironment ] [es-79c977d57-v77gw] heap size [503.6mb], compressed ordinary object pointers [true]
[2019-03-18T13:24:03,469][INFO ][o.e.n.Node ] [es-79c977d57-v77gw] node name [es-79c977d57-v77gw], node ID [qrCUCaHoQfa3SXuTpLjUUA]
[2019-03-18T13:24:03,469][INFO ][o.e.n.Node ] [es-79c977d57-v77gw] version[6.5.1], pid[1], build[default/tar/8c58350/2018-11-16T02:22:42.182257Z], OS[Linux/4.15.0-1032-aws/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/11.0.1/11.0.1+13]
[2019-03-18T13:24:03,469][INFO ][o.e.n.Node ] [es-79c977d57-v77gw] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -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, -Djava.io.tmpdir=/tmp/elasticsearch.oEmM9oSp, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -XX:UseAVX=2, -Des.cgroups.hierarchy.override=/, -Xms512m, -Xmx512m, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2019-03-18T13:24:05,082][INFO ][o.e.p.PluginsService ] [es-79c977d57-v77gw] loaded module [aggs-matrix-stats]
[2019-03-18T13:24:05,082][INFO ][o.e.p.PluginsService ] [es-79c977d57-v77gw] loaded module [analysis-common]
[2019-03-18T13:24:05,082][INFO ][o.e.p.PluginsService ] [es-79c977d57-v77gw] loaded module [ingest-common] ....
发布于 2019-03-15 21:53:31
Kubernetes中的Pod内存使用率并不等同于JVM内存使用率--要获得这个统计数据,您必须直接从JVM中提取指标。Pod内存的使用情况取决于您正在查询的指标,除了应用程序内存之外,还可能包括页面缓存和交换空间,因此无法从图表中看出您提供的实际内存消耗情况。根据问题的不同,Elasticsearch具有诸如memory locking之类的高级特性,它会将您的进程地址空间锁定在内存中。但是,防止Kubernetes pod占用非JVM内存的一种可靠方法是对该pod可以消耗的内存量设置一个限制。在Kubernetes pod规范中,将resources.limits.memory
设置为所需的内存上限,您的内存消耗将不会超出该限制。当然,如果这是您的JVM配置的问题,那么当ES pod达到限制时,它将失败并显示OOM错误。只需确保为系统资源分配了额外的空间,我的意思是,pod内存限制应该比最大JVM堆大小稍大一些。
另外,您可能会惊讶于Kubernetes实际上在幕后做了多少日志记录。定期考虑不定期搜索的closing Elasticsearch indexes,以释放内存。
https://stackoverflow.com/questions/55155385
复制相似问题