我在Mkyong站点https://www.mkyong.com/spring-boot/spring-boot-spring-data-elasticsearch-example/上学习本教程
它使用spring-boot-starter-data-elasticsearch库连接到elasticSearch
我使用以下详细信息尝试连接到Amazon上的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
你知道我需要做些什么来连接到亚马逊上的一个ElasticSearch示例吗?
谢谢达米安
3条答案
按热度按时间rkkpypqq1#
AWS Elasticsearch不支持TCP连接,只支持HTTP连接,这就解释了为什么CURL命令有效,而java连接无效。
http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-supported-resources.html
https://forums.aws.amazon.com/thread.jspa?messageID=683536
9cbw7uwe2#
AWS Elasticsearch只能使用Rest API在端口80上工作。来自elasticsearch的默认传输API不适用于托管的AWS elasticsearch。
我不得不定制Jest client来添加额外的钩子来签署每个请求。
您可能需要参考关于堆栈溢出的这篇文章,以获得关于如何签署HTTP请求的更多细节。
lokaqttq3#
使用托管AWSElasticSearch的HOST:ip地址或托管AWS的路径和PORT:80
例如:
10.100.1.1 或xyz.abc.com