How to install Elasticsearch and Kibana on Linux

Get our simplified instructions for installing both.
126 readers like this.
How to upgrade your Fedora Linux system with DNF

Opensource.com

If you're keen to learn Elasticsearch, the famous open source search engine based on the open source Lucene library, then there's no better way than to install it locally. The process is outlined in detail on the Elasticsearch website, but the official instructions have a lot more detail than necessary if you're a beginner. This article takes a simplified approach.

Add the Elasticsearch repository

First, add the Elasticsearch software repository to your system, so you can install it and receive updates as needed. How you do so depends on your distribution. On an RPM-based system, such as Fedora, CentOS, Red Hat Enterprise Linux (RHEL), or openSUSE, (anywhere in this article that references Fedora or RHEL applies to CentOS and openSUSE as well) create a repository description file in /etc/yum.repos.d/ called elasticsearch.repo:

$ cat << EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

On Ubuntu or Debian, do not use the add-apt-repository utility. It causes errors due to a mismatch in its defaults and what Elasticsearch’s repository provides. Instead, set up this one:

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

Before you can install from that repository, import its GPG key, and then update:

$ sudo apt-key adv --keyserver \
hkp://keyserver.ubuntu.com:80 \
--recv D27D666CD88E42B4
$ sudo apt update

This repository contains only Elasticsearch’s open source features, under an Apache License, with none of the extra features provided by a subscription. If you need subscription-only features (these features are not open source), the baseurl must be set to:

baseurl=https://artifacts.elastic.co/packages/7.x/yum

 

Install Elasticsearch

The name of the package you need to install depends on whether you use the open source version or the subscription version. This article uses the open source version, which appends -oss to the end of the package name. Without -oss appended to the package name, you are requesting the subscription-only version.

If you create a repository pointing to the subscription version but try to install the open source version, you will get a fairly non-specific error in return. If you create a repository for the open source version and fail to append -oss to the package name, you will also get an error.

Install Elasticsearch with your package manager. For instance, on Fedora, CentOS, or RHEL, run the following:

$ sudo dnf install elasticsearch-oss

On Ubuntu or Debian, run:

$ sudo apt install elasticsearch-oss

If you get errors while installing Elasticsearch, then you may be attempting to install the wrong package. If your intention is to use the open source package, as this article does, then make sure you are using the correct apt repository or baseurl in your Yum configuration.

Start and enable Elasticsearch

Once Elasticsearch has been installed, you must start and enable it:

$ sudo systemctl daemon-reload
$ sudo systemctl enable --now elasticsearch.service

Then, to confirm that Elasticsearch is running on its default port of 9200, point a web browser to localhost:9200. You can use a GUI browser or you can do it in the terminal:

$ curl localhost:9200
{

  "name" : "fedora30",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "OqSbb16NQB2M0ysynnX1hA",
  "version" : {
    "number" : "7.2.0",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_hash" : "508c38a",
    "build_date" : "2019-06-20T15:54:18.811730Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Install Kibana

Kibana is a graphical interface for Elasticsearch data visualization. It’s included in the Elasticsearch repository, so you can install it with your package manager. Just as with Elasticsearch itself, you must append -oss to the end of the package name if you are using the open source version of Elasticsearch, and not the subscription version (the two installations need to match):

$ sudo dnf install kibana-oss

On Ubuntu or Debian:

$ sudo apt install kibana-oss

Kibana runs on port 5601, so launch a graphical web browser and navigate to localhost:5601 to start using the Kibana interface, which is shown below:

Kibana running in Firefox.

Troubleshoot

If you get errors while installing Elasticsearch, try installing a Java environment manually. On Fedora, CentOS, and RHEL:

$ sudo dnf install java-openjdk-devel java-openjdk

On Ubuntu:

$ sudo apt install default-jdk

If all else fails, try installing the Elasticsearch RPM directly from the Elasticsearch servers:

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.2.0-x86_64.rpm{,.sha512}
$ shasum -a 512 -c elasticsearch-oss-7.2.0-x86_64.rpm.sha512 && sudo rpm --install elasticsearch-oss-7.2.0-x86_64.rpm

On Ubuntu or Debian, use the DEB package instead.

If you cannot access either Elasticsearch or Kibana with a web browser, then your firewall may be blocking those ports. You can allow traffic on those ports by adjusting your firewall settings. For instance, if you are running firewalld (the default on Fedora and RHEL, and installable on Debian and Ubuntu), then you can use firewall-cmd:

$ sudo firewall-cmd --add-port=9200/tcp --permanent
$ sudo firewall-cmd --add-port=5601/tcp --permanent
$ sudo firewall-cmd --reload

You’re now set up and can follow along with our upcoming installation articles for Elasticsearch and Kibana.

What to read next
Tags
Seth Kenlon
Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time.

7 Comments

Thanks for the links. Not all of them worked for me on Pop_OS which is weird because it is Ubuntu/Debian at its core. I did however get Elasticsearch and Kibana installed. How do you use it?

Funny you should ask! Lauren Maffeo is going to be publishing at least one or two articles about using Elasticsearch and Kibana, so stay tuned.

In reply to by Don Watkins

thanks for the Information

following the instructions for Ubuntu systems, I faced the classic NO_PUBKEY D27D666CD88E42B4 error.

It can be fixed with "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv D27D666CD88E42B4"

That's a great tip, thanks Paolo. I didn't experience that in my tests (and I did try this in an Ubuntu VM in order to get the commands right) but it could be that in my fumbling around to get the right repos defined, I solved the problem before I could see the error.

Thanks for the addition. If you tell me at what step you experienced this error exactly (cite a quote from the article after which I should place this fix, or else send me a patch file using the markdown source found here: https://gitlab.com/osdc/seth/blob/master/elasticsearch/elasticsearch.md ), I'll happily add your fix to the article so that it doesn't just exist in the comments.

In reply to by paolomascellani

Hi Seth,

sure: after "On Ubuntu or Debian, do not use the add-apt-repository utility. It causes errors due to a mismatch in its defaults and what Elasticsearch’s repository provides. Instead, set up this one:" you give the correct command in order to setup the Debian/Ubuntu repository:

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

However, in order to install the packets from the repository it is necessary to obtain the key from a keyserver:

> sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv D27D666CD88E42B4

Moreover, it is necessary to update the packets lists:

> sudo apt update

Ciao, Paolo.

In reply to by sethkenlon

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.