Understanding node and cluster
Every instance of ElasticSearch is called as node. Several nodes are grouped in a cluster. This is the base of the cloud nature of ElasticSearch.
Getting ready
To better understand the upcoming sections, some knowledge of basic concepts of application node and cluster is required.
How it works...
One or more ElasticSearch nodes can be set up on a physical or a virtual server depending on available resources such as RAM, CPUs, and disk space. A default node allows storing data in it and to process requests and responses. (In Chapter 2, Downloading and Setting Up ElasticSearch,we'll see details about how to set up different nodes and cluster topologies). When a node is started, several actions take place during its startup:
- The configuration is read from the environment variables and from the
elasticsearch.yml
configuration file - A node name is set by a
config
file or chosen from a list of built-in random names - Internally, the ElasticSearch engine initializes all the modules and plugins that are available in the current installation
After node startup, the node searches for other cluster members and checks its indices and shards status. In order to join two or more nodes in a cluster, the following rules must be matched:
- The version of ElasticSearch must be the same (0.20, 0.9, and so on) otherwise the join is rejected
- The cluster name must be the same
- The network must be configured to support multicast (default) and they can communicate with each other
Refer to the Networking setup recipe in the next chapter.
A common approach in cluster management is to have a master node, which is the main reference for all cluster level actions, and the others ones called secondary or slaves, that replicate the master data and actions. All the update actions are first committed in the master node and then replicated in secondary ones.
In a cluster with multiple nodes, if a master node dies, a secondary one is elected to be the new master; this approach allows automatic failover to be set up in an ElasticSearch cluster.
There's more...
There are two important behaviors in an ElasticSearch node, namely the arbiter and the data container.
The arbiter nodes are able to process the REST response and all the other operations of search. During every action execution, ElasticSearch generally executes actions using a MapReduce approach. The arbiter is responsible for distributing the actions to the underlying shards (map) and collecting/aggregating the shard results (redux) to be sent a final response. They may use a huge amount of RAM due to operations such as facets, collecting hits and caching (for example, scan queries).
Data nodes are able to store data in them. They contain the indices shards that store the indexed documents as Lucene indices. All the standard nodes are both arbiter and data container.
In big cluster architectures, having some nodes as simple arbiters with a lot of RAM with no data reduces the resources required by data nodes and improves performance in search using the local memory cache of arbiters.
See also
- Setting up a node and Setting up different node types (advanced) recipes in the next chapter