How to Install ElasticSearch on Ubuntu
ElasticSearch is one of the most well-known open-source distributed search and analytics engines. It is commonly used for applications that have advanced search requirements. Huge e-commerce stores, for example, are known to make quite an extensive use of it.
In this tutorial, we’ll go over how to install ElasticSearch on your Ubuntu server.
Install ElasticSearch on Ubuntu:
Start with importing the repository GPG key, and installing the ElasticSearch server. Also, note that you do not have to separately install Java because the ElasticSearch bundle comes with a bundled version of OpenJKD. But, you might want to update the packages index and install the dependencies essential for adding a new HTTPS repository first by entering first:
sudo apt update sudo
apt install apt-transport-https ca-certificates wget
After that use the following to Import the repository’s GPG key:
wget -qO – https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add –
That should give OK as output – confirming that the key has been imported and packages from this repository will be deemed trusted.
Proceed by adding ElasticSearch repository to the system by entering:
sudo sh -c ‘echo “deb https://artifacts.elastic.co/packages/7.x/apt stable main” >
Once that is done, you can easily install ElasticSearch by giving the following input:
sudo apt update sudo apt install elasticsearch
You still have to enable run with the following command because Elasticsearch service will not start automatically:
sudo systemctl enable –now elasticsearch.service
You can use curl to send an HTTP request to port 9200 on localhost to make sure Elasticsearch is running by entering the following command:
curl -X GET “localhost:9200/”
You may then have to wait a few seconds, but you should ideally see something resembling the following:
{
“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”
}
You may use the following to view the messages logged by the ElasticSearch service:
sudo journalctl -u elasticsearch
And voila! ElasticSearch has been installed.
Configuring ElasticSearch
The address for configuration files is /etc/elasticsearch and the Elasticsearch data itself is located in the /var/lib/elasticsearch directory. Java start-up options can be configured in the /etc/default/elasticsearch file.
It is noteworthy here that Elasticsearch is configured to listen on localhost by default, and so, the default configuration file need not be changed if you are setting up a single node cluster and the client connecting to the database is also running on the same host.
Looking for a reliable server hosting provider that supports ElasticSearch? Consider RackNerd’s server hosting solutions below.