Install Elasticsearch 7.x on Ubuntu 18.04/Debian 9.8

2
6258

Today we are going to learn how to install Elasticsearch 7.x on Ubuntu 18.04/Debian 9.8. Elasticsearch is an open source, distributed, RESTful, JSON-based search and analytics engine based on the Lucene library. It is one of the major components of Elastic (ELK) stack.

Elasticsearch 7.0.0, based on Lucene 8.0.0, has just been released and is the current stable release and is already available for deployment.

Install Elasticsearch 7.x on Ubuntu 18.04/Debian 9.8

There are different methods in which you can install Elasticsearch 7.0.0 on Ubuntu 18.04 or Debian 9.8. These include the use of the tar.gz archive, the Debian package (DEB) or from the APT repository.

Install Elasticsearch 7.0.0 using APT Repository

Before you can proceed, resynchronize your system packages to the latest versions.

apt update
apt upgrade

Import the Elasticsearch PGP Key

To install Elasticsearch 7.0.0 from APT repository, you need to import the Elasticsearch Signing Key by running the command below;

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Add Elasticsearch 7.x APT repository

Next, you need to create Elasticsearch 7.x repository by executing the command below;

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

Install Elasticsearch 7.0.0 on Ubuntu 18.04/Debian 9.8

Once you have the repo in place, update your system and install Elasticsearch 7.0.0 by running the commands below. Note that Elasticsearch includes a bundled version of OpenJDK from the JDK maintainers.

apt update
apt-get install apt-transport-https
apt install elasticsearch
...
Preparing to unpack …/elasticsearch_7.0.0_amd64.deb …
Creating elasticsearch group… OK
Creating elasticsearch user… OK
Unpacking elasticsearch (7.0.0) …
Setting up elasticsearch (7.0.0) …
Created elasticsearch keystore in /etc/elasticsearch

,,,

There you go. You have successfully installed Elasticsearch 7.0.0 on Ubuntu 18.04/Debian 9.8. You can find the Elasticsearch configuration file as /etc/elasticsearch/elasticsearch.yml.

Installing Elasticsearch 7.0.0 Using the Debian Package

As stated above, another option of installing Elasticsearch 7.0.0 on Ubuntu 18.04/Debian 9.8 is by using the Debian package (DEB).

Download Elasticsearch Debian package

Run the command below to download Elasticsearch debian package.

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-amd64.deb

Once the download is done, you need to verify the integrity of the Debian package. Hence, download the checksum file.

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-amd64.deb.sha512

Run the comparison of SHA of the downloaded Debian package and the published checksum as shown below. If all is well, you should get an OK output.

shasum -a 512 -c elasticsearch-7.0.0-amd64.deb.sha512 
elasticsearch-7.0.0-amd64.deb: OK

Install Elasticsearch 7.0.0 using the Debian package

sudo apt install ./elasticsearch-7.0.0-amd64.deb

Running Elasticsearch

To configure Elasticsearch to start on system boot, run the following commands:

systemctl daemon-reload
systemctl enable elasticsearch

To start and stop Elasticsearch, run the commands below respectively:

systemctl start elasticsearch
systemctl stop elasticsearch

To check the status, run the command below;

systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-04-28 20:30:26 EAT; 14min ago
Docs: http://www.elastic.co
Main PID: 2887 (java)
Tasks: 44 (limit: 1131)
CGroup: /system.slice/elasticsearch.service
├─2887 /usr/share/elasticsearch/jdk/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiati
└─2951 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
Apr 28 20:30:26 u18server systemd[1]: Started Elasticsearch.
Apr 28 20:30:27 u18server elasticsearch[2887]: OpenJDK 64-Bit Server VM warning:

You can also check Elasticsearch log file, /var/log/elasticsearch/elasticsearch.log, for more details.

You can also use curl command to check if Elasticsearch is running. Note that Elasticsearch listens on tcp port 9200 by default.

apt install curl
curl -X GET "localhost:9200/"
{
"name" : "debian",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Z9N25gX2Sva4Xnep0EgvMw",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

Bootstrap Checks/Single-node discovery.

Elasticsearch is listening on localhost by default. If you are running Elasticsearch for testing and you need to access it from outside, you need to change the network bind address. However, for this to work, you need to configure single-node discovery.

Hence, open the configuration file and;

vim /etc/elasticsearch/elasticsearch.yml
  • configure specific Interface IP by uncommenting and changing the value of network.host and uncomment the http.port line under the Network settings section. Be sure to implement strict firewall rules for security purposes.
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 192.168.0.101
#
# Set a custom port for HTTP:
#
#http.port: 9200
http.port: 9200
#
# For more information, consult the network module documentation.
# 
  • add the line, discovery.type: single-node, under the Discovery settings section.
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
discovery.type: single-node

Restart Elasticsearch and confirm that it is listening on an interface IP.

curl -X GET "192.168.0.101:9200/"
{
  "name" : "elk.example.com",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "o-7EvWIZRA2IVTe0mkTJWw",
  "version" : {
    "number" : "7.0.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "b7e28a7",
    "build_date" : "2019-04-05T22:55:32.697037Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.7.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Well, Elasticsearch is now running. Upto that end, you have learnt how to install Elasticsearch 7.x on Ubuntu 18.04/Debian 9.8. You can also check our guide on how to install Elasticsearch 7.x on CentOS 7/Fedora 29. Enjoy.

Tou build Elastic Stack, you need to install and configure other Components such as Kibana, Logstash, Beats. See the links below;

References:

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here