-
Notifications
You must be signed in to change notification settings - Fork 84
1. Getting Started
Welcome to the Elasticsearch First Steps Online Live Training. This wiki will help you set up and play with the course.
My upcoming Elasticsearch in Action book
I am authoring the second edition of Elasticsearch in Action (second edition) Book and is out for early access. It is a hands-on book that will delve in-depth to guide you in learning Elasticsearch from the ground up.
Follow the steps below to install and get your Elasticsearch and Kibana up and running.
Visit elastic.co/downloads for a set of downloads
Software | Version | Link |
---|---|---|
Elasticsearch | 8.11.1 | https://www.elastic.co/downloads/elasticsearch |
Kibana | 8.11.1 | 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
This step is for Windows OS, please look at the Elastic link for the instructions for other OSs.
- Unpack the binary to your favourite 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.
- Unpack the tar.gz binary to your working folder
- cd <ELASTICSEARCH_INSTALL_DIR>/bin
- Execute the following command:
./elasticsearch
There's a security related information gets printed (first ever time only) on the console, something like the following:
As you can see, should you wish to connect/check your server, there are credentials created automatically for us. Let's check how to use them in a moment.
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.12.1
You should see something like this:
mkonda@Mac-mini PLATFORM % docker pull docker.elastic.co/elasticsearch/elasticsearch:7.12.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.12.1
docker.elastic.co/elasticsearch/elasticsearch:7.12.1
Now that you have the image installed, let's run a signgle-node server:
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.13.0
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": "Mac-mini.local",
"cluster_name": "elasticsearch",
"cluster_uuid": "pI_0RtKTTKigHGgf_IyEUw",
"version": {
"number": "7.12.1",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e",
"build_date": "2020-09-23T00:45:33.626720Z",
"build_snapshot": false,
"lucene_version": "8.6.2",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
Now, let's test the Kibana tool too, as mentioned in the next section.
- Unpack the Kibana binary (tag.gz) to your favourite folder
- cd <KIBANA_INSTALL_DIR>/bin
- Execute the shell script:
./kibana
- Unpack the Kibana binary to your favourite 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
Or on the MacOS terminal:
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:
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. That is, should your Elasticsearch vanishes off, you'll be losing all the data. 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!)
If you wish to start a new node on the same host using the same binary, we need to provide a couple of additional arguments to the script - the data and logs path directories. See Configuration section.
Let's get information about our shards. We use a cat
API for this - short for Compact and Aligned Text.
The
cat
API is for our convenience, not for programmatic consumption.
GET _cat/shards?v
which will result in:
Index a document with four fields - title
, rating
, synopsis
and release_date
for a movie Godfather (search IMDB for info). Fetch the document (remember, the UUID in the response?) using GET method
Index a document with four fields - title
, rating
, synopsis
and release_date
for a movie Godfather (search IMDB for info) with a document ID as 99. Retrieve the same document using GET