How to Install Elasticsearch on Ubuntu 20.04

How to Install Elasticsearch on Ubuntu 20.04

Spread the love

installing elasticsearch on ubuntu 20.04Elasticsearch is an open-source platform for full-text search and analytics engines. It allows you to store, search, and analyze a large amount of data in real-time. It is a popular search engine designed for applications that have complex search requirements. With Elasticsearch, you can build a complex search functionality similar to the Google search engine.

In this tutorial, we will show you how to install Elasticsearch on Ubuntu 20.04.

Prerequisites

  • An Ubuntu 20.04 VPS (we’ll be using our SSD 2 VPS plan)
  • Access to the root user account (or access to an admin account with root privileges)

Step 1: Log in to the Server & Update the Server OS Packages

First, log in to your Ubuntu 20.04 server via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.

Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:

apt-get update -y
apt-get upgrade -y

Step 2: Add Elasticseach Repository

By default, Elasticsearch is not available in the Ubuntu standard OS repository. So you will need to add the Elasticsearch repository to your system.

First, install the required dependencies with the following command:

apt-get install apt-transport-https ca-certificates gnupg2 -y

Once all the dependencies are installed, import the GPG key with the following command:

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

Next, add the Elasticsearch repository with the following command:

sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'

Once the repository is added, you can proceed and install Elasticsearch.

Step 3: Install Elasticsearch

Now, update the repository cache and install the Elasticsearch with the following command:

apt-get update -y
apt-get install elasticsearch -y

Once the installation is completed, start the Elasticsearch service and enable it to start at system reboot with the following command:

systemctl start elasticsearch
systemctl enable elasticsearch

Next, verify whether Elasticsearch is running or not with the following command:

curl -X GET "localhost:9200"

You should get the following output:

{
  "name" : "ubuntu2004",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "JJY-gI6ESgqEvz1dSPxs3g",
  "version" : {
    "number" : "7.10.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
    "build_date" : "2020-12-05T01:00:33.671820Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Step 4: Configure Elasticsearch for Remote Access

By default, Elasticsearch is configured to listen on localhost only. If your application is hosted on the remote server and wants to use the Elasticsearch database then you will need to configure Elasticsearch to allow remote connection.

You can do it by editing Elasticsearch main configuration file:

nano /etc/elasticsearch/elasticsearch.yml

Uncomment and change the following line:

cluster.name: my-application
network.host: 192.168.0.100
discovery.seed_hosts: 192.168.0.100     

Save and close the file then restart the Elasticsearch service to apply the configuration changes:

systemctl restart elasticsearch

installing elasticsearch on ubuntu 20.04Congratulations! you have successfully installed Elasticsearch on an Ubuntu 20.04 VPS.installing Elasticsearch on Ubuntu 20.04

If you use one of our server management services, can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *