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?
network.publish_host. (Static, string) The network address that clients and other nodes can use to contact this node. Accepts an IP address, a hostname, or a special value.
The file-based seed hosts provider configures a list of hosts via an external file. Elasticsearch reloads this file when it changes, so that the list of seed nodes can change dynamically without needing to restart each node.
The network. host config is used to tell elasticsearch which IP in the server it will use to bind. Every service running in a server needs to bind to at least one IP, since servers can have multiple IPs, you can use 0.0. 0.0 to tell the service to bind to all the IPs available on the server.
Elasticsearch is built to be always available and to scale with your needs. It does this by being distributed by nature. You can add servers (nodes) to a cluster to increase capacity and Elasticsearch automatically distributes your data and query load across all of the available nodes.
You need to include network. host:0.0. 0.0 in your elasticsearch. yml file so that it listens on the non-loopback address and after that, if your app-server and ES are both in the same VPC, app-server will be able to connect to ES(provided if you exposed 9200 port in security group(in case of AWS).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With