[Elasticsearch] Instructions to install Elasticsearch 6.5.4 on Ubuntu 16.04

Tram Ho

Prerequisites

Install JRE / JDK

First, update the packages again

Next, we will go to Java installation – Runtime Environment (JRE)

You can install JDK with the following command:

Environment variable setting JAVA_HOME

Many Java server programs use the JAVA_HOME environment variable to locate Java settings. To install this environment variable, we will first need to find out where Java is installed.

You can check by executing the following command:

And the result returns: (note the path in bold)

There is only one alternative in link group java (providing / usr / bin / java): / usr / lib / jvm / java-8-openjdk-amd64 / jre / bin / java

Once you have a java path, copy this path to the following file:

And add the following /etc/environment to the end of the file:

Save and reload:

You can now check the newly added environment variable with the following command:

Download and install Elasticsearch

Log in as root

This step will perform the download Elasticsearch. Here I installed with version 6.5.4

To configure Elasticseach parameters you can find and edit the file /etc/elasticsearch/elasticsearch.yml

After restarting you can use curl to test whether elasticsearch works or not

Increase RAM for Elasticsearch

After you have a large amount of data for your index. And running tests with a large number of requests (search or index) every day you will probably face the following errors that cause ES to stop running, even causing other services in the same server to be delayed and unable to run.

Expression:

When viewing the elasticsearch log. You will get one (or all) of the following error messages:

– rejected execution (queue capacity 1000)

– failed to reduce search

– java.lang.OutOfMemoryError: Java heap space

Reason:

ES needs more RAM than you are using for it. You need to increase RAM for ES (increase ES_HEAP_SIZE)

First, navigate to the file /etc/elasticsearch/jvm.options and edit:

Find the following 2 properties. Default ES to ESHEAPSIZE = 1G

And replace into

Here I only take the example is 6GB, depending on the data as well as the number of requests to increase or decrease accordingly.

And finally restart the service

Share the news now

Source : Viblo