gpt4 book ai didi

java - 使用 Elastic Search 6.2.3 在 AWS EC2 上运行 Spring Boot 2.0.3 应用程序

转载 作者:行者123 更新时间:2023-11-30 06:01:27 25 4
gpt4 key购买 nike

我正在使用 Spring Boot 应用程序。最近我们已将应用程序更新到版本 spring boot 2.0.3。它在 Elastic Search 6.2.3 版本上运行良好。

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

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

将相同的 Elasticsearch 配置放入 application-prod.yml 并运行 Spring Boot 应用程序时,它无法启动并出现错误:

Cannot resolve reference to bean 'elasticsearchTemplate' while setting bean property 'elasticsearchOperations'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'elasticsearchTemplate' available

我们能够从 EC2 实例访问任何版本的 Elastic Search。

尝试过:

  1. 运行了 Elastic Search 版本 5.4.0,但它也无法正常工作。
  2. 如果没有使用IP和端口配置elasticsearch.yml(使用默认配置运行),那么也不起作用。
  3. elasticsearch.yml 中的设置:

network.host: my ip address

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 和 elastic search 2.3.5。

一件有趣的事情是,相同配置的 Elasticsearch 6.2.3 和 spring boot 应用程序在本地计算机上运行良好,但在 EC2 实例上抛出上述错误。

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

最佳答案

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

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

关于java - 使用 Elastic Search 6.2.3 在 AWS EC2 上运行 Spring Boot 2.0.3 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52216484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com