Install Java
sudo apt install default-jre -y # version 2:1.11-72
sudo apt install openjdk-8-jre-headless -y
Download Official Java Installation guide
Elasticsearch
Elasticsearch is available for different platforms Elasticsearch Kibana Logstash . If you are looking for a particular version of elasticsearch find here , In this article, we will go ahead with ELK 7.10 for Ubuntu.
- Download and run elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-x86_64.tar.gz
tar -xzf elasticsearch-7.10.0-linux-x86_64.tar.gz
cd elasticsearch-7.10.1/
- Start elasticsearch
./bin/elasticsearch
- Once elasticsearch is started, Let's test by hitting
localhost:9200
Kibana
- Download and unzip kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.10.0-linux-x86_64.tar.gz
tar -xzf kibana-7.10.0-linux-x86_64.tar.gz
cd kibana-7.10.0-linux-x86_64/
- start kibana
./bin/kibana
Tips
- To run elasticsearch as a daemon in the background
./bin/elasticsearch -d -p pid
and to shut down Elasticsearch, kill the process ID recorded in the PID file:pkill -F pid
What few commands to check on starting elasticsearch
Getting information about clusters and nodes
GET _API/parameter
GET info about cluster
GET _cluster/health
Get info about nodes in a cluster
GET _nodes/stats
Uploading data to elasticsearch
This code can be used to generate ndjson from json for fast insertion of data in elasticsearch for experiments
Json to ndjson
jq -c -r ".[]" input.json | while read line; do echo '{"index":{}}'; echo $line; done > bulk.json
curl -XPOST localhost:9200/your_index/your_type/_bulk -H "Content-Type: application/x-ndjson" --data-binary @bulk.json