How can I install ElasticSearch 8, 7, or 6 on the Ubuntu 22.04|20.04|18.04 Linux system?. Elasticsearch is an Open Source full-text search and analytics engine tool used to store, search, and analyze big volumes of data in near real-time.
The Debian package for Elasticsearch can be downloaded from the website or from our APT repository. In this guide, we will use the APT installation method, which installs Elasticsearch on any Debian-based system such as Debian and Ubuntu.
We will install the free version which is released under the Elastic license. See the Subscriptions page for information about Elastic license levels. Here are the steps you’ll need to install ElasticSearch 8,7, or 6 on Ubuntu Linux.
For multi-node cluster, refer to Setup Elasticsearch Cluster on CentOS | Ubuntu With Ansible
Step 1: Update your system
I like starting all installations on an updated system.
sudo apt update && sudo apt -y full-upgrade
Check if the system needs reboot:
[ -f /var/run/reboot-required ] && sudo reboot -f
Step 2: Import the Elasticsearch PGP Key
Import Elasticsearch Signing Key used to sign all Elastic packages. Run the following command to download and install the public signing key:
sudo apt -y install gnupg
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/elastic.gpg
Step 3: Add APT repository
Next, we add the Elasticsearch APT repository from where we will download and install the packages.
For Elasticsearch 8.x:
sudo apt -y install apt-transport-https
echo "deb [signed-by=/etc/apt/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list
For Elasticsearch 7.x:
sudo apt -y install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
For Elasticsearch 6.x:
sudo apt -y install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/oss-6.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-6.x.list
For Elasticsearch 5.x:
sudo apt -y install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/oss-5.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-5.x.list
Step 4: Install Elasticsearch on Ubuntu
Then install the Elasticsearch Debian package by running:
sudo apt update
sudo apt install elasticsearch-oss||sudo apt install elasticsearch
For Elasticsearch 8, note the commands for next actions as shown after installation.
...
--------------------------- Security autoconfiguration information ------------------------------
Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.
The generated password for the elastic built-in superuser is : JQwFdYCFsksomAKgYAtv
If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>'
after creating an enrollment token on your existing cluster.
You can complete the following actions at any time:
Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.
Generate an enrollment token for Kibana instances with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.
Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.
After the installation, a default configuration file will be populated to /etc/elasticsearch/elasticsearch.yml. Most lines are commented out, edit the file to tweak and tune the configuration.
E.g, you can set the correct cluster name for your applications:
cluster.name: myapplication
Note that the default minimum memory set for JVM is 2gb, if your server has small memory size, change this value:
sudo nano /etc/elasticsearch/jvm.options
Change:
-Xms2g
-Xmx2g
And set your values for minimum and maximum memory allocation. E.g to set values to 512mb of ram, use:
-Xms512m
-Xmx512m
Note that it is recommended to set the min and max JVM heap size to the same value. Xms represents the initial size of total heap space and Xmx represents the maximum size of total heap space.
After you have modified the configuration, you can start Elasticsearch:
sudo systemctl enable elasticsearch.service && sudo systemctl restart elasticsearch.service
Check elasticsearch service status:
$ systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-05-03 09:18:39 PDT; 18s ago
Docs: http://www.elastic.co
Main PID: 21459 (java)
Tasks: 18 (limit: 1093)
Memory: 429.0M
CGroup: /system.slice/elasticsearch.service
├─21459 /usr/share/elasticsearch/jdk/bin/java -Xms512m -Xms512m -XX:+UseConcMarkSweepGC -XX:CMSIn
└─21589 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
May 03 09:18:39 ubuntu systemd[1]: Started Elasticsearch.
You have deployed a single node Elasticsearch cluster on your Ubuntu system.
Learning materials:
Reference books:
I haven’t seen a nice post like this in a while, so I’m going to start following you in the hopes that you continue to improve.
Thanks Tomasa we will keep getting better.
Yes, I also have the same opinion with you.
Welcome!