无法从外部访问嵌入式 elasticsearch
Embedded elasticsearch is not accessible from outside
我有 Spring 带有嵌入式 elasticsearch 的引导应用程序。我可以在 localhost:9200 上访问它,但它不响应真实 IP xx.xxx.x.xx:9200.
端口已打开,问题是它只监听本地接口。
netstat -vanp tcp | grep 9200
tcp4 0 0 127.0.0.1.9200 *.* LISTEN 131072 131072 31425 0
tcp6 0 0 ::1.9200 *.* LISTEN 131072 131072 31425 0
tcp6 0 0 fe80::1%lo0.9200 *.* LISTEN 131072 131072 31425 0
如何强制它听所有,就像我对 web 8080 一样
netstat -vanp tcp | grep 8080
tcp46 0 0 *.8080 *.* LISTEN 131072 131072 23002 0
我正在使用:
- spring-boot-starter-parent 1.4.1.RELEASE
- spring-boot-starter-data-elasticsearch 1.4.1.RELEASE
- 弹性搜索版本 2.4.0
这是我申请的一部分-dev.yml
data:
elasticsearch:
cluster-name:
cluster-nodes:
properties:
path:
logs: target/elasticsearch/log
data: target/elasticsearch/data
http:
enabled: true
谢谢
您需要将您的嵌入式 Elasticsearch 绑定到所有主机 ip(或至少绑定到机器的真实 ip),在我看来您绑定到 localhost,因此您在配置 elasticsearch 时需要此条目:
Settings.Builder nodeSettings = nodeBuilder().settings();
...
nodeSettings.put("network.host", "0.0.0.0");
这会将您的 elasticsearch 绑定到您的主机 ip 地址。
我有 Spring 带有嵌入式 elasticsearch 的引导应用程序。我可以在 localhost:9200 上访问它,但它不响应真实 IP xx.xxx.x.xx:9200.
端口已打开,问题是它只监听本地接口。
netstat -vanp tcp | grep 9200
tcp4 0 0 127.0.0.1.9200 *.* LISTEN 131072 131072 31425 0
tcp6 0 0 ::1.9200 *.* LISTEN 131072 131072 31425 0
tcp6 0 0 fe80::1%lo0.9200 *.* LISTEN 131072 131072 31425 0
如何强制它听所有,就像我对 web 8080 一样
netstat -vanp tcp | grep 8080
tcp46 0 0 *.8080 *.* LISTEN 131072 131072 23002 0
我正在使用:
- spring-boot-starter-parent 1.4.1.RELEASE
- spring-boot-starter-data-elasticsearch 1.4.1.RELEASE
- 弹性搜索版本 2.4.0
这是我申请的一部分-dev.yml
data:
elasticsearch:
cluster-name:
cluster-nodes:
properties:
path:
logs: target/elasticsearch/log
data: target/elasticsearch/data
http:
enabled: true
谢谢
您需要将您的嵌入式 Elasticsearch 绑定到所有主机 ip(或至少绑定到机器的真实 ip),在我看来您绑定到 localhost,因此您在配置 elasticsearch 时需要此条目:
Settings.Builder nodeSettings = nodeBuilder().settings();
...
nodeSettings.put("network.host", "0.0.0.0");
这会将您的 elasticsearch 绑定到您的主机 ip 地址。