How to Install Elasticsearch on CentOS 7 / Ubuntu 14.10 / Linux Mint 17.1

Elasticsearch is an enterprise level open source search server based on Apache Lucene, it offers a real-time distributed search and analytics with a RESTful web interface and schema-free JSON documents. Elasticsearech is developed in Java and is released under the Apache License, currently it is ranked second in most popular enterprise search engine, behind Apace Solr.

This guide will help you to install Elasticsearch on CentOS 7 / Ubuntu 14.10 / Linux Mint 17.1.

Prerequisites:
As said earlier, Elasticsearch is developed in Java. Make sure you have the latest JDK 8 installed on your system.

Install Elasticsearch:

Elasticsearch can be downloaded directly from the official website, more than that, it offers a pre-built binary packages for RHEL and Debian derivatives.

Download and install public signing key.

### Ubuntu 14.10 & Linux Mint 17.1 ###

$ wget -qO – https://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add –

### RHEL 7 / CentOS 7 ###

# rpm –import https://packages.elasticsearch.org/GPG-KEY-elasticsearch

 

Add and enable Elasticsearch repository

### Ubuntu 14.10 & Linux Mint 17.1 ###

$ sudo add-apt-repository “deb http://packages.elasticsearch.org/elasticsearch/1.4/debian stable main”

### RHEL 7 / CentOS 7 ###

# cat <> /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-1.4]
name=Elasticsearch repository for 1.4.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.4/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1
EOF

 

Install Elasticsearch by using following command.

### Ubuntu 14.10 & Linux Mint 17.1 ###

$ sudo apt-get update && sudo apt-get install elasticsearch

### RHEL 7 / CentOS 7 ###

# yum -y install elasticsearch

 

Configure Elasticsearch to auto-start during system startup.

### Ubuntu 14.10 & Linux Mint 17.1 ###

$ sudo update-rc.d elasticsearch defaults 95 10

### RHEL 7 / CentOS 7 ###

# /bin/systemctl daemon-reload
# /bin/systemctl enable elasticsearch.service
# /bin/systemctl start elasticsearch.service


Configuring Elasticsearch:

Elasticsearch configuration files can be found in /etc/elasticsearch/ directory, you could see only two files in it, elasticsearch.yml and logging.yml. logging.yml manages the logging of elasticsearch, logs files are stored in /var/log/elasticsearch directory.

elasticsearch.yml is the main configuration file of elasticsearch, contains default settings for running production cluster.

Elasticsearch, by default, binds to all network cards (0.0.0.0), and listens on port no 9200 – 9300 for HTTP traffic and on 9300 – 9400 for internal node to node communication, ranges means that if the port is busy, it will automatically try the next port.

Edit elasticsearch.yml file.

# vi /etc/elasticsearch/elasticsearch.yml

 

In order to make Elasticsearch to listen on particular ip, place the ip address on following syntax. To protect elasticsearch from public access, you can set it to listen on localhost.

### Listening on particular IPv4 ###

network.bind_host: 192.168.0.1

### Disabling public access ###

network.bind_host: 127.0.0.1

 

Restart the Elasticsearch service.

# service elasticsearch restart

 

Once you restarted, wait for at least a minute to let the Elasticsearch get fully started, otherwise testing will fail. Elastisearch should be now listen on 9200 for processing HTTP request, we will use CURL to get the response.

# curl -X GET ‘http://localhost:9200’

 

You should get the response like below.

{
“status” : 200,
“name” : “Toad-In-Waiting”,
“cluster_name” : “elasticsearch”,
“version” : {
“number” : “1.4.4”,
“build_hash” : “c88f77ffc81301dfa9dfd81ca2232f09588bd512”,
“build_timestamp” : “2015-02-19T13:05:36Z”,
“build_snapshot” : false,
“lucene_version” : “4.10.3”
},
“tagline” : “You Know, for Search”
}

 

Alternatively, you can use browser to query the Elasticsearch by visiting :9200. You should see the same as you saw using curl.

Elasticsearch cluster:

Cluster Name:
The setting cluster.name is used to discover and auto-join other nodes, If a group of Elasticsearch servers on the same network have the same cluster name, they will discover each others. Make sure you change the default cluster name of Elasticsearch server, to avoid auto-joining of other servers on the same network that are not under your control.

If you are running multiple Elasticsearch clusters on the same network, make sure you are using unique cluster names.

cluster.name:


Node Name:
This is like a host name for Elasticsearch server, node name is dynamically generated during the service startup. You can set it your own name by setting the following syntax.

node.name: “”

 

Do not forget to restart the Elasticsearch service.

# service elasticsearch restart

 

Links:
Elasticsearch = elastisearch.org
SetupGuide = Guide
credits: itzgeek.com

Leave a Comment

Your email address will not be published. Required fields are marked *