您的位置:首页技术文章
文章详情页

docker 报错 Exited (1) 4 minutes ago的原因分析

【字号: 日期:2024-11-15 13:08:26浏览:10作者:猪猪

docker 报错

1. 查看原因

docker logs nexus

docker 报错 Exited (1) 4 minutes ago的原因分析

2. 报错原因

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e7000000, 419430400, 0) failed; error=‘Cannot allocate memory’ (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 419430400 bytes for committing reserved memory. # An error report file with more information is saved as: # /opt/sonatype/nexus/hs_err_pid1.log

补充知识:Docker 安装运行 ElasticSearch 遇到的问题!

在创建 6.4.3版本的 ES 以后启动发现过了一会 ES 自动退出了。

原因好像是 ES 的默认分配的内存太大了。进程被自动杀死了。

所以以下我来记录下这坑:

使用ES工具类索引时运行测试方法时报错

org.elasticsearch.transport.ConnectTransportException: [][192.168.235.9300] connect_timeout[30s]

发现使用SpringBoot 2.x的版本导入的ES的包与Docker 上安装的 ES 版本不兼容的问题。

SpringBoot 2.1.3版本引入的Spring-Data-ES包为:3.1.5

docker 报错 Exited (1) 4 minutes ago的原因分析

Docker安装的ES版本为:5.6.12

docker 报错 Exited (1) 4 minutes ago的原因分析

查看官方文档的适配关系:

docker 报错 Exited (1) 4 minutes ago的原因分析

发现 3.1.X 对应需要ES 6.2.2版本以上

我项目整合的ES的Jar包为6.4.3

docker 报错 Exited (1) 4 minutes ago的原因分析

然后我们在Docker 安装 6.4.3版本的 ES

我们使用 Docker 中国官方镜像加速:

# docker pull registry.docker-cn.com/library/elasticsearch:6.4.3

下载完毕后我们创建容器并启动:

//列出本地所有镜像 # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEregistry.docker-cn.com/library/rabbitmq 3-management 92682ab7dca0 12 days ago 212MBregistry.docker-cn.com/library/elasticsearch 6.4.3 01e5bee1e059 4 months ago 795MBregistry.docker-cn.com/library/elasticsearch latest 5acf0e8da90b 5 months ago 486MB

由于ES版本在 5.0 以后默认分配的内存是 2G 创建Docker启动时需要 1G 所以我们可以参数上设置它的环境变量:

也可以更改对应的 jvm.options 配置

我们创建运行 6.4.3 的ES

# docker run -e ES_JAVA_OPTS='-Xms256m -Xmx256m' -d -p 9201:9200 -p 9301:9300 --name ES02 01e5bee1e059

然后出现了下列情况以后,ES 容器自动停止了。:

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.[2019-03-06T03:29:17,534][INFO ][o.e.n.Node ] [] initializing ...[2019-03-06T03:29:17,680][INFO ][o.e.e.NodeEnvironment ] [gV0jbyu] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [13.6gb], net total_space [16.9gb], types [rootfs][2019-03-06T03:29:17,681][INFO ][o.e.e.NodeEnvironment ] [gV0jbyu] heap size [247.6mb], compressed ordinary object pointers [true][2019-03-06T03:29:17,690][INFO ][o.e.n.Node ] [gV0jbyu] node name derived from node ID [gV0jbyuBSrmiqJJ8p524XA]; set [node.name] to override[2019-03-06T03:29:17,691][INFO ][o.e.n.Node ] [gV0jbyu] version[6.4.3], pid[1], build[default/tar/fe40335/2018-10-30T23:17:19.084789Z], OS[Linux/3.10.0-957.5.1.el7.x86_64/amd64], JVM['Oracle Corporation'/OpenJDK 64-Bit Server VM/10.0.2/10.0.2+13][2019-03-06T03:29:17,691][INFO ][o.e.n.Node ] [gV0jbyu] 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.GVv4IesY, -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=/, -Xms256m, -Xmx256m, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar][2019-03-06T03:29:22,164][INFO ][o.e.p.PluginsService ] [gV0jbyu] loaded module [aggs-matrix-stats]...[2019-03-06T03:29:26,129][WARN ][o.e.d.s.ScriptModule ] Script: returning default values for missing document values is deprecated. Set system property ’-Des.scripting.exception_for_missing_value=true’ to make behaviour compatible with future major versions.[2019-03-06T03:29:30,804][INFO ][o.e.x.s.a.s.FileRolesStore] [gV0jbyu] parsed [0] roles from file [/usr/share/elasticsearch/config/roles.yml][2019-03-06T03:29:31,986][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/62] [Main.cc@109] controller (64 bit): Version 6.4.3 (Build 7a0781676dd492) Copyright (c) 2018 Elasticsearch BV[2019-03-06T03:29:32,929][INFO ][o.e.d.DiscoveryModule ] [gV0jbyu] using discovery type [zen][2019-03-06T03:29:34,282][INFO ][o.e.n.Node ] [gV0jbyu] initialized[2019-03-06T03:29:34,283][INFO ][o.e.n.Node ] [gV0jbyu] starting ...[2019-03-06T03:29:34,625][INFO ][o.e.t.TransportService ] [gV0jbyu] publish_address {172.17.0.2:9300}, bound_addresses {0.0.0.0:9300}[2019-03-06T03:29:34,656][INFO ][o.e.b.BootstrapChecks ] [gV0jbyu] bound or publishing to a non-loopback address, enforcing bootstrap checksERROR: [1] bootstrap checks failed[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144][2019-03-06T03:29:34,721][INFO ][o.e.n.Node ] [gV0jbyu] stopping ...[2019-03-06T03:29:34,760][INFO ][o.e.n.Node ] [gV0jbyu] stopped[2019-03-06T03:29:34,760][INFO ][o.e.n.Node ] [gV0jbyu] closing ...[2019-03-06T03:29:34,778][INFO ][o.e.n.Node ] [gV0jbyu] closed[2019-03-06T03:29:34,780][INFO ][o.e.x.m.j.p.NativeController] Native controller process has stopped - no new native processes can be started

输出了一下错误日志,大致翻译了一下看到了这句话:

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

说是 最大虚拟内存区 vm.max_map_count 设置的 65530 太低,至少要增加到 262144

网上百度了一下设置方法:

# sudo sysctl -w vm.max_map_count=262144

然后我们再来启动 ES

# docker start ES02

过一会我们再来查看它的状态:

# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESbdaed6794ca6 5acf0e8da90b '/docker-entrypoint.…' 5 minutes ago Exited (130) 6 seconds ago ES017d2dcc5512ee 01e5bee1e059 '/usr/local/bin/dock…' 3 hours ago Up 15 minutes 0.0.0.0:9201->9200/tcp, 0.0.0.0:9301->9300/tcp ES02d372501cc505 92682ab7dca0 'docker-entrypoint.s…' 4 days ago Exited (0) 22 hours ago myrabbitmq

发现是正常启动的以后我们来访问一下 http 对应的端口:

http://192.168.235.128:9201/

docker 报错 Exited (1) 4 minutes ago的原因分析

发现我们安装的 6.4.3 版本的 ES 就没有问题了。

以上这篇docker 报错 Exited (1) 4 minutes ago的原因分析就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持好吧啦网。

标签: Docker
相关文章: