This brief tutorial shows students and new users how to install and configure Elasticsearch on Ubuntu 20.04 | 18.04.
Elasticsearch is an open-source, Java-based search engine that provides a distributed, scalable and speedy search and analytics platform via an HTTP web interface, schema-free JSON-style documents, and built on the Apache Lucene library.
For businesses looking for solutions to search their complex and big data, including eCommerce databases easily, Elasticsearch might be a good place to start.
For more about Elasticsearch, please check its homepage.
When you’re ready to install Elasticsearch on Ubuntu, please follow the steps below:
Install OpenJDK 8
Elasticsearch is based on Java and requires Java to be installed. You can either install Oracle Java Standard EditionĀ 8 or the open-source version of OpenJDK 8.
For this tutorial, we will install OpenJDK 8 on Ubuntu. To do that, run the commands below:
sudo apt update sudo apt install openjdk-8-jdk
After that run the commands below to see if Java is successfully installed.
java -version
You should see a similar message as shown below:
openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
When you see the above message, then OpenJDK 8 is installed successfully.
Install Elasticsearch
Now that OpenJDK 8 is installed, run the commands below to add the Elasticsearch GPG key by importing it.
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
After importing its GPG key, run the commands below to add its package repository to Ubuntu.
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" > /etc/apt/sources.list.d/elastic-6.x.list'
At the time of writing this post, Elasticsearch version 6.6.1 is the latest. If you prefer previous versions, you will have to update the repository package list to include previous packages.
Once the Elasticsearch repository is added and enabled, run the commands below to update the apt package list and install Elasticsearch.
sudo apt update sudo apt install elasticsearch
After installing the Elasticsearch package, you can use the commands below to make sure it automatically starts up when the server boots up and start immediately.
sudo systemctl start elasticsearch.service sudo systemctl enable elasticsearch.service
Elasticsearch should be installed and ready to use.
Out of the box, there’s no authentication and anyone can access its portal via HTTP. It also only listens for traffic on the localhost via port # 9200
If you’re running a single host server and the client connecting from the same server, then no configuration is required. If the clients are connecting from remote systems, then you’ll want to allow external clients.
To do that, open the elasticsearch.yml configuration file:
sudo nano /etc/elasticsearch/elasticsearch.yml
Then search for the line that contains network.host, uncomment it, and change the highlighted value to 0.0.0.0
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
Save the file and exit.
When you’re done, restart Elasticsearchhttps://geekrewind.com/how-to-install-the-office-google-chrome-on-ubuntu-16-04-18-04/
sudo systemctl restart elasticsearch.service
That should do it!
Now open your browser and browse to the server hostname or IP address followed by port #9200. You should see the service respond with JSON data.
http://localhost:9200

Congratulations! You have successfully installed the Elasticsearch platform on Ubuntu 16.04 | 18.04 LTS servers.
You may also like the post below: