0

I'm trying to setup elasticsearch on my AWS lightsail instance, and got it running on port 9200, however I'm not able to connect from AWS lambda to the instance on the same port. I've updated my lightsail instance level networking setting to allow port 9200 to accept traffic, however I'm neither able to connect to port 9200 through the static IP, nor I'm able to get my AWS lambda function to talk to my lightsail host on port 9200.

I understand that AWS has separate Elasticsearch offering that I can use, however I'm doing a test setup and need to run vanilla ES on the same lightsail host. The ES is up and running and I can connect to it through SSH tunnel, however it doesn't work when I try to connect using the static IP or through another AWS service.

Any pointers shall be appreciated.

Thanks.

4

2 回答 2

0

我可能迟到了,但是对于仍在为此类问题苦苦挣扎的任何人都应该知道,默认情况下,新版本的弹性搜索绑定到本地主机,如本答案中所述 以覆盖此行为,您应该设置:

network.bind_host: 0 

允许在本地主机之外访问节点

于 2019-03-23T21:27:42.427 回答
0

更新 elasticsearch.yml

  network.host: _ec2:privateIpv4_

我们在 AWS 云上运行多个版本的 elaticsearch 集群:

elasticsearch-2.4 集群 elasticsearch.yml(在经典 ec2 实例上 --i3.2xlarge )

cluster.name: ES-CLUSTER

node.name: ES-NODE-01

node.max_local_storage_nodes: 1

node.rack_id: rack_us_east_1d

index.number_of_shards: 8

index.number_of_replicas: 1

gateway.recover_after_nodes: 1

gateway.recover_after_time: 2m

gateway.expected_nodes: 1

discovery.zen.minimum_master_nodes: 1

discovery.zen.ping.multicast.enabled: false

cloud.aws.access_key: ***

cloud.aws.secret_key: ***

cloud.aws.region: us-east-1

discovery.type: ec2

discovery.ec2.groups: es-cluster-sg

network.host: _ec2:privateIpv4_

elasticsearch-6.3 cluster elasticsearch.yml(VPC & i3.2xlarge 实例内部)

cluster.name: ES-CLUSTER

node.name: ES-NODE-01

gateway.recover_after_nodes: 1

gateway.recover_after_time: 2m

gateway.expected_nodes: 1

discovery.zen.minimum_master_nodes: 1

discovery.zen.hosts_provider: ec2

discovery.ec2.groups: vpc-es-eluster-sg

network.host: _ec2:privateIpv4_

path:
  logs: /es-data/log
  data: /es-data/data

discovery.ec2.host_type: private_ip

discovery.ec2.tag.es_cluster: staging-elasticsearch  
discovery.ec2.endpoint: ec2.us-east-1.amazonaws.com

我建议不要对外开放端口 9300 和 9200。仅允许 EC2 实例与您的 elaticsearch 通信。

现在如何从我的本地盒子访问弹性搜索?

使用以下命令从您的系统使用隧道(端口转发):

  $ ssh -i es.pem ec2-user@es-node-public-ip -L 9200:es-node-private-ip:9200 -N 

就像,您正在本地系统上运行弹性搜索。

于 2018-09-14T05:10:35.553 回答