To set up Elasticsearch 7 on Ubuntu 20.04 please run these simple commands one-by-one in the command-line interface:

sudo apt -y install gnupg
wget -qO - | sudo apt-key add -

sudo apt -y install apt-transport-https
echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update
sudo apt -y install elasticsearch

By default, Elasticsearch uses 2GB RAM memory for JVM. If your server has limited memory size you can reduce it to e.g. 1gb or 512mb. To do this edit the jvm.options file, run the command:

sudo nano /etc/elasticsearch/jvm.options

and change the




Save the jvm.options file.

Next, enable and start elasticsearch service, run the commands:

sudo systemctl enable elasticsearch.service && sudo systemctl restart elasticsearch.service

Once is done, you can check the elasticsearch and see if it works. Run the command:

systemctl status elasticsearch.service

If everything is fine you should see a similar result:

● elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor>
Active: active (running) since Sun 20XX-11-14 10:23:20 EET; 1s ago
Main PID: 14009 (java)
Tasks: 65 (limit: 18364)
Memory: 719.1M
CGroup: /system.slice/elasticsearch.service
└─14009 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto>