Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Single-Node Deployment of Elasticsearch

Introduction

Elasticsearch is a powerful open-source search and analytics engine. It's used for a variety of use cases like log and event data analysis, full-text search, and more. In this tutorial, we'll guide you through setting up a single-node deployment of Elasticsearch from start to finish.

Prerequisites

Before you begin, ensure you have the following:

  • A system with at least 2GB of RAM
  • Java 8 or higher installed
  • Internet connection for downloading Elasticsearch

Step 1: Download and Install Elasticsearch

First, download the latest version of Elasticsearch from the official website or use the following command:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.0-linux-x86_64.tar.gz

Once downloaded, extract the tarball:

tar -xzf elasticsearch-8.0.0-linux-x86_64.tar.gz

Step 2: Configure Elasticsearch

Navigate to the extracted directory and open the configuration file elasticsearch.yml located in the config directory. Make the following changes:

  • cluster.name: my-cluster
  • node.name: node-1
  • network.host: 0.0.0.0

These settings configure the cluster name, node name, and network settings respectively.

Step 3: Start Elasticsearch

To start Elasticsearch, navigate to the bin directory and run the following command:

./elasticsearch

You should see output similar to the following:

[2023-01-01T12:00:00,000][INFO ][o.e.n.Node ] [node-1] version[8.0.0], pid[12345], build[default/tar/abc123/2023-01-01T12:00:00.000Z], OS[Linux/4.15.0-106-generic/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_212/25.212-b04] [2023-01-01T12:00:00,000][INFO ][o.e.n.Node ] [node-1] starting ... [2023-01-01T12:00:00,000][INFO ][o.e.t.TransportService ] [node-1] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300} [2023-01-01T12:00:00,000][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks [2023-01-01T12:00:00,000][INFO ][o.e.c.s.MasterService ] [node-1] elected-as-master ([1] nodes joined)[{node-1}{RANDOM_ID}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=1234567890, xpack.installed=true, ml.max_open_jobs=20}]) [2023-01-01T12:00:00,000][INFO ][o.e.c.c.CoordinationState] [node-1] cluster UUID [RANDOM_UUID] [2023-01-01T12:00:00,000][INFO ][o.e.n.Node ] [node-1] started

Step 4: Verify Elasticsearch is Running

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

curl -X GET "localhost:9200/"

You should see a response similar to this:

{ "name" : "node-1", "cluster_name" : "my-cluster", "cluster_uuid" : "RANDOM_UUID", "version" : { "number" : "8.0.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "abc123", "build_date" : "2023-01-01T12:00:00.000Z", "build_snapshot" : false, "lucene_version" : "8.6.2", "minimum_wire_compatibility_version" : "7.10.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" }

Conclusion

Congratulations! You've successfully deployed a single-node Elasticsearch instance. You can now start using Elasticsearch for indexing and searching your data.

For further customization and scaling, refer to the official Elasticsearch documentation.