
Hello Readers !!! Hope you all are doing well . Again I am here with a new post and In this post we’ll see How we can configure Elasticsearch To Run On Localhost . Firstly , we’ll see what is elastic search and how we can install it and after that we;ll configure elasticsearch on our local .
So, let’s get started !!!
Introduction
What is ElasticSearch
Elasticsearch is a distributed, open-source, cost-free search and analytics platform for text, numbers, geographic, structured, and unstructured data. Built on Apache Lucene, Elasticsearch was first made available in 2010 by Elasticsearch N.V. (now known as Elastic).
It is called as the centrepiece of the Elastic Stack, a collection of free and open technologies for data intake, enrichment, storage, analysis, and visualisation, is renowned for its straightforward REST APIs, distributed nature, speed, and scalability.
The Elastic Stack, often known as the ELK Stack (after Elasticsearch, Logstash, and Kibana), now supports a wide range of lightweight shipping agents called Beats for transmitting data to Elasticsearch.
Installation
Elasticsearch is a platform for distributed search and analysis of data in real time .
Prerequisites
An Ubuntu 22.04 server with 2GB RAM and 2 CPUs set up
Java
if java is not install , you can install it from here Click OR run below command as :
sudo apt install openjdk-8-jdk
java version
Here , are the installation steps that we have to install ElasticSearch . These are as follows :
STEP 1 install an APT transport package
To allow access to your repositories via HTTPS, you need to install an APT transport package by running command :
sudo apt install apt-transport-https



STEP 2 Add ElasticSearch Repository
First we need to update the GPG Key for the elastic search repository . Use the below command to do so :
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key
add -
Next, use the below command to add the repository to your system .
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo
tee -a /etc/apt/sources.list.d/elastic-7.x.list



STEP 3 Install ElasticSearch
Now , let’s install elasticsearch , update the packages by running the command :
sudo apt update



run the installation command as :
sudo apt install elasticsearch



STEP 4 Start ElasticSearch Service
Once installed , you need to start the elasticsearch service . First reload the daemon and after that enable the elasticsearch service as :
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service



and finally run :
sudo systemctl start elasticsearch
sudo systemctl status elasticsearch



Configuration
Now , the most important thing that we have to configure elasticsearch . To make changes to the default Elasticsearch configuration, edit the elasticsearch.yml file. The file is located in the directory:
cd /etc/elasticsearch
and the configuration for logging is located in the:
cd /var/log/elasticsearch/logging.yml file
Allow Remote Access
The default configuration does not allow your machine to be accessed by other hosts. To allow remote access, use a text editor of your choice and open the elasticsearch.yml file as :
sudo su
cd /etc/elasticsearch/
nano elasticsearch.yml



Scroll down to the Network section. Find the line that says #network.host
.
Uncomment the line (remove the pound (#) sign), set the IP address to 127.0.0.1 , and add these lines:
check for the lines says #discovery.seed_hosts: [“Host1” , “Host2”]
Uncomment the line (remove the pound (#) sign) , and remove host1 , host2 from the bracket .



also uncomment #http.port: 9200
Now make changes to the file located at :
cd /etc/elasticsearch/jvm.options



here , In this file you have to look for the line which says : #-Xms4g , #-xmx4g
Uncomment the line (remove the pound (#) sign) like this :



So , we are set , now restart the elasticsearch service and check status by :
sudo systemctl restart elasticsearch
sudo systemctl status elasticsearch
Test Elasticsearch
Now test the elasticsearch service by running the command on terminal as :
curl localhost:9200



OR you can hit on the browser as :
localhost:9200



All set !!! we are done . In this way we can install and configure ElasticSearch .
Conclusion
So, In this blog we have seen How we can Configure Elasticsearch To Run On Localhost and also we have seen what is elasticsearch and how we can install it . I hope this post is helpful for you all . Keep learning and keep shining . If you have any query , you can ask me .
Thank You !!!
Keep Learning !!!