How to install Elasticsearch on Ubuntu 20.04

Elasticsearch is an open source full-text search and analysis engine. It supports RESTful operations, and allows you to store, search, and analyze large amounts of data in real time. Elasticsearch is one of the most popular search engines that can power applications with complex search requirements, such as large e-commerce stores and analytics applications.

This guide explains how to install Elasticsearch on Ubuntu 20.04.

One, install Elasticsearch

Installing Elasticsearch on Ubuntu is very straightforward. We will enable the Docker software source, import the GPG key, and install Elasticsearch.

The Elasticsearch package is packaged with OpenJDK, so you don't need to install Java.

First, update the package index and install the necessary dependent packages to add a new Https software source:

sudo apt update
sudo apt install apt-transport-https ca-certificates wget

Import the GPG key of the software source:

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

The above command should output OK, which means that the key has been successfully imported and the package of this software source is also considered to be trusted.

Next, add Elasticsearch software source to the system, enter:

sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
If you want to install the previous version of Elasticsearch, change the`7.x`Replace with the version you need.

Once the software source is enabled, enter the following command to install Elasticsearch:

sudo apt update
sudo apt install elasticsearch

The Elasticsearch service will not start automatically after the installation is complete. Want to start the service and enable startup:

sudo systemctl enable --now elasticsearch.service

To verify that Elasticsearch is running, use curl to send an HTTP request to port 9200:

curl -X GET "localhost:9200/"

You should see something like this:

{" name":"vagrant","cluster_name":"elasticsearch","cluster_uuid":"IJqDxPfXSrmFQ27KbXbRIg","version":{"number":"7.8.0","build_flavor":"default","build_type":"deb","build_hash":"757314695644ea9a1dc2fecd26d1a43856725e65","build_date":"2020-06-14T19:35:50.234439Z","build_snapshot":false,"lucene_version":"8.5.1","minimum_wire_compatibility_version":"6.8.0","minimum_index_compatibility_version":"6.0.0-beta1"},"tagline":"You Know, for Search"}

It will take 5-10 seconds to start the service. If you see curl: (7) Failed to connect to localhost port 9200: Connection refused, please wait a few seconds and try again.

To view the messages recorded by the Elasticsearch service, use the following command:

sudo journalctl -u elasticsearch

that's it. Elasticsearch has been installed on your Ubuntu machine.

Two, configure Elasticsearch

Elasticsearch data is stored in the /var/lib/elasticsearch directory. The configuration file is located in /etc/elasticsearch and the Java startup options can be configured via the /etc/default/elasticsearch file.

By default, Elasticsearch is configured to only listen on localhost. If the client connecting to the database is also on this machine, you can set up a simple node cluster without modifying the default configuration file.

2.1 remote access###

Elasticsearch, available out of the box, does not implement authorization, so it can be accessed by anyone through HTTP API.

To allow remote access to your Elasticsearch server, you will need to configure your firewall and open TCP port 6379.

Normally, you will only allow access to the server from a specified IP or specified IP range. For example, to only allow access from the 192.168.121.0/24 subnet, you would allow the following command:

sudo ufw allow proto tcp from192.168.121.0/24 to any port 6379

Once the firewall is configured, the next step is to edit the Elasticsearch configuration file and allow Elasticsearch to listen for other connections.

To do this, open the elasticsearch.yml configuration file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Search for the line that includes network.host, uncomment it, and modify the value to 0.0.0.0:

network.host:0.0.0.0

If there are many network interfaces on your machine, specify the interface IP address to force Elasticsearch to only listen on the specified interface.

Restart the Elasticsearch service to make the application take effect:

sudo systemctl restart elasticsearch

that's it! , Now you can connect to the Elasticsearch server from your remote location.

Three, summary##

We have shown you how to install Elasticsearch on Ubuntu 20.04.

To learn more about Elasticsearch, please Browse the official documentation page.

Recommended Posts

How to install Elasticsearch on Ubuntu 20.04
How to install and configure Elasticsearch on Ubuntu 16.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Elasticsearch on CentOS 8
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Elasticsearch on CentOS 8
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to install Bacula Server on Ubuntu 14.04
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ubuntu 19.10 on Raspberry Pi 4