# Elasticsearch 7.17.x on Ubuntu 22.04+

## Introduction

This document provides a comprehensive guide for installing **Elasticsearch version 7.17.x** on an Ubuntu 22.04 system. It includes prerequisites, installation steps, configuration, and performance optimization guidelines recommended by OvalEdge.

### Prerequisites

Before proceeding, ensure the following requirements are met:

* **Operating System**: Ubuntu 22.04 LTS or later
* **User Access**: Root or a user with `sudo` privileges
* **Network**: Stable internet connection
* **Java**: Java 17 installed (`openjdk-17-jdk`)
* **Firewall**: Ensure required ports are open (`9200`, `9300`)

### Installation Steps

1. **Elasticsearch Installation**
   * **Update Package Index and Enable HTTPS Support**

     * Before installing Elasticsearch, update the package index and ensure secure APT transport is enabled:

       ```bash
       sudo apt update -y
       sudo apt install apt-transport-https -y
       ```

       \
       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfGKVKwCCVYjPMTaoArAncaI3qAxRVVp7ar01sgC6wLyIUQpk-Dy8y2wWcefqeh2m6xbk0g28qPf_yxAwSi6lSnTfg0_RSdt9CKwgW2iP2_w_4uZWMke5keQJbVMpgCuQ4rJ93L7g?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

     * Create Elasticsearch Repository File

       Download and add the GPG key, then configure the repository:

       ```bash
       wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
       sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
       ```

       \
       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd8T75SKSq9WOAyk7RE5tKZBe6G7DCVbuwCMDIR9KPkdDYVEqFU9B05rG1QEC4zLo79kyLwjRwK938iJTRPZWnGtU_nhv0zn5FMYvhO8RHOJCYqDMYsZbVIdtJSP-Kzs-N_ToIioQ?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

     * Install Elasticsearch

       Run the following commands to install Elasticsearch:

       ```bash
       sudo apt update
       sudo apt install elasticsearch -y
       ```

       \
       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc4IsXmjGmowG9mY6xVquF3B8HgoKr_ClDne3sVx8X16CB3ZfZmghgKKkYC9tMOLf7tnPgzrZk5fwr_Sp4qj_z2j6nZYFEJVuL2NG7aOPwwJFaNdnrpyYKZiRSXS3u1Ch4K62NK?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

     * Enable and Start the Service

       Enable Elasticsearch to start at boot and then start the service:

       ```bash
       sudo systemctl daemon-reexec
       sudo systemctl enable elasticsearch
       sudo systemctl start elasticsearch
       ```

       \
       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXemPtxe1aBWncDUwJB2_J9tBn7u9drzBZdMx4aCwOBU-WUbbsNc0IDVH6Rgk5yw4KVEzzhjytjouzvDAu4fYkWtwrNNgtGmtFa8Rg_7BOCXle6C-OW7K-FdgM0QH1bKI0_fDD3d?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

2. **Java Installation**

   * Log in to the Elasticsearch VM and install Java 17:

     ```bash
     sudo apt update -y
     sudo apt install -y openjdk-17-jdk
     java --version
     ```

     \
     *Sample Reference Screenshot*

     <div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeP-FiOpl1LvbvoVqgHzO8qVE8PNDTYKH7muZSJEMnAGHtSLUFUoaDwApajVJJzs3ITol7Sx3ZTWihi6Ry4eKUljZT1V-M-vKXCyNwtw0h-KzPBSNcLYenHwR2vCXlIXUBPhb69Xw?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure></div>

3. **Elasticsearch Configuration**
   * **Configure Elasticsearch Settings**

     * Open the Elasticsearch configuration file:

       ```bash
       sudo vi /etc/elasticsearch/elasticsearch.yml
       ```

       Add or update the following parameters:

       ```yaml
       cluster.name: ovaledge
       network.host: 0.0.0.0
       http.port: 9200
       transport.host: localhost
       transport.tcp.port: 9300
       xpack.security.enabled: true
       ```

       \
       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcCfe6YdSKgKX7-kD5zJarDhGpQa2D9_FUIhv8pC4yhLKrwEHkEH6SVqJ00Eg7vxp-0_kEb4NXYOj9JgYxwzlmTLxRoaaZiFfYRJWQNXA0WCDF3-g1U3G9wEurzv1v0y8Ik7Po-?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

   * **Configure JVM Heap Size**

     * Edit the JVM options file:

       ```bash
       sudo vi /etc/elasticsearch/jvm.options
       ```

       Locate the following lines (usually near the top of the file):

       ```ini
       ## -Xms4g
       ## -Xmx4g
       ```

       Uncomment and configure them:

       ```ini
       -Xms4g
       -Xmx4g
       ```

       <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Both values must be set to the same. Recommended value = <strong>50% of available memory</strong>.</p></div>

       \
       *Sample Reference Screenshot*

       <div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcRWvtWoNJyjRveIAVWNcGzrNicjYxjZ5YCwidBV072AWF7IihK83uYXVJ8-kQivS6nH9SBFmxBUediUnRG6h_iXLP6c7VUak47RNsTbKBdHe_8oa8aOlwvxvjIO0s574LBNPcr0w?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure></div>

   * **Restart Elasticsearch**
     * Restart the service to apply changes:

       ```bash
       sudo systemctl restart elasticsearch
       ```

4. **Elasticsearch Passwords**

   * **Set Password for Elastic User**
     * Run the password reset tool:

       ```bash
       sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
       ```

       When prompted:

       * Type **y**
       * Enter a new password for the `elastic` user
       * Confirm the password if requested

       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcPdJrLm_KzvTK9Cp0NSw4n5H0h9T8vMq9k4DFnEYqe4ROE7JRzRf6bOCHw0D7dOTKCbs2s1Z-YFOiZEiPXj9Qw6tZj4SXOV7WtTwP6cZCc_1fTD-5IgZfpwkAAVX7obHTh8-bE?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

5. **Verify Installation**

   * **Verify Service Availability**

     * Use `curl` or a browser to verify Elasticsearch is running:

       ```bash
       curl http://localhost:9200 -u elastic:<password>
       ```

       * Replace `<password>` with the password set previously
       * A successful response should display cluster information in JSON format

       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe5U8CUqLUlUxKb6oKNKSsE8jvqT8GCvR-2vkM0w0-Odx2TvMt6AOjvrwULbSlbdsWwr8jLsRg8ioXPiORgDIgIQE1mkjMEqeM5TqFWiXimuShHq1j8tTdBLOKu6mLJe3bS-_P1BA?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

   * **Open Firewall Ports (if enabled)**
     * If using `firewalld`, open the necessary ports:

       ```bash
       sudo firewall-cmd --permanent --add-port=9200/tcp
       sudo firewall-cmd --permanent --add-port=9300/tcp
       sudo firewall-cmd --reload
       ```

6. **Integrate Elasticsearch with OvalEdge**
   * **Locate and Edit `oasis.properties`**

     * On the OvalEdge application VM, navigate to the `extprop` directory and open the file:

       ```bash
       vi /path/to/ovaledge/extprop/oasis.properties
       ```

       \
       \&#xNAN;*Sample Reference Screenshot*

       <div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcGpYla3GKxqDXhYL3ooX33gFJqnSMKpXJxT7vhiAXekU955XrjOW9N7sQLLGypNUP73MxCNvyVYYl8QSkmgDZuPrKBl--nO_h1EWNhLJ-sqpVesNSjqZsuFjU2qbcJJi4I6Nh4_w?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure></div>

   * **Update Elasticsearch Section**

     * Configure the following parameters:

       ```properties
       es.host=<elasticsearch_host>
       es.port=9200
       es.protocol=http
       es.username=elastic
       es.password=<password>
       ```

       \
       *Sample Reference Screenshot*

       <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdu7fzUs57AUIpt-5jRGQhiwd7VqV3FGVIrWrpChufipOqOiawziAVex4dN4uKY6abHISbnq70gm1knM7uEB0zYciHIWMTSV8UYsbpEpe6uTWtRDpJPuNmSfdTZZ3S0PpgN41-2?key=2SbTepGGfk0cZXjz0gmLSw" alt=""><figcaption></figcaption></figure>

   * **Restart Tomcat Service**
     * Restart Tomcat to apply the updated configuration:

       ```bash
       sudo systemctl restart tomcat
       ```
