In this tutorial, we will look at how we can install Elasticsearch on Ubuntu 18.04. Elasticsearch is an open-source distributed full-text search and analytics engine. It supports RESTful operations (GET, POST requests) and allows you to store, search, and analyze big volumes of data in real-time.
Step 1: Install Prerequisites
Before installing Elasticsearch, we must first get its dependencies. The major dependency is OpenJDK 8 since this is an open-source Java application.
Let’s first update our system and install required packages so that apt
can download over https.
sudo apt update
sudo apt install apt-transport-https
Now, install OpenJDK 8 (Recommended) using the package manager.
sudo apt install openjdk-8-jdk
Otherwise, if you want to install the most recent version, you can install the latest version of Java.
Step 2: Download the Elasticsearch package
Now that we have our major dependencies installed, we must now download the latest version of Elasticsearch, found at the Elastic Downloads page.
The latest version is 7.5.1 at the time of writing.
Let’s download the Debian package (.deb) for our system.
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.1-amd64.deb
Let’s use wget
to fetch it from the remote server.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.1-amd64.deb
Step 3: Install Elasticsearch
We will install the Debian package using dpkg
package installer for Elasticsearch 7.5.1.
dpkg -i elasticsearch-7.5.1-amd64.deb

A similar output indicates that your installation was successful!
Now, let us configure Elasticsearch for it to work properly.
Step 4: Configure Elasticsearch
In our first step of configuration, we shall set the IP address of our Server.
The Elasticsearch configuration file is available at /etc/elasticsearch/elasticsearch.yml.
Open your favorite text editor and edit this file.
sudo vi /etc/elasticsearch/elasticsearch.yml
Go to the Network Module.

By default, the Network host address is not set. Set it by uncommenting the corresponding line and setting it to the desired IP Address.
After editing, your file will look like this:

Save changes and exit the editor.
Now, we have finished our bare-bones setup of Elasticsearch. We now just need to start our server!
Step 5: Enable the Elasticsearch service
Start and enable the Elasticsearch service using systemctl
:
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
Now that we have started our server, we can now send requests to the Server to verify that it is working properly.
Step 6: Test the server
You can verify that Elasticsearch is running by sending an HTTP request to port 9200 to your Server address (Mine is 192.168.0.1)
curl -X GET "192.168.0.1:9200/"
We will get an output response from the Server. It will look similar to this:
{
"name" : "BEwpV2R",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "T-3S34LRQFqDeIGwQgD1xw",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "d7d56a7",
"build_date" : "2020-01-03T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "7.3.0",
"minimum_index_compatibility_version" : "7.3.0-beta1"
},
"tagline" : "You Know, for Search"
}
Now that our server is working properly, we have successfully configured our Elasticsearch service, and we are now ready to use it!
Conclusion
In this tutorial, we learned how we could setup and install Elasticsearch on our Ubuntu 18.04 machine in just a few simple steps.
Thanks for valuable info on elastic search.