简体   繁体   English

无法访问AWS上的ElasticSearch

[英]Unable to access ElasticSearch on AWS

I am trying to use curl in powershell to access elasticsearch on an AWS instance, with no luck. 我试图在Powershell中使用curl来访问AWS实例上的elasticsearch,但是没有运气。

I can access the instance using putty with no problems, and can successfully run a health check on elasticsearch using curl 'localhost:9200/_cat/health?v' . 我可以使用腻子curl 'localhost:9200/_cat/health?v'地访问该实例,并且可以使用curl 'localhost:9200/_cat/health?v'成功对curl 'localhost:9200/_cat/health?v'运行运行状况检查。 I've added a rule to the AWS security group to allow TCP requests to port 9200 from my IP, and have added the following lines to the elasticsearch.yml file: 我已将一条规则添加到AWS安全组,以允许TCP请求从我的IP向端口9200发送请求,并将以下行添加到elasticsearch.yml文件中:

http.enabled : true
http.cors.enabled : true
http.cors.allow-origin : "*"

I've checked ip tables, and it looks as though nothing is wrong there: 我检查了ip表,那里似乎没有什么不妥:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:wap-wsp flags:FIN,SYN,RST,ACK/SYN
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:wap-wsp flags:FIN,SYN,RST,ACK/SYN

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

I've tried sending a request from my windows machine using powershell, here's the request and error: 我尝试使用Powershell从Windows机器发送请求,这是请求和错误:

curl '*{awsPublicIP}*:9200/_cat/health?v'
curl : Unable to connect to the remote server
At line:1 char:1
+ curl '*{awsPublicIP}*:9200/_cat/health?v'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I've also tried this in chrome, which resulted in a "connection refused" error: 我也在chrome中尝试过此操作,这导致“连接被拒绝”错误:

http://*{AWSPublicIP}*:9200/_cat/health?v

I did create a .pem file whilst spinning up the instance for ssh connections, would I have to include it somehow? 我确实在创建.pem文件的同时旋转了ssh连接的实例,我是否必须以某种方式包含它? where am I going wrong? 我要去哪里错了?

By default, ES only listens to the loopback interface. 默认情况下,ES仅侦听回送接口。 Please read this article from ES documentation: 请阅读ES文档中的这篇文章:

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html

I had the same problem and i solved it by editing the elasticsearch.yml file. 我有同样的问题,我通过编辑elasticsearch.yml文件解决了。 Just uncomment the line with "network.host" and change it to : network.host: _eth0_ 只需取消对“ network.host”的注释,并将其更改为:network.host: _eth0_

When eth0 is your desired NIC you want to use for connections to ES. 当eth0是所需的NIC时,您要用于连接ES。

This seems to be a firewall on the OS level and not the security group. 这似乎是操作系统级别的防火墙,而不是安全组。 did you check if the firewall is turned off? 您检查防火墙是否关闭了吗? what OS are you running? 您正在运行什么操作系统? if CentOS 7, firewall is enabled by default and therefore you will have this issue. 如果CentOS 7默认情况下启用了防火墙,因此您将遇到此问题。

also, try to test on your elasticsearch.yml file by changing the host to 0.0.0.0 另外,尝试通过将主机更改为0.0.0.0来对您的elasticsearch.yml文件进行测试

if you are using CentOS systemctl stop firewalld 如果您使用的是CentOS系统systemctl stop firewalld

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM