a. Installing and configuring Elasticsearch
Guide to install Elastic Stack
For simplicity reasons I will be installing Elastic Stack as an All-in-One server that has all three instances, Elasticsearch, Kibana, and Logstash on a Ubuntu 18.04 LTS server with 8GB of RAM.
Sizing and configuring an Elastic Stack cluster with multiple nodes for logging use cases can be challenging and might be the subject of a separate blog.

Modify Hosts File

Firstly, I will add the name of my single-node cluster in /etc/hosts to use later in my elasticsearch configuration file.
1
192.168.20.222 elk_allinone
2
127.0.0.1 localhost
Copied!

Disabling SWAP

Considering the impact of swap on the performance and stability of the nodes, it is recommended to disable it permanently by modifying the/etc/fstab file.
1
$ sudo swapon –show
2
$ sudo swapoff -v /swapfile
3
$ sudo vi /etc/fstab
Copied!
Then comment any ligne that contains the word swap in the/etc/fstab then delete swapfile
1
$ sudo rm /swapfile
Copied!

Download and install Debian packages manually

I am going to work here with version 7.8.0 of elastic stack since, later, I will be installing opendistro's plugins which are at the time of writing this blog was not compatible with the latest version of Elastic Stack. See here for more information about version compatibilities.
1
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-amd64.deb
2
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-amd64.deb.sha512
3
$ shasum -a 512 -c elasticsearch-7.8.0-amd64.deb.sha512
4
$ sudo dpkg -i elasticsearch-7.8.0-amd64.deb
Copied!

Modify Heap Size

As a rule of thumb, it is recommended to dedicate half of the available RAM to Elasticsearch. In our case we have 8GB so we will modify jvm.optionsaccordingly.
1
$ sudo vi /etc/elasticsearch/jvm.options
Copied!
1
-Xms4g
2
-Xmx4g
Copied!

Modify Configuration File

Next step is modifying elasticsearch.ymlconfiguration file to fit my single-node cluster requirements.
1
// Back up your configuration file
2
$ sudo cp elasticsearch.yml elasticsearch.yml.backup
3
$ sudo vi /etc/elasticsearch/elasticsearch.yml
Copied!
1
# ======================== Elasticsearch Configuration ===================#
2
cluster.name: cyb3rsn0rlax
3
node.name: elk_allinone
4
node.master: true
5
node.ingest: true
6
node.data: true
7
node.ml: false
8
path.data: /var/lib/elasticsearch
9
path.logs: /var/log/elasticsearch
10
network.host: [_local_, _site_]
11
http.port: 9200
12
cluster.initial_master_nodes: ["elk_allinone"]
13
​
Copied!
I have a single-node cluster so obviously it will be my data node for storing data, my master node and my ingest node if I am willing to use Elasticsearch pipelines.

Modifying System Configuration

It is recommended to modify system configuration to allow the user running Elasticsearch to access more resources than allowed by default. This part depends on the system you're using and the method you used to install Elasticsearch, since we are using Ubuntu and the Debian package manual installation the following method would make the necessary changes.
1
$ sudo systemctl edit elasticsearch
Copied!
Add the following lines then reload and start Elasticsearch :
1
[Service]
2
LimitMEMLOCK=infinity
Copied!
1
$ sudo systemctl daemon-reload
2
$ sudo systemctl start elasticsearch
Copied!

Lets begin!

Configure elasticsearch service for automatic startup
1
$ sudo /bin/systemctl daemon-reload
2
$ sudo /bin/systemctl enable elasticsearch.service
Copied!
Check its status and curl it
1
$ sudo systemctl status elasticsearch
2
$ sudo curl localhost:9200
Copied!
1
{
2
"name" : "elk_allinone",
3
"cluster_name" : "cyb3rsn0rlax",
4
"cluster_uuid" : "-wuP6BX2QCiB5CSHKSw2GQ",
5
"version" : {
6
"number" : "7.8.0",
7
"build_flavor" : "default",
8
"build_type" : "deb",
9
"build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
10
"build_date" : "2020-11-26T06:34:37.794943Z",
11
"build_snapshot" : false,
12
"lucene_version" : "8.4.0",
13
"minimum_wire_compatibility_version" : "6.8.0",
14
"minimum_index_compatibility_version" : "6.0.0-beta1"
15
},
16
"tagline" : "You Know, for Search"
17
}
18
​
Copied!
​
Last modified 11mo ago