• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Ubuntu » How To Install and Configure Elasticsearch on Ubuntu Server 22.04

How To Install and Configure Elasticsearch on Ubuntu Server 22.04

sammbysamm
October 17, 2023
Install Elasticsearch on Ubuntu

How To Install and Configure Elasticsearch on Ubuntu Server 22.04

Share on FacebookShare on LinkedinShare on Whatsapp

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.

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.

OTHER POSTS

How To Install and Secure phpMyAdmin on Ubuntu 22.04

How To Secure SSH with Fail2Ban on Ubuntu 22.04

How To Install Uptime Kuma on Ubuntu 22.04

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:

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.

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.

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.

Tags: ElasticsearchLogOpensourceSearchSearch EngineUbuntu

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install DBeaver Community on Ubuntu 22.04

Next Post

How To Install Python 3.11 on Rocky Linux 9

Leave a Reply Cancel reply

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

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu

How To Install and Secure phpMyAdmin on Ubuntu 22.04

July 22, 2024
Secure SSH with Fail2Ban
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

October 29, 2023
Install Uptime Kuma on Ubuntu 22.04
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

November 12, 2023
Install Ubuntu Server 22.04
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

October 21, 2023
Load More
Next Post
Install Python 3.11 on Rocky Linux

How To Install Python 3.11 on Rocky Linux 9

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.