1. Getting Started - madhusudhankonda/elasticsearch-next-steps GitHub Wiki

Elasticsearch Next Steps

Welcome to the Elasticsearch Next Steps Online Live Training

Installation

Follow the steps below to install and get your Elasticsearch and Kibana up and running.

Download Software

Visit elastic.co/downloads for a set of downloads

Software Version Link
Elasticsearch 8.2.2 https://www.elastic.co/downloads/elasticsearch
Kibana 8.2.2 https://www.elastic.co/downloads/kibana

Click on the Downloads for the appropriate binary for your Operating System. We use Binary/Archive for this class

Install Elasticsearch on Windows OS

This step is for Windows OS, please look at the Elastic link for the instructions for other OSs.

  • Unpack the binary to your favorite folder
  • cd <ELASTICSEARCH_INSTALL_DIR>/bin
  • Execute the batch file: elasticsearch.bat You will see a message like 'Server started' in the command prompt console.

Install Elasticsearch on Mac OS

  • Unpack the tar.gz binary to your working folder
  • cd <ELASTICSEARCH_INSTALL_DIR>/bin
  • Execute the following command: ./elasticsearch

If should see the server started without errors as expected.

Using Docker

Make sure you install Docker Desktop for Windows or for [Mac] (https://hub.docker.com/editions/community/docker-ce-desktop-mac/) on your machine.

Once Docker is installed, follow the commands: To install the Elasticsearch server: docker pull docker.elastic.co/elasticsearch/elasticsearch:7.11.1

You should see something like this:

mkonda@Mac-mini PLATFORM % docker pull docker.elastic.co/elasticsearch/elasticsearch:7.11.1
7.9.2: Pulling from elasticsearch/elasticsearch
f1feca467797: Pull complete 
2b669da077a4: Pull complete 
e5b4c466fc6d: Pull complete 
...
Digest: sha256:2be3302537236874fdeca184c78a49aed17d5aca0f8fc3f6192a80e93e817cb4
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:7.9.2
docker.elastic.co/elasticsearch/elasticsearch:7.9.2

/images/docker-mac-install.png

Now that you have the image installed, let's run the server:

Sanity Test

Once the server was up and running, let's check out the status by visiting http://localhost:9200 on your internet browser. This should provide a JSON response on the browser like the following:

{
"name": "node-1",
"cluster_name": "elasticsearch",
"cluster_uuid": "xLcNZ2eYT0-t0nDijprIUw",
"version": {
"number": "7.11.1",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "ff17057114c2199c9c1bbecc727003a907c0db7a",
"build_date": "2021-02-15T13:44:09.394032Z",
"build_snapshot": false,
"lucene_version": "8.7.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}

Using CAT APIs

We can use _cat (compact and aligned text) APIs to talk to Elasticsearch with using a RESTful tool like Kibana or cURL.

Go to your browser and input http://localhost:9200/_cat command. You will see the list of cat APIs that are available to us:

=^.^=
/_cat/allocation
/_cat/shards
/_cat/nodes
/_cat/indices
/_cat/indices/{index}
/_cat/count
/_cat/count/{index}
/_cat/health
...

Let's get the health of the cluster: Enter http://localhost:9200/_cat/health?v on the browser's address bar and see the output something like the following:

epoch      timestamp cluster        status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1615158735 23:12:15  es-first-steps yellow          1         1      7   7    0    0        1             0                  -                 87.5%

There is a lot of information there but check the cluster name, the status and node.total.

Similarly, experiment by issuing _cat/nodes to fetch the nodes (you will get your information abour your node) and _cat/indices to fetch the indices.

We know our Elasticsearch is up and running and is responding to our queries. However, to get the extract its full potential, we must install another tool, Kibana - a graphical UI to interact with Elasticsearch, subject of the next section.

Install Kibana on MacOS

  • Unpack the Kibana binary (tag.gz) to your favorite folder
  • cd <KIBANA_INSTALL_DIR>/bin
  • Execute the shell script: ./kibana

Install Kibana on Windows OS

  • Unpack the Kibana binary to your favorite folder
  • cd <KIBANA_INSTALL_DIR>/bin
  • Execute the batch file: kibana.bat

You will see a message like below in the command prompt console.

  log   [12:41:36.302] [info][listening] Server running at http://localhost:5601
  log   [12:41:36.453] [info][server][Kibana][http] http server running at http://localhost:5601

/images/kibana_command_prompt.PNG

Or on the MacOS terminal:

/images/mac-kibana-running.png

Sanity Test

Once the Kibana web app was up and running, visit http://localhost:5601. This should take you to a Web UI, home of Kibana. If you see a beautiful UI on your browser, your Kibana tool is all set and ready to go!

Kibana Home on MacOS:

/images/kibana_home.png

Checking the state of the cluster

Let's issue a simple command to check the state of the cluster. Go to Kibaba, on your DevTools tab (left hand menu), enter the following API call:

GET _cluster/health

This should respond with

{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 16,
  "active_shards" : 16,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 10,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 61.53846153846154
}

The status yellow indicates you have no replicas for your shards available. Let's see if we can start a new node but on the same machine and using the same binary (you wouldn't do the same on PROD environment though!)

That's nice, you got the basic setup done for Elasticsearch and Kibana. Let's look at the configuraiton of the server in the next section.