Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

On-Premises Deployment of Elasticsearch

Introduction

Elasticsearch is a powerful search engine that is widely used for its full-text search capabilities. Deploying Elasticsearch on-premises allows for greater control over data and infrastructure. This tutorial will guide you through the process of setting up an Elasticsearch instance on your local environment.

Prerequisites

Before you begin, ensure you have the following:

  • A machine with at least 2GB of RAM and a dual-core CPU.
  • Java 8 or later installed.
  • Basic knowledge of command-line interface (CLI) operations.

Step 1: Download Elasticsearch

To start, download the latest version of Elasticsearch from the official website:

https://www.elastic.co/downloads/elasticsearch

Select the appropriate package for your operating system and download it.

Step 2: Install and Configure Elasticsearch

Once the download is complete, extract the archive to a suitable location:

tar -xzf elasticsearch-7.x.x.tar.gz

Navigate to the Elasticsearch directory:

cd elasticsearch-7.x.x

Open the config/elasticsearch.yml file in a text editor and make necessary adjustments. For example, you might want to set the cluster name:

cluster.name: my-application

Step 3: Starting Elasticsearch

To start Elasticsearch, run the following command:

./bin/elasticsearch

Elasticsearch will start in the foreground, and you should see log messages indicating its status.

Step 4: Verifying the Installation

To verify that Elasticsearch is running correctly, open a new terminal window and run the following command:

curl -X GET "localhost:9200"

You should see a JSON response with details about your Elasticsearch instance.

{ "name" : "your-node-name", "cluster_name" : "your-cluster-name", "cluster_uuid" : "some-uuid", "version" : { "number" : "7.x.x", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "some-hash", "build_date" : "some-date", "build_snapshot" : false, "lucene_version" : "8.x.x", "minimum_wire_compatibility_version" : "6.x.x", "minimum_index_compatibility_version" : "6.x.x" }, "tagline" : "You Know, for Search" }

Step 5: Managing Elasticsearch

Elasticsearch provides several tools for managing and monitoring your cluster. Here are some basic commands:

  • Stopping Elasticsearch:
    pkill -f elasticsearch
  • Checking cluster health:
    curl -X GET "localhost:9200/_cluster/health?pretty"
  • Viewing node statistics:
    curl -X GET "localhost:9200/_nodes/stats?pretty"

Conclusion

Congratulations! You have successfully deployed Elasticsearch on your local machine. This setup allows you to explore the powerful features of Elasticsearch and integrate it with your applications. For more advanced configurations and optimizations, refer to the official Elasticsearch documentation.