Lorem ipsum dolor sit amet, conse ctetur adip elit, pellentesque turpis.

  • No products in the cart.

Image Alt

An Introduction to ElasticSearch and its Installation on Centos7

An Introduction to ElasticSearch and its Installation on Centos7

In this blog, you will learn about :

  • What is ElasticSearch ?
  • Why use ElasticSearch?
  • Basic Terminologies
  • Installation of ElasticSearch on Centos 7

What is ElasticSearch?

ElasticSearch is an open source,distributed search and analytics engine developed in Java.It was first released in 2010 by ElasticSearch-Shay Banon and is based on Apache Lucene.It is Commonly referred to as the ELK Stack (after ElasticSearch, Logstash, and Kibana).

 

Why use ElasticSearch?

  • Search all types of data-Textual,Numerical,Geospatial,Structured and Unstructured.
  • Possible to analyse billions of records in a few seconds.
  • It is open source and distributed by nature.
  • Fast performance.
  • ElasticSearch uses JSON document format.It is simple,concise and easy to learn.

 

Basic Terminologies

Node :  A node is a running instance of ElasticSearch which belongs to a cluster.

Cluster : Cluster consists of one or more nodes that holds together the entire data.Each cluster has a single Master node which is chosen automatically.

Index : An index is a collection of documents that have similar characteristics and is identified by name.This name is used to refer to the index while performing indexing,search,update and delete operations.

Type : Type  is a logical category/partition of index and It is defined for documents that have a set of common fields.

Document : Document is like a ‘row’ (record)  in a table in a relational database. It is a JSON format document which is stored in ElasticSearch. Each document is stored in an index and has a type and an id.A document is a JSON object which contains zero or more fields, or key-value pairs.

Shard : A shard is a single Lucene(index) instance.It is a low-level “worker” unit. ElasticSearch distributes shards amongst all nodes in the cluster automatically.An Index points to primary and replica shards.Each document is stored in single primary shard.When index a document, it is indexed first on the primary shard, then on all replicas.By default, an index has one primary shard. 

Replica : Replica is a copy of primary shard.It is also called replica shard.Replica shard get promoted to a primary shard if primary fails.

 


Configuring Oracle Java


Java is the primary requirement for installing Elasticsearch on any system.You can check the installed version of Java by executing the following command.

$ java -version

Note: If Java is not installed so execute below steps:

Install OpenJDK 8 JDK.

To install OpenJDK 8 JDK using yum, run this command:

$ sudo yum install java-1.8.0-openjdk-devel -y

At the confirmation prompt, enter y then RETURN to continue with the installation.

Now re-check the Java version.

$ java -version

Installing ElasticSearch


ElasticSearch can be downloaded directly from elastic.co in zip, tar.gz, deb, or rpm packages. For CentOS, it’s best to use the native rpm package which will install everything you need to run ElasticSearch :

    $ wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.3.noarch.rpm

Then install it in the usual CentOS way with the rpm command like this:

$ sudo rpm -ivh elasticsearch-1.7.3.noarch.rpm

Once the installation process is complete, start and enable the service by running:

    $ sudo systemctl start elasticsearch.service

ElasticSearch has been successfully installed and running on your CentOS or RHEL system.

This results in Elasticsearch being installed in /usr/share/elasticsearch/ with its configuration files placed in /etc/elasticsearch and its init script added in /etc/init.d/elasticsearch

To make sure ElasticSearch starts and stops automatically with the Droplet, add its init script to the default run levels with the command:

     $ sudo systemctl enable elasticsearch.service

After successful installation edit Elasticsearch configuration file “/etc/elasticsearch/elasticsearch.yml” and set the network.host to localhost. 

     $ sudo vi /etc/elasticsearch/elasticsearch.yml

network.host: localhost
Restart the Elasticsearch service for the changes to take effect:

    $ sudo systemctl restart elasticsearch

You can verify that Elasticsearch is running by sending an HTTP request to port 9200 on localhost with the following

Run the following command to verify service:

    $ curl -X GET "localhost:9200/?pretty"


Starting a single node cluster

single-node discovery : For development or testing, we can configure a standalone ElasticSearch cluster by setting discovery.type to single-node; in this case, a node will elect itself master and will not join a cluster with any other node.

Specifies whether ElasticSearch should form a multiple-node cluster. By default, ElasticSearch discovers other nodes when forming a cluster and allows other nodes to join the cluster later. If discovery.type is set to single-node, ElasticSearch forms a single-node cluster. 

Port – 9200 is for REST

Port – 9300 for nodes Communication

    $ docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.5.2

Note: Container Name must not be the same

Check Cluster Information

    $ docker ps


Conclusion 

Elasticsearch has quickly become the most popular search engine, and is commonly used for log analytics, full-text search, security intelligence, business analytics, and operational intelligence use cases.Hopefully this blog has given a better understanding of what ElasticSearch is and how to install ElasticSearch on Centos 7 having single node cluster.

Post a Comment