Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Setting Up Elasticsearch Environment

Introduction

Elasticsearch is a highly scalable open-source search and analytics engine. It allows you to store, search, and analyze large volumes of data quickly and in near real-time. This tutorial will guide you through setting up your own Elasticsearch environment from start to finish.

Prerequisites

Before setting up Elasticsearch, ensure you have the following prerequisites:

  • A system with at least 2GB of RAM
  • Java 11 or later installed
  • Internet access to download Elasticsearch

Step 1: Install Java

Elasticsearch requires Java to run. If you don't already have Java installed, you can install it using the following commands:

sudo apt update

sudo apt install openjdk-11-jdk

Verify the installation with:

java -version

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

Step 2: Download and Install Elasticsearch

Next, download and install Elasticsearch. You can download the latest version from the official website or use the following commands to download and install it:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-amd64.deb

sudo dpkg -i elasticsearch-7.12.1-amd64.deb

Step 3: Configure Elasticsearch

After installation, configure Elasticsearch by editing the configuration file located at /etc/elasticsearch/elasticsearch.yml. You can use any text editor to open and edit this file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Ensure the following settings are configured:

  • network.host: localhost
  • http.port: 9200

Step 4: Start and Enable Elasticsearch Service

Start the Elasticsearch service with the following command:

sudo systemctl start elasticsearch

Enable Elasticsearch to start on boot:

sudo systemctl enable elasticsearch

Verify that Elasticsearch is running:

sudo systemctl status elasticsearch

Step 5: Verify Installation

To verify the installation, open a web browser and go to http://localhost:9200/. You should see a JSON response similar to this:

{
  "name" : "your-node-name",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "your-cluster-uuid",
  "version" : {
    "number" : "7.12.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "your-build-hash",
    "build_date" : "2021-04-20T20:56:39.040728659Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Conclusion

Congratulations! You have successfully set up your Elasticsearch environment. You can now start using Elasticsearch to store, search, and analyze your data. For more advanced configurations and usage, refer to the official documentation.