Docker Desktop部署Elasticsearch 5.2.0失败的排查与解决
问题背景
- 现有非Docker环境基于Ubuntu 18.04(从16.04升级),运行Elasticsearch 5.2.0、MongoDB 4.2.8、Java 8+Tomcat业务应用,运行正常
- 目标:通过单个docker-compose完成全栈容器化,需保留应用依赖的
org.elasticsearch.elasticsearch 5.2.0版本库 - 问题:Elasticsearch 5.2.0容器无法启动,在MacOS Ventura(M1)和Windows11(i7-9代)环境均出现相同错误,MongoDB容器运行正常
报错信息
2023-08-08 16:22:57 [2023-08-08T08:22:57,087][INFO ][o.e.n.Node ] [es01] initializing ... 2023-08-08 16:22:57 [2023-08-08T08:22:57,199][INFO ][o.e.e.NodeEnvironment ] [es01] using [1] data paths, mounts [[/ (overlay)]], net usable_space [233gb], net total_space [250.9gb], spins? [possibly], types [overlay] 2023-08-08 16:22:57 [2023-08-08T08:22:57,199][INFO ][o.e.e.NodeEnvironment ] [es01] heap size [1.9gb], compressed ordinary object pointers [true] 2023-08-08 16:22:57 [2023-08-08T08:22:57,202][INFO ][o.e.n.Node ] [es01] node name [es01], node ID [6LH5fzjMRBSvg5c1JpC1Pw] 2023-08-08 16:22:57 [2023-08-08T08:22:57,206][INFO ][o.e.n.Node ] [es01] version[5.2.0], pid[1], build[24e05b9/2017-01-24T19:52:35.800Z], OS[Linux/5.10.16.3-microsoft-standard-WSL2/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_92-internal/25.92-b14] 2023-08-08 16:22:59 [2023-08-08T08:22:59,630][INFO ][o.e.p.PluginsService ] [es01] loaded module [aggs-matrix-stats] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [ingest-common] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [lang-expression] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [lang-groovy] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [lang-mustache] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [lang-painless] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [percolator] 2023-08-08 16:22:59 [2023-08-08T08:22:59,631][INFO ][o.e.p.PluginsService ] [es01] loaded module [reindex] 2023-08-08 16:22:59 [2023-08-08T08:22:59,632][INFO ][o.e.p.PluginsService ] [es01] loaded module [transport-netty3] 2023-08-08 16:22:59 [2023-08-08T08:22:59,632][INFO ][o.e.p.PluginsService ] [es01] loaded module [transport-netty4] 2023-08-08 16:22:59 [2023-08-08T08:22:59,633][INFO ][o.e.p.PluginsService ] [es01] loaded plugin [x-pack] 2023-08-08 16:23:00 [2023-08-08T08:23:00,391][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead 2023-08-08 16:23:01 [2023-08-08T08:23:01,237][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [es01] uncaught exception in thread [main] 2023-08-08 16:23:01 org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: No match found 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 Caused by: java.lang.IllegalStateException: No match found 2023-08-08 16:23:01 at java.util.regex.Matcher.group(Matcher.java:536) ~[?:1.8.0_92-internal] 2023-08-08 16:23:01 at org.elasticsearch.monitor.os.OsProbe.getControlGroups(OsProbe.java:216) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.monitor.os.OsProbe.getCgroup(OsProbe.java:414) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.monitor.os.OsProbe.osStats(OsProbe.java:466) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.monitor.os.OsService.<init>(OsService.java:45) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.monitor.MonitorService.<init>(MonitorService.java:45) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.node.Node.<init>(Node.java:345) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.node.Node.<init>(Node.java:232) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Bootstrap$6.<init>(Bootstrap.java:241) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:241) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.0.jar:5.2.0] 2023-08-08 16:23:01 ... 6 more
原docker-compose.yml配置
version: '3.8' services: mongodb: image: 'mongo:4.2.8' container_name: 'my_db_container' ports: - 27017:27017 entrypoint: [ "/usr/bin/mongod", "--bind_ip_all" ] elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:5.2.0 platform: linux/amd64 ports: - 9200:9200 - 9300:9300 environment: - discovery.type=single-node - node.name=es01 - cluster.name=my-es-local # - bootstrap.system_call_filter=false app: build: . ports: - 8080:8080 - 8000:8000 - 9090:9090 volumes: - /var/run/docker.sock:/var/run/docker.sock - ./target/order-0.0.1-SNAPSHOT/:/opt/apache-tomcat-8.5.82/webapps/ROOT/ depends_on: - mongodb - elasticsearch environment: CATALINA_OPTS: "$CATALINA_OPTS -Dlogs.path.location=D:/my-logs/dev/logs/" JPDA_ADDRESS: 8000 JPDA_TRANSPORT: dt_socket
有效解决方案
核心调整点
- 升级Elasticsearch镜像版本:将
docker.elastic.co/elasticsearch/elasticsearch:5.2.0替换为5.6.3,该版本仍兼容应用依赖的org.elasticsearch.elasticsearch 5.2.0库 - 调整ES容器环境变量:添加必要的兼容性配置,解决Cgroup匹配问题
- 应用端配置:因使用单节点集群,设置
client.transport.sniff=false,确保应用正常连接
修改后的Elasticsearch服务配置
elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3 platform: linux/amd64 ports: - 9200:9200 - 9300:9300 environment: - discovery.type=single-node - node.name=es01 - cluster.name=my-es-local - xpack.security.enabled=false - http.publish_host=localhost - bootstrap.system_call_filter=false
该方案已在MacOS Ventura(MBP M1)和Windows11 64位环境验证有效。
内容的提问来源于stack exchange,提问作者Borgy Manotoy
相关产品推荐
相关产品推荐

