【问题标题】:Run Spring Boot 2.0.3 application on AWS EC2 with Elastic Search 6.2.3使用 Elastic Search 6.2.3 在 AWS EC2 上运行 Spring Boot 2.0.3 应用程序
【发布时间】:2019-02-12 10:47:56
【问题描述】:

我正在使用 Spring Boot 应用程序。最近我们更新了我们的应用程序到版本 spring boot 2.0.3Elastic Search 6.2.3 版本可以正常工作。

我们已经使用我们的应用程序创建了构建,并在本地系统上使用application-prod.yml 成功测试了弹性搜索服务版本 6.2.3。

但是当我们迁移到 AWS EC2 实例时。 Ran Elastic search 6.2.3,得到引导检查的错误,但错误已通过Elasticsearch 5.x - Bootstrap checks failing 解决 然后我们就可以在实例之外访问弹性搜索。

在 application-prod.yml 中放入相同的弹性搜索配置并运行 spring boot 应用程序时,它无法启动并出现错误:

设置时无法解析对 bean 'elasticsearchTemplate' 的引用 bean 属性“elasticsearchOperations”;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException: 否 名为“elasticsearchTemplate”的 bean 可用

我们可以从 EC2 实例访问任何版本的弹性搜索。

试过了:

  1. 运行弹性搜索 5.4.0 版,但也无法正常工作。
  2. 如果不使用 IP 和端口配置 elasticsearch.yml(使用默认配置运行),那么也无法正常工作。
  3. 在 elasticsearch.yml 中设置:

network.host:我的ip地址

http.port: 9400

transport.tcp.port: 9100

transport.host: 127.0.0.1

Elastic Search 6.2.3 登录启动(已启动):

[ec2-user@ip-172-31-66-241 bin]$ sh elasticsearch
[2018-09-07T06:33:36,234][INFO ][o.e.n.Node               ] [node-esonaws] initializing ...
[2018-09-07T06:33:36,299][INFO ][o.e.e.NodeEnvironment    ] [node-esonaws] using [1] data paths, mounts [[/ (/dev/xvda1)]], net usable_space [5.8gb], net total_space [7.7gb], types [ext4]
[2018-09-07T06:33:36,299][INFO ][o.e.e.NodeEnvironment    ] [node-esonaws] heap size [1007.3mb], compressed ordinary object pointers [true]
[2018-09-07T06:33:36,300][INFO ][o.e.n.Node               ] [node-esonaws] node name [node-esonaws], node ID [s_p8BehORnOHD-zKCtf9vg]
[2018-09-07T06:33:36,300][INFO ][o.e.n.Node               ] [node-esonaws] version[6.2.3], pid[10407], build[c59ff00/2018-03-13T10:06:29.741383Z], OS[Linux/4.9.81-35.56.amzn1.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_161/25.161-b14]
[2018-09-07T06:33:36,300][INFO ][o.e.n.Node               ] [node-esonaws] 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.4vPhJaqc, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/home/ec2-user/elasticsearch-6.2.3, -Des.path.conf=/home/ec2-user/elasticsearch-6.2.3/config]
[2018-09-07T06:33:36,944][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [aggs-matrix-stats]
[2018-09-07T06:33:36,944][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [analysis-common]
[2018-09-07T06:33:36,944][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [ingest-common]
[2018-09-07T06:33:36,945][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [lang-expression]
[2018-09-07T06:33:36,945][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [lang-mustache]
[2018-09-07T06:33:36,945][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [lang-painless]
[2018-09-07T06:33:36,946][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [mapper-extras]
[2018-09-07T06:33:36,946][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [parent-join]
[2018-09-07T06:33:36,946][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [percolator]
[2018-09-07T06:33:36,946][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [rank-eval]
[2018-09-07T06:33:36,946][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [reindex]
[2018-09-07T06:33:36,947][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [repository-url]
[2018-09-07T06:33:36,947][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [transport-netty4]
[2018-09-07T06:33:36,947][INFO ][o.e.p.PluginsService     ] [node-esonaws] loaded module [tribe]
[2018-09-07T06:33:36,947][INFO ][o.e.p.PluginsService     ] [node-esonaws] no plugins loaded
[2018-09-07T06:33:39,393][INFO ][o.e.d.DiscoveryModule    ] [node-esonaws] using discovery type [zen]
[2018-09-07T06:33:39,919][INFO ][o.e.n.Node               ] [node-esonaws] initialized
[2018-09-07T06:33:39,920][INFO ][o.e.n.Node               ] [node-esonaws] starting ...
[2018-09-07T06:33:40,040][INFO ][o.e.t.TransportService   ] [node-esonaws] publish_address {172.31.67.241:9300}, bound_addresses {172.31.67.241:9300}
[2018-09-07T06:33:40,056][INFO ][o.e.b.BootstrapChecks    ] [node-esonaws] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2018-09-07T06:33:43,110][INFO ][o.e.c.s.MasterService    ] [node-esonaws] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {node-esonaws}{s_p8BehORnOHD-zKCtf9vg}{k_9Tu_5OR4WZRJj86X0n8g}{172.31.67.241}{172.31.67.241:9300}
[2018-09-07T06:33:43,128][INFO ][o.e.c.s.ClusterApplierService] [node-esonaws] new_master {node-esonaws}{s_p8BehORnOHD-zKCtf9vg}{k_9Tu_5OR4WZRJj86X0n8g}{172.31.67.241}{172.31.67.241:9300}, reason: apply cluster state (from master [master {node-esonaws}{s_p8BehORnOHD-zKCtf9vg}{k_9Tu_5OR4WZRJj86X0n8g}{172.31.67.241}{172.31.67.241:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-09-07T06:33:43,151][INFO ][o.e.g.GatewayService     ] [node-esonaws] recovered [0] indices into cluster_state
[2018-09-07T06:33:43,163][INFO ][o.e.h.n.Netty4HttpServerTransport] [node-esonaws] publish_address {172.31.67.241:9400}, bound_addresses {172.31.67.241:9400}
[2018-09-07T06:33:43,164][INFO ][o.e.n.Node               ] [node-esonaws] started

但没有任何效果!

所有这些配置在本地机器上都可以正常运行,并且可以正确运行我的 spring boot 应用程序。

注意:之前我能够在 AWS EC2 上成功运行 spring boot 1.4.0 和弹性搜索 2.3.5。

一个有趣的事情是相同配置的弹性搜索 6.2.3 与 Spring Boot 应用程序在本地机器上运行良好,但上面提到的 EC2 实例抛出错误。

如何在AWS EC2上运行spring boot 2.0.3 + elastic search 6.2.3?

【问题讨论】:

  • ES 6.2.3能正常启动吗?如果可以,能否分享一下启动时看到的 ES 日志?
  • @Val 是 ES 6.2.3 工作正常,并在访问 IP 上显示标语:“标语”:“您知道,用于搜索”还更新了日志问题

标签: java spring spring-boot elasticsearch amazon-ec2


【解决方案1】:

我遇到了同样的问题。就我而言,我的代码无法读取我的 application.yml 文件是我非常愚蠢的错误,因此在修复读取路径后,问题解决了。

只是为了确定,你能检查一下yml文件的路径吗?

【讨论】:

  • 是的!问题出在配置文件上,构建无法读取 yml 路径。更正了 yml 文件的路径,成功了!!
猜你喜欢
  • 2017-09-28
  • 2016-07-01
  • 2017-04-19
  • 2019-01-24
  • 2021-12-18
  • 1970-01-01
  • 2020-11-09
  • 2016-06-16
  • 2017-02-02
相关资源
最近更新 更多