Install Elasticsearch 2.1 on CentOS 6

This article will cover install Elasticsearch 2.x version on CentOS 6. Also guideline to change to Default Cluster and Index settings in Elasticsearch 2.x. So Let’s start with prerequisites

Prerequisites:

Elasticsearch needed at least Java 7.

Install Elasticsearch 2.x On CentOS 6 using Elasticsearch Repository

Install Public Signing Key:

rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

Create new repo in your /etc/yum.repos.d/ directory. For example I have created elasticsearch.repo here.

/etc/yum.repos.d/elasticsearch.repo

[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=http://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

Now Elasticsearch 2.x will avilable for installation using yum

yum install elasticsearch

Note: The repositories do not work with older rpm based distributions that still use RPM v3, like CentOS5.

chkconfig --add elasticsearch

Otherwise if your distribution is using systemd:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service

Now we have done with Elasticsearch installation. You can check your default Elasticsearch configuration in /etc/elasticsearch/elasticsearch.yml

By default its cluster name will be elasticsearch.

Now we will change Cluster, Index and Host info in elasticsearch.yml

To illustrate here I am naming my Elasticsearch cluster name “Techieroop” and node name “techieroop-es-node“. Add your host into “discovery.zen.ping.unicast.hosts“.

Summary of important Elasticsearch Configuration:

cluster.name: TechieRoop
node.name: techieroop-es-node
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

Your elasticsearch.yml will be look like this

# =========== Elasticsearch Configuration ==============
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ----------------- Cluster ---------------
#
# Use a descriptive name for your cluster:
#
 cluster.name: TechieRoop
#
#------------------- Node ----------------
#
# Use a descriptive name for the node:
#
 node.name: techieroop-es-node
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------- Paths ----------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /path/to/data
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ------------------ Memory -----------------
#
# Lock the memory on startup:
#
# bootstrap.mlockall: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ----------------- Network ----------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# ---------------- Gateway -------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# --------------- Discovery -----------------
#
# Elasticsearch nodes will find each other via unicast, by default.
#
# Pass an initial list of hosts to perform discovery when new node is started:
#  The default list of hosts is ["127.0.0.1", "[::1]"]
#
 discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# --------------- Various -----------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true

Start the Elasticsearch:

sudo service elasticsearch start

Verify you installation :

curl -XGET 'localhost:9200'

Output:

{
      "name" : "techieroop-es-node",
      "cluster_name" : "Techieroop",
      "version" : {
        "number" : "2.1.1",
        "build_hash" : "40e2c53a6b6c2972b3d13846e450e66f4375bd71",
        "build_timestamp" : "2015-12-15T13:05:55Z",
        "build_snapshot" : false,
        "lucene_version" : "5.3.1"
      },
      "tagline" : "You Know, for Search"
    }
TypeLocationDescription
home/usr/share/elasticsearchHome of elasticsearch installation
bin/usr/share/elasticsearch/binBinary scripts including elasticsearch to start a node.
conf/etc/elasticsearchConfiguration files elasticsearch.yml and logging.yml.
conf/etc/sysconfig/elasticsearchEnvironment variables including heap size, file descriptors.
data/var/lib/elasticsearchDefault path to store elasticsearch data .
logs/var/log/elasticsearchDefault log location.
plugins/usr/share/elasticsearch/pluginsPlugin directory, all plugin installed in separate directory here.
script/etc/elasticsearch/scriptsDefault script files location.
(Visited 424 times, 4 visits today)