【发布时间】:2018-10-25 06:52:47
【问题描述】:
我创建了一个亚马逊 ec2 实例并通过ssh 成功登录到该实例。现在我正在尝试使用 Model.reindex 重新索引来自 rails c 的模型,但出现以下错误:
Faraday::ConnectionFailed: Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)
我已将所有 tcp 端口(80,22,5432,433,9200,9300)添加到相应的安全组中。
我还使用以下信息编辑了/etc/elasticsearch/elasticsearch.yml 文件:
cluster.name: esonaws
bootstrap.mlockall: true
network.host: xxx.xx.xx.xx(this is the instance private ip)
http.port: 9200
discovery.zen.ping.unicast.hosts: xxx.xx.xx.xx(this is the instance private ip)
然后做了sudo service elasticsearch restart,elasticsearch 启动正常,但是当我再次尝试重新索引时,再次弹出相同的错误。
顺便说一句,当我在 ssh curl localhost:9200/_cluster/health?pretty 内执行此操作时,我明白了:
curl: (7) Failed to connect to localhost port 9200: Connection refused
但如果我使用亚马逊 ec2 实例的私有 ip,它可以工作并返回所有集群信息。
curl http://xxx.xx.xx.xx:9200/_cluster/health?pretty^C
有什么我可能在这里遗漏的想法以及如何让它发挥作用吗?
【问题讨论】:
标签: ruby-on-rails amazon-web-services elasticsearch searchkick