sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Install and Configure Elasticsearch on Ubuntu Server 22.04
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Install and Configure Elasticsearch on Ubuntu Server 22.04

Samuel Siahaan
By Samuel Siahaan
Last updated: April 23, 2023
SHARE

Introduction

At the present time Elasticsearch is a powerful search and analytics engine that can help you extract valuable insights from your data. Installing and configuring Elasticsearch on your Ubuntu Server 22.04 can be a game-changer for data analysis and search functionality. For that reason this easy-to-follow step-by-step guide, we will walk you through the process of how to install and configure Elasticsearch on Ubuntu Server 22.04. Lastly of this tutorial, you’ll have Elasticsearch up and running smoothly on your Ubuntu Server.

Contents
IntroductionTable of ContentsWhy Elasticsearch on Ubuntu Server 22.04?PrerequisitesInstall Elasticsearch on Ubuntu Server 22.04Step 1: Update the System on Ubuntu 22.04Step 2: Install JavaStep 3: Add the Elasticsearch RepositoryStep 4: Install ElasticsearchStep 5: Configure ElasticsearchStep 6: Start and Enable ElasticsearchStep 7: Test ElasticsearchStep 8: Configure Firewall for ElasticsearchStep 9: Install Kibana (Optional)Conclusion

Table of Contents

  • Introduction
  • Why Elasticsearch on Ubuntu Server 22.04?
  • Prerequisites
  • Install Elasticsearch on Ubuntu Server 22.04
    • Step 1: Update the System on Ubuntu 22.04
    • Step 2: Install Java
    • Step 3: Add the Elasticsearch Repository
    • Step 4: Install Elasticsearch
    • Step 5: Configure Elasticsearch
    • Step 6: Start and Enable Elasticsearch
    • Step 7: Test Elasticsearch
    • Step 8: Configure Firewall for Elasticsearch
    • Step 9: Install Kibana (Optional)
  • Conclusion

Why Elasticsearch on Ubuntu Server 22.04?

Before we dive into the installation and configuration, let’s briefly discuss why Elasticsearch on Ubuntu Server 22.04 is a great choice. Given that Ubuntu Server 22.04 is a stable and secure operating system, making it an ideal platform for hosting Elasticsearch and ensuring a reliable search engine for your applications.

Prerequisites

Important to realize this guide assumes that you are using Ubuntu Server 22.04. Before we dive into install and configure Elasticsearch on Ubuntu Server 22.04 there are prerequisite you need to ensure are in place:

  • Before you begin, you should have a non-root user account with sudo privileges set up on your system. You can learn how to do this by following the Initial Server Setup Guide with Ubuntu Server 22.04 tutorial.
  • We will work with the minimum amount of CPU and RAM required to run Elasticsearch. Note that the amount of CPU, RAM, and storage that your Elasticsearch server will require depends on the volume of logs that you expect.

Install Elasticsearch on Ubuntu Server 22.04

Here’s a simple guide on how to install and configure Elasticsearch on Ubuntu Server 22.04. By following these steps, you can tap into the advantages it offers:

- Advertisement -

Step 1: Update the System on Ubuntu 22.04

To ensure that your Ubuntu Server is up to date, start by running the following commands in your terminal:

Bash
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install apt-transport-https ca-certificates wget

Additionally, these commands will update your package lists and upgrade installed packages to their latest versions.

Step 2: Install Java

Elasticsearch is built on Java, so you need to have Java installed on your server. You can install OpenJDK 11, a popular choice, with the following command:

Bash
$ sudo apt install -y openjdk-11-jre-headless

Furthermore, this command installs the Java Runtime Environment (JRE) without unnecessary graphical components.

Step 3: Add the Elasticsearch Repository

Basically The Elasticsearch components are not available in Ubuntu’s default package repositories. However, you can install them with APT after adding Elastic’s package source list.

- Advertisement -

Moreover, all packages are signed with the Elasticsearch signing key, providing an added layer of security to safeguard your system against package spoofing. Once authenticated using the key, your package manager will trust these packages. Use the following command:

Bash
$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

Furthermore, the above command should yield an “OK” output, signifying the successful import of the key.

Because of this, you can consider packages from this repository to be reliable and dependable.

- Advertisement -

Then, we need to add the Elastic APT repository. Since the lsb_release -cs sub-command will return the name of your Ubuntu distribution, the command will add the correct repository:

Bash
$ echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list

The output will be similar to this, for instance:

Bash
deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main

Step 4: Install Elasticsearch

Now that the repository has been added, you can proceed to install Elasticsearch. To do this, update the package lists once more.

Bash
$ sudo apt update

Then install Elasticsearch:

Bash
$ sudo apt install elasticsearch

The output will be similar to this:

Bash
$ sudo apt install elasticsearch
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  elasticsearch
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 606 MB of archives.
After this operation, 1,246 MB of additional disk space will be used.
Get:1 https://artifacts.elastic.co/packages/8.x/apt stable/main amd64 elasticsearch amd64 8.9.0 [606 MB]
Fetched 606 MB in 1min 42s (5,964 kB/s)                                                                                                                                                                           
Selecting previously unselected package elasticsearch.
(Reading database ... 86173 files and directories currently installed.)
Preparing to unpack .../elasticsearch_8.9.0_amd64.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (8.9.0) ...
Setting up elasticsearch (8.9.0) ...

-------------------------------------------------------------------------------------------------
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service
Scanning processes...                                                                                                                                                                                              
Scanning candidates...                                                                                                                                                                                             
Scanning linux images...      

Step 5: Configure Elasticsearch

Before we start Elasticsearch for the first time, we need to configure a few things. Open the Elasticsearch configuration, file is located at /etc/elasticsearch/elasticsearch.yml.

Bash
$ sudo vi /etc/elasticsearch/elasticsearch.yml

Adjust the following configurations to enhance security and performance:

Set the cluster name to identify your Elasticsearch cluster:

JSON
cluster.name: my-elasticsearch-cluster

After that configure the network host to allow connections from localhost:

JSON
network.host: 172.32.1.221

Then save and close the configuration file.

Step 6: Start and Enable Elasticsearch

Once you complete the installation, initiate and enable the Elasticsearch service.

Bash
$ sudo systemctl enable elasticsearch
$ sudo systemctl start elasticsearch

To check the status of the service, if it is up and running, execute the following command:

Bash
$ sudo systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
     Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-08-03 20:05:01 WIB; 11s ago
       Docs: https://www.elastic.co
   Main PID: 44806 (java)
      Tasks: 83 (limit: 4556)
     Memory: 2.3G
        CPU: 47.342s
     CGroup: /system.slice/elasticsearch.service
             ├─44806 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=/usr/share/elasticsearch/bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.hom>
             ├─44864 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -Djava.security.manager=allow -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless>
             └─44888 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Aug 03 20:04:32 elasticsearch systemd[1]: Starting Elasticsearch...
Aug 03 20:05:01 elasticsearch systemd[1]: Started Elasticsearch.

Step 7: Test Elasticsearch

To verify the operational status of Elasticsearch, you can use the “curl” command. This command dispatches an HTTP request to port 9200 on either localhost or your IP address.

Bash
$ curl -X GET "172.32.1.221:9200/"

If the setup is correct, then your Elasticsearch cluster will generate a JSON response containing relevant information.

JSON
{
  "name" : "elasticsearch",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "3JIbJ_6tRv2ru3Br-VOqPQ",
  "version" : {
    "number" : "8.9.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "8aa461beb06aa0417a231c345a1b8c38fb498a0d",
    "build_date" : "2023-07-19T14:43:58.555259655Z",
    "build_snapshot" : false,
    "lucene_version" : "9.7.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Step 8: Configure Firewall for Elasticsearch

Elasticsearch data finds its storage within the /var/lib/elasticsearch directory. Additionally, configuration files are positioned at /etc/elasticsearch, while Java start-up options can be tailored through the /etc/default/elasticsearch file.

By default, Elasticsearch is configured to listen on localhost only. If the client connecting to the database is also running on the same host and you are setting up a single node cluster, you don’t need to change the default configuration file.

By default, Elasticsearch doesn’t implement authentication, which means it grants access to anyone who can reach the HTTP API. Therefore, to enable remote access to your Elasticsearch server, you’ll need to configure your firewall and open TCP port 9200.

Usually, you’d prefer to grant access to the Redis server exclusively from a specific IP address or IP range. For instance, to permit connections solely from the 172.32.1.0/24 subnet, you would execute the following command:

Bash
$ sudo ufw allow from 1172.32.1.0/24 to any port 9200
$ sudo ufw reload

Once the firewall is configured, the next step is to edit the Elasticsearch configuration and allow Elasticsearch to listen for external connections.

To do so, open the elasticsearch.yml configuration file:

Bash
$ sudo vi /etc/elasticsearch/elasticsearch.yml

Search for the line that contains network.host, and change the value to 0.0.0.0:

JSON
network.host: 0.0.0.0

If you have multiple network interfaces on your machine, you can specify the interface IP address. This will ensure identically that Elasticsearch listens exclusively on the provided interface.

Then restart the Elasticsearch service for the changes to take effect:

Bash
$ sudo systemctl restart elasticsearch

That’s it. You can now connect to the Elasticsearch server from your remote location.

Step 9: Install Kibana (Optional)

Kibana, a data visualization tool, pairs well with Elasticsearch. To install Kibana, follow these steps:

Add Kibana repository:

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

Install Kibana:

Bash
$ sudo apt update
$ sudo apt install kibana

Configure Kibana, open the Kibana configuration file:

Bash
$ sudo vi /etc/kibana/kibana.yml
JSON
#Set the server host to localhost:
server.host: "localhost"

Start and enable Kibana:

Bash
$ sudo systemctl start kibana
$ sudo systemctl enable kibana

Conclusion

Finally Congratulations! You’ve successfully installed and configured Elasticsearch on your Ubuntu Server 22.04. Elasticsearch is now ready to index and search your data, making it a valuable tool for data analysis and search functionality in your applications.

In this guide, we covered the essential steps for installing and configuring Elasticsearch, including updating your system, installing Java, downloading and installing Elasticsearch, starting and enabling Elasticsearch, configuring Elasticsearch, testing the installation, and optionally installing Kibana and plugins.

With Elasticsearch at your disposal, you have a powerful tool to enhance your data-driven applications and gain valuable insights from your data. Happy searching and analyzing!

To learn more about Elasticsearch, visit the official documentation page.

Also Read Our Other Guides :

  • How To Install and Configure Go (Golang) on Ubuntu 22.04
  • How To Install and Configure NFS Server Client on Ubuntu 22.04
  • How To Install Nextcloud with Apache and MariaDB on Ubuntu Server 22.04
  • How To Install Composer in Ubuntu 22.04: A Comprehensive Guide

As I have shown, now you have learned how to install and configure Elasticsearch on Ubuntu 22.04.

TAGGED:ElasticsearchLogOpensourceSearchSearch EngineUbuntu

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Install DBeaver Community on Ubuntu 22.04
Next Article How To Install Python 3.11 on Rocky Linux 9
Leave a Comment

Leave a Reply Cancel reply

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

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install MongoDB 6.0 on Debian 10 & 11
Debian

You Might Also Like

Ubuntu

How To Install and Use TeamViewer on Ubuntu 22.04

9 Min Read
Ubuntu

How To Install Redis on Ubuntu Server 22.04

14 Min Read
Ubuntu

How To Install VirtualBox 7.0 on Ubuntu 22.04

9 Min Read
Ubuntu

How To Install Nextcloud with Apache and MariaDB on Ubuntu Server 22.04

20 Min Read
Ubuntu

How To Install MariaDB 10.6 on Ubuntu Server 22.04

14 Min Read
Ubuntu

How To Install Snipe-IT Asset Management on Ubuntu 22.04

13 Min Read
Linux

How To Install and Use Linux Screen with Commands

9 Min Read
Ubuntu

How To Install and Use Docker CE on Ubuntu 22.04

26 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?