我在AWS上设置了一个elasticsearch节点集群。群集包含3个节点。节点位于ELB(Elastic Load平衡器)后面。 ELB的DNS名称为" a.b.c.com"。
我能够成功运行:
curl -XGET 'http://a.b.c.com:9200/_cat/nodes'
这证明权限和路由正常工作。
当我尝试将Java Application Server连接到Elasticsearch时,它失败并出现以下错误:
org.elasticsearch.transport.ReceiveTimeoutTransportException: [][inet[a.b.c.com/172.31.27.110:9300]][cluster:monitor/nodes/info] request_id [57] timed out after [10000ms]
at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:366)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
无论我是否增加client.transport.ping_timeout。
,都会发生这种情况我用来连接的java代码如下所示:
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).put("client.transport.ping_timeout", 10000).build();
client = new TransportClient(settings);
TransportClient transportClient = (TransportClient)client;
transportClient.addTransportAddress(new InetSocketTransportAddress(instance, esPort));
实例=" a.b.c.com" esPort = 9300(我也试过了9200)
提前帮忙。
答案 0 :(得分:2)
对于将来寻找任何可怜的灵魂的答案:
您的ES节点在9300上运行,并且您的安全组在该实例上打开,以允许来自您的应用服务器的连接。
但是ELB有自己的安全组。所以你需要这样做:
在ELB上设置SG以允许从您的应用服务器进行连接。 在ES实例上设置SG以允许从ELB进行连接。
并在你的ES实例上设置SG以允许自己的9300流量 - 一旦他们发现彼此需要能够自己交谈!
答案 1 :(得分:0)
ELB是否配置为允许TCP? Java客户端使用TCP,默认情况下,ELB仅为HTTP配置。您可以按照http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-listener-config.html
更改相同内容