Elasticsearch is a product by Elasticsearch BV. It is available on Github and the company also hosts Elasticsearch's apt repository for Ubuntu.

It is developed using Java thus you'll also need to install Java Runtime Environment alongside the Elasticsearch binary.

Step-by-step video guide:

Steps to install Elasticsearch on Ubuntu:

  1. Add Elasticsearch repository to apt.
    1. Add GPG key of Elasticsearch's repository via apt-key.
      $ wget --quiet --output-document=- https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
      [sudo] password for user:
    2. Add Elasticsearch's repository to apt's repository list.
      $ echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
      deb https://artifacts.elastic.co/packages/6.x/apt stable main
  2. Update list of available packages from the newly added repository.
    $ sudo apt update
  3. Install latest Java Runtime Environment.
    $ sudo apt install --assume-yes default-jre
  4. Install Elasticsearch package.
    $ sudo apt install --assume-yes elasticsearch
  5. Enable access to port 9200 and 9300 from the local firewall.
    $ sudo ufw allow 9200
    Rules updated
    Rules updated (v6)
    $ sudo ufw allow 9300
    Rules updated
    Rules updated (v6)

  6. Configure Elasticsearch options located in /etc/elasticsearch/elasticsearch.yml.
    1. Allow connection from remote host.
  7. Configure Elasticsearch to automatically start during boot.
    $ sudo systemctl enable elasticsearch
    Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install.
    Executing: /lib/systemd/systemd-sysv-install enable elasticsearch
    Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.
  8. Start Elasticsearch service.
     $ sudo systemctl start elasticsearch
  9. Test if installation was successfully by querying Elasticsearch service.
    $ curl
      "name" : "90mQ0vJ",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "4oFjuDQLRtiCrkjrIKyZuQ",
      "version" : {
        "number" : "6.4.0",
        "build_flavor" : "default",
        "build_type" : "deb",
        "build_hash" : "595516e",
        "build_date" : "2018-08-17T23:18:47.308994Z",
        "build_snapshot" : false,
        "lucene_version" : "7.4.0",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
      "tagline" : "You Know, for Search"

    You will get the following error if you immediately test the service after starting it up because Elasticsearch takes a while to start.

    curl: (7) Failed to connect to port 9200: Connection refused

Discuss the article:

Comment anonymously. Login not required.