Setting up Elasticsearch Development Environment.
By: Kumar Gaurav
Tags: Elasticsearch, Full Text Search, Search, NoSQL, Cloud

Introduction

Elasticsearch is a Lucene-based search server (and a lot more) that has become a topic of every hot conversation around the block. If you work with large volumes of structured/unstructured text data in production environments, you would have come across Elasticsearch quite often.

Elasticsearch can scale up to Petabytes of data, is highly available, can double as a No-SQL datastore, has a class leading enterprise support while offering all the goodness of Lucene (Full Text Search) in a nicely wrapped API. No wonder this has become the absolute favorite of industry giants in a very short span of time.

Today, we are going to take the first step in a long journey of understanding the crux of Elasticsearch and what makes it everyone’s favorite by setting up a local development environment.

Note: This is the first article in a multipart series to explore Elasticsearch in detail. Please check additional articles here.

Prerequisites

Before we jump into setting up our Elasticsearch server, lets go ahead and check if our system is ready with prerequisites.

The list of prerequisites for Elasticsearch is pretty short, in fact if you are on Unix platform (Linux/MacOS), the only requirement is a compatible appropriate version of JAVA. As of writing this article (latest Elastic Search Version 7.1.0), java 7+ (recommended 8+) will work fine.

Note: Elasticsearch installer ships with JDK which can be used directly, in case you want to use your own installation of JAVA, Setup JAVA_HOME environment variable.

java -version

echo $JAVA_HOME

Installation

Depending upon your use case their are several ways to get Elastic Search up and running on your local system, Let’s discuss each one by one

From archive (.tar.gz) on Linux or MacOS Using Package Manager on Debian based Linux Distribution. Using Docker

Let’s address each one at a time.

1. From archive (.tar.gz) on Linux or MacOS

Elasticsearch is available as .tar.gz archive on elastic official website, both latest and archived versions can be downloaded from the link here.

Alternately, for the latest version of elastic search (as of writing this article), following code snippet can be used.

On Linux

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

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-x86_64.tar.gz.sha512

shasum -a 512 -c elasticsearch-7.10.0-linux-x86_64.tar.gz.sha512

$ tar -xzf elasticsearch-7.10.0-linux-x86_64.tar.gz

On MacOS

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-darwin-x86_64.tar.gz

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-darwin-x86_64.tar.gz.sha512

shasum -a 512 -c elasticsearch-7.10.0-darwin-x86_64.tar.gz.sha512

$ tar -xzf elasticsearch-7.10.0-darwin-x86_64.tar.gz

Running Elasticsearch from command line

This is one of the simplest (not very robust and reusable) way to get up and running with Elasticsearch. In my personal experience unless you are setting us the environment for a very occasional, mostly learning purpose, running elastic search as service (next section) is worth the effort.

$ cd elasticsearch-7.10.0/

$ ./bin/elasticsearch

2. Using Package Manager on Debian based Linux Distribution

While installing Elasticsearch using .tar.gz archive is an excellent way to get started quickly, it leaves a lot to be desired, in terms of long term use and manageability of the service.

First import the Elasticsearch PGP key

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

2. Add the Elasticsearch repository in apt directory

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

3. Finally the magic command, to summon them all

sudo apt-get update && sudo apt-get install elasticsearch

4. To make Elasticsearch server start on its own every time you reboot, lets enable the service (Optional)

sudo /bin/systemctl enable elasticsearch.service

5. If you wanna manually start/stop the service, following command can be used. (Optional)

sudo /bin/systemctl start elasticsearch.service

sudo /bin/systemctl stop elasticsearch.service

sudo /bin/systemctl restart elasticsearch.service

6. Now to check/debug the installation

sudo /bin/systemctl status elasticsearch.service

You should get a green running status, in case it shows any error, you can debug the same using command.

journalctl -b -u elasticsearch.service

3. Using Docker

This is perhaps the easiest and simplest way to deploy Elasticsearch server on a local system. If you want to setup the server purely for learning purpose or want to run experiments that risk messing up the installation, this is the recommended way to go.

we can get up and running in two easy step (assuming you have docker installed and configured on your system, if not, please Get Docker)

Pulling the Image

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.0

Starting a single node cluster

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.0

There you go, That’s pretty much it.

Conclusion

While Elasticsearch is a labyrinth of a system, jam-packed of features and configuration, moldable in any shape or size imaginable, it is almost comically easy to get a single note server up and running, and poke around. I have tried to list some of the most popular setup environments in the article, in case you on a different platform, you can checkout the Elasticsearch official installation guide here.

This is the very first article in a multipart Getting to know Elasticsearch series that I am writing. Ones you are done with your installation you might be interested in a simple Python based Indexer to load data into your new installed and currently empty Elasticsearch server.

A Simple Elasticsearch Indexer written in Python Programming Language (Coming Soon!)

Ref:

https://www.elastic.co/guide/index.html