我在Mkyong网站上关注本教程 https://www.mkyong.com/spring-boot/spring-boot-spring-data-elasticsearch-example/
它使用spring-boot-starter-data-elasticsearch库连接到elasticSearch
我使用以下详细信息尝试连接到亚马逊上的弹性搜索实例
elasticsearch.host=<search address in amazon elastic search console>
elasticsearch.port=9200
elasticsearch.clustername=<accountId:clusterName>`
但是我一直收到以下错误
2017-05-16 18:37:24.308 INFO 7108 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'elasticsearchTemplate' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=esConfig; factoryMethodName=elasticsearchTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mkyong/EsConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration; factoryMethodName=elasticsearchTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]]
2017-05-16 18:37:24.859 INFO 7108 --- [ main] org.elasticsearch.plugins : [Rawhide Kid] modules [], plugins [], sites []
2017-05-16 18:37:46.911 INFO 7108 --- [ main] org.elasticsearch.client.transport : [Rawhide Kid] failed to connect to node [{#transport#-1}{55.66.223.158}{55.66.223.158:9200}], removed from nodes list
org.elasticsearch.transport.ConnectTransportException: [][55.66.223.158:9200] connect_timeout[30s]
at org.elasticsearch.transport.netty.NettyTransport.connectToChannelsLight(NettyTransport.java:967) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:933) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.transport.netty.NettyTransport.connectToNodeLight(NettyTransport.java:906) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.transport.TransportService.connectToNodeLight(TransportService.java:267) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.doSample(TransportClientNodesService.java:390) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.client.transport.TransportClientNodesService$NodeSampler.sample(TransportClientNodesService.java:336) [elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.client.transport.TransportClientNodesService.addTransportAddresses(TransportClientNodesService.java:187) [elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.client.transport.TransportClient.addTransportAddress(TransportClient.java:243) [elasticsearch-2.4.4.jar:2.4.4]
at com.mkyong.EsConfig.client(EsConfig.java:45) [classes/:na]
at com.mkyong.EsConfig$$EnhancerBySpringCGLIB$$7e0ccfee.CGLIB$client$0(<generated>) [classes/:na]
at com.mkyong.EsConfig$$EnhancerBySpringCGLIB$$7e0ccfee$$FastClassBySpringCGLIB$$83a2b819.invoke(<generated>) [classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) [spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at com.mkyong.EsConfig$$EnhancerBySpringCGLIB$$7e0ccfee.client(<generated>) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instant
我需要做些什么才能连接到亚马逊上的弹性搜索实例?
由于 达明
答案 0 :(得分:0)
AWS Elasticsearch不支持TCP连接,仅支持HTTP连接。这解释了为什么CURL命令有效,但是你的java连接不起作用。
TCP transport
The service supports HTTP on port 80, but does not support TCP transport.
http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-supported-resources.html
答案 1 :(得分:0)
AWS Elasticsearch仅适用于使用Rest API的端口80。 elasticsearch的默认传输API不适用于Hosted AWS elasticsearch。
我必须自定义Jest client以添加额外的挂钩以对每个请求进行签名。
您可能需要参阅Stack Overflow上的this帖子,了解有关如何签署HTTP请求的更多详细信息。
答案 2 :(得分:0)
使用主机:托管的AWS Elasticsearch的IP地址或托管的AWS es和PORT的路径:80
例如:
10.100.1.1:80或xyz.abc.com:80