Correctly setting up a networking is very important for your node and cluster.
As there are a lot of different install scenarios and networking issues in this recipe we will cover two kinds of networking setups:
You need a working ElasticSearch installation and to know your current networking configuration (that is, IP).
For configuring networking, we will perform the steps as follows:
Using the standard ElasticSearch configuration file (config
/elasticsearch.yml
), your node is configured to bind on all your machine interfaces and does autodiscovery broadcasting events, that means it sends "signals" to every machine in the current LAN and waits for a response. If a node responds to it, they can join in a cluster.
If another node is available in the same LAN, they join in the cluster.
elasticsearch.yml
file, such as:cluster.name: elasticsearch node.name: "My wonderful server" network.host: 192.168.0.1 discovery.zen.ping.unicast.hosts: ["192.168.0.2","192.168.0.3[9300-9400]"]
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
This configuration sets the cluster name to elasticsearch
, the node name, the network address, and it tries to bind the node to the address given in the discovery section.
We can now start the server and check if the network is configured:
[INFO ][node ] [Aparo] version[0.90.3], pid[16792], build[5c38d60/2013-08-06T13:18:31Z] [INFO ][node ] [Aparo] initializing ... [INFO ][plugins ] [Aparo] loaded [transport-thrift, river-twitter, mapper-attachments, lang-python, jdbc-river, lang-javascript], sites [bigdesk, head] [INFO ][node ] [Aparo] initialized [INFO ][node ] [Aparo] starting ... [INFO ][transport ] [Aparo] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.1.5:9300]} [INFO ][cluster.service] [Aparo] new_master [Angela Cairn][yJcbdaPTSgS7ATQszgpSow][inet[/192.168.1.5:9300]], reason: zen-disco-join (elected_as_master) [INFO ][discovery ] [Aparo] elasticsearch/yJcbdaPTSgS7ATQszgpSow [INFO ][http ] [Aparo] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.1.5:9200]} [INFO ][node ] [Aparo] started
In this case, we have:
It works as follows:
cluster.name
: This sets up the name of the cluster (only nodes with the same name can join).node.name
: If this is not defined, it is automatically generated by ElasticSearch. It allows defining a name for the node. If you have a lot of nodes on different machines, it is useful to set this name meaningful to easily locate it. Using a valid name is easier to remember than a generated name, such as whqVp_4zQGCgMvJ1CXhcWQ
.network.host
: This defines the IP of your machine to be used in binding the node. If your server is on different LANs or you want to limit the bind on only a LAN, you must set this value with your server IP.discovery.zen.ping.unicast.hosts
: This allows you to define a list of hosts (with ports or port range) to be used to discover other nodes to join the cluster. This setting allows using the node in LAN where broadcasting is not allowed or autodiscovery is not working (that is, packet filtering routers). The referred port is the transport one, usually 9300. The addresses of the hosts list can be a mix of:18.216.188.62