Install Elasticsearch on Ubuntu 20.04 - Best Method ?

Elasticsearch is an analytic engine that allows you to search and analyze data in real-time. It is an open-source project distributed platform that provides RESTful API. You can host elasticsearch in your own data center or in a local machine and use it for storing, searching, and analyzing them.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Server Monitoring queries.

In this context, we shall look into how to install the latest version of elasticsearch on Ubuntu 20.04 and configure it to use.


How to Install elasticsearch on Ubuntu ?

1. First, update your packages using the following command.

# apt-get update

2. Install required dependency as below.

# apt-get -y install curl gnupg2 apt-transport-https

3. Now, you need to add an elastic search GPG key in order to download the package. So, copy paste the following line of command in your terminal.

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

Now download the elastic search package using the following command. Here, if you use 7.x as below, you will get the latest version of the elastic search package. If you want an older version you can specify in place of 7.x. Please refer to the official release version documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/es-release-notes.html

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

You have just added an elastic search package to the system. So, let's update it once.

# apt-get update

4. Now, you are ready to install elastic search just by entering the following command.

# apt-get install elasticsearch -y


How to Configure elasticsearch ?

Now, that your elasticsearch service is installed, You need to configure it to reach your network or publicly. The configuration file is located inside /etc/elasticsearch/elasticsearch.yml so, open it using your favorite editor.

# vim /etc/elasticsearch/elasticsearch.yml

Make sure you change the following parameter. Here, ‘cluster.name’ is the name for your elasticsearch service. 

In 'network.host' use your server IP address, otherwise, it will not be accessible outside the host. 

Similarly, use your host IP in 'discovery.seed_hosts' as below:

cluster.name: my_search_server
network.host: 10.4.3.200
discovery.seed_hosts: 10.4.3.200

Save the file and start and enable an elasticsearch service using systemctl.

# systemctl start elasticsearch
# systemctl enable elasticsearch

Check service status using,

# systemctl status elasticsearch

Now, port 9200 should be listening, you can verify using the following command.

# ss -ltn | grep 9200

If everything is fine you should get the following output as the response.

# curl -X GET "localhost:9200/"


[Need help in Installing Software Packages on Ubuntu Linux System? We can help you. ]

This article covers how to install elasticsearch in the stable version of Ubuntu 20.04. Now you can use the hosted elasticsearch server for doing searches.

If your application generates a huge amount of data and the search procedures are slow, then using elasticsearch will be best.

Related Posts