溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

發(fā)布時(shí)間:2020-11-19 14:37:40 來源:億速云 閱讀:3177 作者:Leah 欄目:開發(fā)技術(shù)

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決?相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

docker 報(bào)錯(cuò)

1. 查看原因

docker logs nexus

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

2. 報(bào)錯(cuò)原因

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

補(bǔ)充知識(shí):Docker 安裝運(yùn)行 ElasticSearch 遇到的問題!

在創(chuàng)建 6.4.3版本的 ES 以后啟動(dòng)發(fā)現(xiàn)過了一會(huì) ES 自動(dòng)退出了。

原因好像是 ES 的默認(rèn)分配的內(nèi)存太大了。進(jìn)程被自動(dòng)殺死了。

所以以下我來記錄下這坑:

使用ES工具類索引時(shí)運(yùn)行測(cè)試方法時(shí)報(bào)錯(cuò)

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

發(fā)現(xiàn)使用SpringBoot 2.x的版本導(dǎo)入的ES的包與Docker 上安裝的 ES 版本不兼容的問題。

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

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

Docker安裝的ES版本為:5.6.12

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

查看官方文檔的適配關(guān)系:

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

發(fā)現(xiàn) 3.1.X 對(duì)應(yīng)需要ES 6.2.2版本以上

我項(xiàng)目整合的ES的Jar包為6.4.3

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

然后我們?cè)贒ocker 安裝 6.4.3版本的 ES

我們使用 Docker 中國官方鏡像加速:

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

下載完畢后我們創(chuàng)建容器并啟動(dòng):

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

由于ES版本在 5.0 以后默認(rèn)分配的內(nèi)存是 2G 創(chuàng)建Docker啟動(dòng)時(shí)需要 1G 所以我們可以參數(shù)上設(shè)置它的環(huán)境變量:

也可以更改對(duì)應(yīng)的 jvm.options 配置

我們創(chuàng)建運(yùn)行 6.4.3 的ES

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

然后出現(xiàn)了下列情況以后,ES 容器自動(dòng)停止了。:

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 checks
ERROR: [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

輸出了一下錯(cuò)誤日志,大致翻譯了一下看到了這句話:

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

說是 最大虛擬內(nèi)存區(qū) vm.max_map_count 設(shè)置的 65530 太低,至少要增加到 262144

網(wǎng)上百度了一下設(shè)置方法:

# sudo sysctl -w vm.max_map_count=262144

然后我們?cè)賮韱?dòng) ES

# docker start ES02

過一會(huì)我們?cè)賮聿榭此臓顟B(tài):

# docker ps -a
CONTAINER ID  IMAGE    COMMAND     CREATED    STATUS      PORTS           NAMES
bdaed6794ca6  5acf0e8da90b  "/docker-entrypoint.…" 5 minutes ago  Exited (130) 6 seconds ago             ES01
7d2dcc5512ee  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 ES02
d372501cc505  92682ab7dca0  "docker-entrypoint.s…" 4 days ago   Exited (0) 22 hours ago              myrabbitmq

發(fā)現(xiàn)是正常啟動(dòng)的以后我們來訪問一下 http 對(duì)應(yīng)的端口:

http://192.168.235.128:9201/

使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決

看完上述內(nèi)容,你們掌握使用docker 出現(xiàn) Exited (1) 4 minutes ago報(bào)錯(cuò)如何解決的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI