本文主要介绍docker启动elasticsearch时内存不足的问题。本文为大家分享安装流程和解决方案,对你的学习或工作有一定的参考价值。有需要的朋友可以参考一下。
问题
Docker在安装和启动elasticsearch时内存不足。
Centos8(阿里云ecs服务器)
[root@iZ2zeczvvb79boy368xppwZ~]#cat/etc/redhat-release CentOSLinuxrelease8.1.1911(Core)安装过程
dockerpullelasticsearch:6.4.0修改虚拟机内存(看似无效)
sysctl-wvm.max_map_count=262144使用dockerrun命令运行容器。
dockerrun-p9200:9200-p9300:9300--nameelasticsearch\ -e"discovery.type=single-node"\ -e"cluster.name=elasticsearch"\ -v/mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins\ -v/mydata/elasticsearch/data:/usr/share/elasticsearch/data\ -delasticsearch:6.4.0dockerps查看容器未启动。
[root@iZ2zeczvvb79boy368xppwZ~]#dockerps CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES edfc400862ebrabbitmq:3.7.15"docker-entrypoint.s…"14hoursagoUp14hours0.0.0.0:4369->4369/tcp,0.0.0.0:5671-5672->5671-5672/tcp,0.0.0.0:15671-15672->15671-15672/tcp,0.0.0.0:25672->25672/tcprabbitmq 2ae2f3f8dc1fnginx:1.10"nginx-g'daemonof…"2weeksagoUp2weeks0.0.0.0:80->80/tcp,443/tcpnginx 164e4e7561dfredis:3.2"docker-entrypoint.s…"2weeksagoUp2weeks0.0.0.0:6379->6379/tcpredis eeabe57f1f21mysql:5.7"docker-entrypoint.s…"2weeksagoUp2weeks0.0.0.0:3306->3306/tcp,33060/tcpmysql检查容器确实被创建了
[root@iZ2zeczvvb79boy368xppwZ~]#dockerps-a CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES 767829ae1d7celasticsearch:6.4.0"/usr/local/bin/dock…"AboutaminuteagoExited(1)Aboutaminuteagoelasticsearch edfc400862ebrabbitmq:3.7.15"docker-entrypoint.s…"14hoursagoUp14hours0.0.0.0:4369->4369/tcp,0.0.0.0:5671-5672->5671-5672/tcp,0.0.0.0:15671-15672->15671-15672/tcp,0.0.0.0:25672->25672/tcprabbitmq 2ae2f3f8dc1fnginx:1.10"nginx-g'daemonof…"2weeksagoUp2weeks0.0.0.0:80->80/tcp,443/tcpnginx 164e4e7561dfredis:3.2"docker-entrypoint.s…"2weeksagoUp2weeks0.0.0.0:6379->6379/tcpredis eeabe57f1f21mysql:5.7"docker-entrypoint.s…"2weeksagoUp2weeks0.0.0.0:3306->3306/tcp,33060/tcpmysql检查日志dockerlogs-fd性搜索命令检查日志,发现jvm内存不足。
[root@iZ2zeczvvb79boy368xppwZ~]#dockerlogs-felasticsearch OpenJDK64-BitServerVMwarning:OptionUseConcMarkSweepGCwasdeprecatedinversion9.0andwilllikelyberemovedinafuturerelease. OpenJDK64-BitServerVMwarning:INFO:os::commit_memory(0x00007ebf15330000,549668585472,0)failed;error='Notenoughspace'(errno=12) # #ThereisinsufficientmemoryfortheJavaRuntimeEnvironmenttocontinue. #Nativememoryallocation(mmap)failedtomap549668585472bytesforcommittingreservedmemory. #Anerrorreportfilewithmoreinformationissavedas: #logs/hs_err_pid1.log解决方法
修改jvm.options文件配置
首先找到jvm.options文件的位置(每个服务器的位置可能不一样)。
Vim进入该文件来修改虚拟机的最小内存
[root@iZ2zeczvvb79boy368xppwZ~]#vim/var/lib/docker/overlay2/d399872a3517b4d4acb0d2f70d0625c0f38251ffe5819a1cea00f8213de3e7f5/diff/usr/share/elasticsearch/config/jvm.options找到-Xms属性,修改为512m(我的elasticsearch:6.4.0默认为1g)
##JVMconfiguration ################################################################ ##IMPORTANT:JVMheapsize ################################################################ ## ##YoushouldalwayssettheminandmaxJVMheap ##sizetothesamevalue.Forexample,toset ##theheapto4GB,set: ## ##-Xms4g ##-Xmx4g ## ##Seehttps://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html ##formoreinformation ## ################################################################ #Xmsrepresentstheinitialsizeoftotalheapspace #Xmxrepresentsthemaximumsizeoftotalheapspace -Xms512m -Xmx512m保存并退出
在vim中,按I进入编辑模式,按ESC退出编辑模式,按:进入命令模式,然后输入W保存,Q退出,Q!强行退出。
再次启动容器,dockerps检查容器启动成功。
摘要[/s2/]
关于docker启动elasticsearch时内存不足的问题及其解决方法的文章到此为止。关于docker启动elasticsearch时内存不足的更多信息,请搜索我们之前的文章或者继续浏览下面的相关文章。希望大家以后能多多支持我们!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)