What Is Elasticsearch & Installation Steps In RHEL 7

In this tutorial, you will learn what Elasticsearch is and the component of the elastic stack. You will also learn how to install Elasticsearch 6.x and 7.x on a Red Hat Enterprise Linux 7 and CentOS 7

UNDERSTANDING THE SUBJECT MATTER

What Is Elasticsearch?

Elasticsearch is an open-source, real-time search and analytical engine, a very powerful and popularly used enterprise-grade search engine.

Elasticsearch can be related to a database. Yes, because it holds data and for information to be searched, the data or database needs to be queried. But again, elasticsearch and the likes of MongoDb and cassandra is a NoSQL database, i.e, a no relational database management system, unlike the relational database management system(RDBMS), which are the likes of Oracle, MySQL, MSQL, etc, when a huge volume of database is queried, it is relatively slow and therefore there is a lag in retrieving information because data is in different tables, columns, and rows.

On the contrary, for elastic search, data is indexed, i.e, data is collected with related information and in close proximity, so that when a database is queried (elasticsearch queries), the information is gotten very fast, in milliseconds.

As Ash Powell has said, the systems management engineer of Elasticsearch, Elasticsearch is like running an in house google.

Elasticsearch is built on Apache Luscene engine which is of course written in Java. Hence why one will need to install java on the operating system before installing elasticsearch.


How Does Elasticsearch Work?

In RDMS, data is stored in rows and has fields such as columns, but in Elasticsearch, data is stored in the form of document as JSON objects and indexed.

In a document, there are fields and adding fields to elastic search is a very simple task, a JSON object that describes the field is sent to elastic search and easily automated and queried with the help of RESTful API.

A query can be structured as one desires because one has the free will to create an index pattern as one wishes.


Uses Of Elasticsearch

some of the uses of elastic search are

  • Used for easy search

Elastic search is used to search a huge database easily, even as enterprise tool, up to petabyte and information is retrieved in real time. Like the RDMS where you will need to write some sort of SQL statement to retrieve information, in elastic search, such is not needed.

For example, On Jumia or Alli-express site, if you are looking for a particular set of wristwatches, it can be searched on the site with the search button, you can even go as far as to narrow your search down to Casio wristwatches. This is an example of what elasticsearch can be used for.

Similarly on this blog site, from the search button just at the top right corner, one can search for a specific article topic, and the results will be displayed. This is a perfect use case of elastic search.

  • Used for auto-completion and typo correction.

Elasticsearch can be used for auto-completion and typo correction just as it is used on google. It matches highlights. Whenever one searches for a particular word, suggestions may be be given which can serve as a form of auto-completion. More so, unlike SQL database, using the SQL commands will only give an output of what is being queried for, there is no good form of auto-completion as it is in Elasticsearch.

Elastic search does not support text search only, it also supports numbers. All the various forms of searches can be combined together regardless of the data structure or type.

  • Used for Data Analytics

Elastic search can be used for data analysis. i.e, to analyze data which includes application logs and system metrics. if there is a lot of logs that are needed to be analyzed or streamlined by a specific data, for example, application memory usage, application CPU usage, application errors, etc, elasticsearch is one of the best tools that can be used for this purpose.

Elasticsearch is a very good tool that can be used for data analytics, a decision making tool if the potential is fully maximized. Though, elasticsearch is easily set up and used but maximizing its full potentials will require a complex configuration, however, will be enjoyable afterward.

There are other tools that can be used with elasticsearch for easy analysis and log management. They are logstash[link] and kibana[link]. The Combination of these tools is called elastic stack (ELK).

Where E represents elasticsearch,

L represents logstash and

K represents Kibana.

Not to gout of the scope of study, we won’t delve into these other tools in this article but we will treat them in another article on this site.

what is elasticsearch

Advantages Of Elasticsearch

Some of the advantages of Elasticsearch are

  • Scalability

From the word elastic, elasticsearch is scalable. Data can be distributed across different nodes, up to thousands of node and this is done seamlessly.

  • Performance

With data being indexed without index type or any form of a schema, querying and retrieving information from a database is done in milliseconds without the use of any special function.

Concurrent searches can also be handled in real-time.

  • Cost-free

Elasticsearch is open-source, so it can be used for free.

  • Diverse Programming Languages Support.

Elasticsearch supports different programming languages and they are

PHP, .Net(c#), Java, java script(Node.js), Perl, ruby, Go, Python.

  • Diverse Languages Support

Elastic search supports different text languages and provides an analyzer for each of them. Languages that elastic search supports are

Arabic, Armenian, Basque, Bengali, Brazilian, Bulgarian, Catalan, Cjk, Czech, Danish, Dutch, English, Estonian, Finnish, French, Galician, German, Greek, Hindi, Hungarian, Indonesian, Irish, Italian, Latvian, Lithuanian, Norwegian, Persian, Portuguese, Romanian, Russian, Sorani, Spanish, Swedish, Turkish, Thai.


Where Has Elasticsearch Been Used

Examples of company’s that uses elastic search are Netflix, Facebook, Quora, Adobe, etc.

Having understood what elasticsearch is, let us proceed to the installation steps on a Red Hat Enterprise Linux 7 system in the “ACTION TIME” section.

ACTION TIME

How To Install Elasticsearch 7.x / 6.x On RHEL 7 / CentOS 7

1 Install Java 8 version, OpenJDK 8

[root@HQPRD2 ~]# yum install java-1.8.0-openjdk-devel

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
rhel-7-server-extras-rpms                                | 3.4 kB     00:00
rhel-7-server-optional-rpms                              | 3.2 kB     00:00
rhel-7-server-rpms                                       | 3.5 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.242.b08-0.el7_7 will be ins                                                                                        talled
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.242.b08-0.el7_7                                                                                         for package: 1:java-1.8.0-openjdk-devel-1.8.0.242.b08-0.el7_7.x86_64
--> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk                                                                                        -devel-1.8.0.242.b08-0.el7_7.x86_64
--> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-                                                                                        devel-1.8.0.242.b08-0.el7_7.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.242.b08-0.el7_7 will be installed
--> Processing Dependency: gtk2(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.                                                                                        242.b08-0.el7_7.x86_64
--> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjd                                                                                        k-1.8.0.242.b08-0.el7_7.x86_64
--> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-1.8.0-openjd                                                                                        k-1.8.0.242.b08-0.el7_7.x86_64
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.242.b08-0.el7_7 will be                                                                                         installed
--> Processing Dependency: copy-jdk-configs >= 3.3 for package: 1:java-1.8.0-ope                                                                                        njdk-headless-1.8.0.242.b08-0.el7_7.x86_64
--> Processing Dependency: tzdata-java >= 2015d for package: 1:java-1.8.0-openjd                                                                                        k-headless-1.8.0.242.b08-0.el7_7.x86_64
--> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-head                                                                                        less-1.8.0.242.b08-0.el7_7.x86_64
--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjd                                                                                        k-headless-1.8.0.242.b08-0.el7_7.x86_64

2. verify the Java version installed.

[root@HQPRD2 ~]# java -version

openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
[root@HQPRD2 ~]#

3. Setup Elasticsearch repository

  • import elastic search pupblic GPG key to the rpm package manager
[root@HQPRD2 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
  • To Install elastic search 7.x, add below repository file for elastic search
[root@HQPRD2 ~]# vi /etc/yum.repos.d/elasticsearch.repo

[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
  • To Install elastic search 6.x, add below repository file for elastic search,
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

4. Install Elasticsearch

[root@HQPRD2 ~]# yum install elasticsearch

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
elasticsearch-7.x                                        | 1.3 kB     00:00
epel/x86_64/metalink                                     |  37 kB     00:00
mysql-connectors-community                               | 2.5 kB     00:00
mysql-tools-community                                    | 2.5 kB     00:00
mysql80-community                                        | 2.5 kB     00:00
nginx                                                    | 2.9 kB     00:00
remi-safe                                                | 3.0 kB     00:00
elasticsearch-7.x/primary                                  | 101 kB   00:06
elasticsearch-7.x                                                       279/279
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.x86_64 0:7.6.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch         Version         Repository               Size
================================================================================
Installing:
 elasticsearch       x86_64       7.6.0-1         elasticsearch-7.x       283 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 283 M

5. Verify the status of the service

[root@HQPRD2 ~]# systemctl status elasticsearch

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://www.elastic.co
[root@HQPRD2 ~]#

6. start elastic search service and verify again

[root@HQPRD2 ~]# systemctl status elasticsearch.service

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-02-20 08:00:49 PST; 15s ago
     Docs: http://www.elastic.co
 Main PID: 12618 (java)
   CGroup: /system.slice/elasticsearch.service
           ├─12618 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress....
           └─12702 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-...

Feb 20 07:59:39 HQPRD2 systemd[1]: Starting Elasticsearch...
Feb 20 07:59:41 HQPRD2 elasticsearch[12618]: OpenJDK 64-Bit Server VM warnin....
Feb 20 08:00:49 HQPRD2 systemd[1]: Started Elasticsearch.
Hint: Some lines were ellipsized, use -l to show in full.
[root@HQPRD2 ~]#

If you wish to enable the service, use the command,

[root@HQPRD2 ~]# systemctl status elasticsearch.service

7. verify the current elasticsearch status

[root@HQPRD2 ~]# curl -X GET "localhost:9200/"

{
  "name" : "HQPRD2",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "tJHFQFdfRWSqEyUQMz71pA",
  "version" : {
    "number" : "7.6.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
    "build_date" : "2020-02-06T00:09:00.449973Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

The configuration we have done is okay provided the client that will be accessing the elastic search server is also within the local host, but if clients will be connected remotely to the elastic search server, you will still need to do quiet few configurations like

8. Add port 9200 to the firewall rule

[root@HQPRD2 ~]# firewall-cmd --add-port=9200/tcp --permanent

success
[root@HQPRD2 ~]# firewall-cmd --reload

success

9. Add the remote IP’s that will be connecting to the server to the firewall rule as well.

firewall-cmd --add-source=<IP> --permanent

for example,

[root@HQPRD2 ~]# firewall-cmd --add-source=10.10.10.23/32 --permanent

success
[root@HQPRD2 ~]# firewall-cmd --reload

success

Tutorial Video On How To Install Elasticsearch 6.x and 7.x On RHEL

Be the first to comment

Leave a Reply

Your email address will not be published.


*