The installation

Elasticsearch requires a JDK version of 1.7 or lower, especially at the time of writing, Oracle JDK version 1.8.0_72 is recommended, we won’t focus on the details of different Java versions here. Oracle recommended installation documentation is available here: Oracle’s website. Before you install ES, use the following command to check your Java environment:

java -version echo $JAVA_HOME

Once our Java environment is configured, we can download and run ES. Binary installation packages and all versions are available here at www.elastic.co/downloads, each with zip, tar, or deb and RPM packages, which are simply tar packages. Use the following command to download ES2.2.1 (For Windows users, download the zip package by yourself) :

curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.2.1/elasticsearch-2 . 2.1. Tar. Gz

Then unzip:

The tar – XVF elasticsearch – 2.2.1. Tar. Gz

A series of files and folders will be released, and we’ll go to the bin directory:

CD elasticsearch – 2.2.1 / bin

Now we can run a single node cluster (Windows user double click elasticSearch.bat) :

./elasticsearch

After successful startup, you should see the following startup log:

[2014-03-13 13:42:17.218][INFO][node][New Goblin] version[2.2.1], PID [2085] Build [5C03844/2014-02-25T15:52:53z][2014-03-13 13:42:17219][INFO][New Goblin] initializing… [2014-03-13 13:42:17,223][INFO][plugins][] Sites [] [INFO][node][New Goblin] Initialized [2014-03-13 13:42:19,832][INFO][node][New Goblin] starting … [2014-03-13 13:42:19.958][INFO][transport][New Goblin] bound_address {inet[/ 0:0:0:0:0:9300]}, Publish_address {inet[/192.168.8.112:9300]} [2014-03-13 13:42:23.030][INFO][cluster.service] [New Goblin] new_master [New Goblin] [rWMtGj3dQouz2r6ZFL9v4g] [mwubuntu1] [inet [/ 192.168.8.112:9300]], “reason: Zen-disco join (Elected_AS_master) [2014-03-13 13:42:23,100][INFO][Discovery][New Goblin] 13:42:23 elasticsearch/rWMtGj3dQouz2r6ZFL9v4g [2014-03-13, 125] [INFO] [HTTP] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, Publish_address {inet[/192.168.8.112:9200]} [2014-03-13 13:42:23.629][INFO][gateway][New Goblin] Recovered [1] Indices into Cluster_STATE [2014-03-13 13:42:23.630][INFO][Node][New Goblin] Started

By simply looking at the log information, we can tell that the node has been started, named New Goblin (marvel hero name), and has elected itself as the cluster’s master node. Don’t worry about not knowing what the master node means, just focus on us now that we started a node in a cluster.

As mentioned earlier, we can customize the cluster name and node name. We can start ES with the following command:

./elasticsearch –cluster.name my_cluster_name –node.name my_node_name

Note also that the line marked Http in the log represents the Http protocol address (192.168.8.112) and port (9200) from which we can access the cluster. ES uses port 9200 by default to provide REST API access, which can be configured if necessary

(Translator’s note: for the sake of security, it is better to customize the port. The node name is better to have meaning, such as the server IP, so that you can use some operation tools or logs to view the node information can be friendly and quick.)

Previous section: 1.1 Basic Concepts

Next section: 1.3 Exploring clusters