What's the difference between bind_host and pu

2019-03-09 17:56发布

From this document network settings, I know that publish_host is the host that other nodes in the cluster will communicate to. But I don't understand the functionality of bind_host, which means that:

The network.bind_host setting allows to control the host different network components will bind on. By default, the bind host will be anyLocalAddress (typically 0.0.0.0 or ::0).

And the network.host will set network.bind_host and network.publish_host to the same value.

So I want to know why there's a need to set network.bind_host and if it's possible to set network.bind_host and network.publish_host to different values?

5条回答
相关推荐>>
2楼-- · 2019-03-09 18:36

The following setting should do the trick. It accepts connections from any IP (bind) and configures its self ip to the first non_loopback in the first available network interface.

network.bind_host: "0.0.0.0"
network.publish_host: _non_loopback:ipv4_

To see more options, check the docs.

查看更多
倾城 Initia
3楼-- · 2019-03-09 18:37

To check this value, via the API:

curl http://ES:9200/_cat/master

Pay attention that hostname will be resolved (so never exposed).

查看更多
再贱就再见
4楼-- · 2019-03-09 18:41

From what I understand, and to use a phone-calling analogy:

  • publish_host means: "Call me on this number"
  • bind_host means: "I'll answer on this number"

And publish_host: _non_loopback:ipv4_ may be understood as: "Call me on whatever number I'm calling you from"

查看更多
对你真心纯属浪费
5楼-- · 2019-03-09 18:42

It is possible to set them to different values and really useful in some cases. Here is my usage:

I have a local network in a data center where I run the elasticsearch cluster composed of different nodes. This means that every elasticsearch machine has two ip addresses, one to reach it from an external machine and the other to connect locally to other machines in the same network.

The internal ip (eth1) is used to let different nodes of elasticsearch communicate, discover, etc. each other and the external ip address (eth0) is the one which my web application, which is in another network, makes the requests to.

So in simple words, bind_host (both ip in my case, the same as default value 0.0.0.0 that attaches all interfaces) is where elasticsearch listens and publish_host (internal ip in my case) is where elasticsearch communicates with other cluster components.

This way, my web application being in another network, can access the ES cluster from the bind_host address, while elasticsearch communicates with the cluster with the publish_host.

查看更多
何必那么认真
6楼-- · 2019-03-09 18:50

The bind_host setting controls what network interface Elasticsearch listens on. So on a machine that has multiple NICs this will allow you to control which one ES will bind to. The default of 0.0.0.0 basically means "bind to all".

The publish_host setting controls what IP address Elasticsearch announces to other members. This has to be an actual IP address and is what the other cluster members will use to communicate with the ES node.

You can set bind_host and publish_host to different values if you need to do something special on a multi-homed server. Most use cases won't need to though, hence the network.host setting controlling both.

查看更多
登录 后发表回答