In this tutorial, we will learn how to install and configure Elasticsearch ubuntu 16.04 and 18.04
1. What is Elasticsearch?
Elasticsearch is a distributed, open-source search and analytics engine for all types of data. For example Text, Numbers, structured, etc. It is built on apache Lucene and provide scalable search. With Elasticsearch we can store, search, and analyze big volumes of data quickly and in near real-time. Elasticsearch is built on java and data is stored as a document in JSON.
Elasticsearch is basically used for application search, a website search, analytics of big data, etc.
2. Advantage of using Elasticsearch
- Fast: It is built on top of Lucene and come through full-text search. Elasticsearch is near real-time-search platform
- Features: It has numbers of powerful built-in features which help us to store and search data more efficient
- Distributed by nature: when we store data in Elasticsearch are distributed in different containers called shards which are duplicated to provide redundant data in case of hardware failure.
# Install Elasticsearch on ubuntu
In this topic, we will cover both
APT Repository and manual installation using
wget. So let's start the installation with APT Repo method
Method 1. Installing from APT Repository
Before we start make sure
apt-transport-https is installed
sudo apt-get install apt-transport-https
Next, Enter the following command to add key and the repository definition.
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
Once done with adding the repository, Now update your repo and install the Elasticsearch Debian package by entering the following command.
sudo apt-get update & sudo apt-get install elasticsearch
Method 2. Download and Install Debian package using wget
At the time of writing this article the current version of elastic search is
7.3.1. First, we need to download the package using the following command
Once you finished with downloading enter the following command to install the elastic search Debian package
sudo dpkg -i elasticsearch-7.3.1-amd64.deb
In case if you get any error while installation use
sudo apt-get install -f to force to install the required library and packages.
By default, all the configuration of the Elasticsearch can be found at
/etc/elasticsearch. This path contains several files:
- elasticesearch.yml: This file contains all the Elasticsearch server setting.
- Logging.yml: This file contains the configuration of the log. By default, you can find the log file of elastic search at
Next, edit the
elasticsearch.yml file and set the configuration as mentioned below. By default, the following variables will be commented, uncomment and set the variable.
cluster.name: clusterOne node.name: "Your own node name"
Once this is done, Enable and start the elastic search server
sudo service elasticsearch start
# Testing Elasticsearch
To test the elasticsearch enter the following command.
curl -X GET http://localhost:9200