How to deploy Elasticsearch

Deploying a single-node elasticsearch cluster on Linux in 10 steps

vikas yadav
DevOps Dudes
3 min readSep 1, 2020

--

The best way to learn anything is by doing it!

With that in mind, I welcome you to part 2 of this series where we’ll deploy a single-node elasticsearch cluster in 10 steps on Ubuntu.

elasticsearch

If you haven't read part 1 I suggest you start there, I discuss various components of the Elastic stack

There are multiple ways to install elasticsearch, we’ll use the deb package which is suitable for Debian-based Linux systems.

Pre-requisites

A pre-requisite for this article is that you have an Ubuntu virtual machine(or any other Debian-based system), you can set this up on your hardware or you can use one of the public cloud options. You can also follow my youtube videos that will help you set up your elasticsearch lab on a google cloud platform or GCP, you’ll need to do 3 things

  1. Set up your GCP account
  2. Create a new VPC and configure networking for your elasticsearch lab
  3. Create virtual machines to host your elasticsearch cluster in GCP

With pre-requisites out of the way, let's deploy our elasticsearch demo system

1. Download and install elasticsearch’s public signing key

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

2. Install apt-transport-https package

sudo apt-get install apt-transport-https -y

3. Save directory definitions to /etc/apt/sources.list.d/elastic-7.x.list

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

5. Update the system and Install elasticsearch and Kibana

sudo apt-get updatesudo apt-get install elasticsearch && sudo apt-get install kibana

6. configure elasticsearch

Once elasticsearch and Kibana are installed, it is time to configure each application, lets start with elasticsearch. Elasticsearch configuration file can be found at /etc/elasticsearch/elasticsearch.yml

# Open elasticsearch configuration file with a text editor like nano   sudo nano /etc/elasticsearch/elasticsearch.yml# Configure the following settings in your elasticsearch.yml file   cluster.name: demo-elk      # give the cluster a descriptive name   node.name: elk-1            # give the node a descriptive name   network.host: 0.0.0.0       # change network binding   discovery.type: single-node # configure as single-node cluster# save the file

7. Start Elasticsearch service

once you have saved elasticsearch.yml, you can start elasticsearch service using the following command

sudo systemctl start elasticsearch

8. Validate Elasticsearch cluster health

After the service starts, check the health of your cluster using the following command

curl -XGET http://localhost:9200/_cluster/health?pretty

It should display something like this

{
“cluster_name” : “demo-elk”,
“status” : “yellow”,
“timed_out” : false,
“number_of_nodes” : 1,
“number_of_data_nodes” : 1,
“active_primary_shards” : 34,
“active_shards” : 34,
“relocating_shards” : 0,
“initializing_shards” : 0,
“unassigned_shards” : 12,
“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” : 73.91304347826086
}

9. configure Kibana

Next, its time to configure Kibana. Kibana configuration file can be found at /etc/kibana/kibana.yml.

# Open Kibana configuration file with a text editor like nano   sudo nano /etc/kibana/kibana.yml# Configure the following settings in your elasticsearch.yml fileserver.port: 5601                         # uncomment server.portserver.host: “0.0.0.0”                    # change server.hostserver.name: “demo-kibana”                # change server.name# uncomment elasticsearch.hosts
elasticsearch.hosts: [“http://localhost:9200"]

9. start Kibana service

systemctl start kibana

10. enable elasticsearch and Kibana

systemctl enable elasticsearchsystemctl enable kibana

Open Kibana by typing in IP address of your elk and port 5601

http:\\<<ip_address>>:5601

and it should display the home page for Kibana.

Please feel free to have a look at my youtube video on how to install elasticsearch.

--

--

vikas yadav
DevOps Dudes

IT engineer with 14 years of experience in IT with recent experience in Solution design, Big data, and log analytics.