Easily install ElasticSearch on Ubuntu

Elasticsearch is an open-source & very powerful application for analytics & distributed real-time searches. It is published under the Apache 2 license which means complete flexibility. It is very popular as well due to ease of use, scalability & its features like enhanced experience with security, monitoring, alerting, reporting, graph exploration, machine learning, etc.

Elasticsearch uses standard RESTful APIs and JSON, which allows the ability for full-text searches. All these things make it a popular tool to be used for application searches, Security analytics, logging & other metrics purposes.

Recommended Read: Important Logs to monitor to identify issues in the Linux system

Also Read: Installing Awstat for analyzing Apache logs

In this tutorial, we are going to discuss the process to install Elasticsearch on Ubuntu. So let’s start with pre-requisites,

Pre-requisites

We need to have Java 8 installed to install Elasticearch on Ubuntu systems. You can check if Java is installed or not, using the following command,

$ java -version

If you don’t have java installed on your system, then you can run the following commands to install it. First, add the repo,

$ sudo apt-get install software-properties-common

$ sudo add-apt-repository ppa:webupd8team/java

then run the update,

$ sudo apt-get update

Next, install java with the following command,

$ sudo apt-get install oracle-java8-installer

That’s it, Java is now installed on your system. Now we will proceed to the next step,


Install Elasticsearch on Ubuntu

Now we download the zip, tar, packages or can also installed elasticsearch using the package manager tool like apt-get. For this tutorial, we will be installing using deb package as well as an installation with apt-get as well.

Installing .deb package

Download the latest stable version of the elasticsearch (version 7.0.0, at the time of writing this tutorial), using the following command,

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-amd64.deb

Then to install it run the following command,

$ sudo dpkg -i elasticsearch-7.0.0-amd64.deb

Installing using apt-get

First, download and install the public signing key for elasticsearch,

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

Next, we need to install the following package,

$ sudo apt-get install apt-transport-https

Now, we will add the repo to our Ubuntu system with the following command,

$ echo “deb https://artifacts.elastic.co/packages/7.x/apt stable main” | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

Now, install Elasticsearch on Ubuntu system,

$ sudo apt-get update && sudo apt-get install elasticsearch

That’s it, elasticsearch will then be installed on our system. To run it, we will use the command,

$ sudo systemctl start elasticsearch

& will also enable to it to run at system boot-up,

$ sudo systemctl enable elasticsearch


Configuring Elasticsearch

All the configuration related files for elasticseach can be found under folder ‘/etc/elasticsearch’, but we need to edit one file only i.e. elasticsearch.yml. Open the file with your editor of choice,

$ sudo vim /etc/elasticsearch/elasticsearch.yml

& change for following,

network.host: 0.0.0.0

This is done to make sure that elasticsearch listens to all interfaces & is publically available. Next change the following,

cluster.name: TEST_Cluster

This assigns a name to the cluster. This is especially necessary if we have a multi-node cluster, as all nodes must use the same cluster name. Next, we will update the node name, so change the following,

node.name: “Test_Node_1”

Now save the file & exit. Restart the elasticsearch to implement the changes made to the configuration file,

$ sudo systemctl restart elasticsearch


Testing Elasticsearch

Now to test the elasticsearch if it’s working or not, we can simply use the curl command,

$ curl -X GET http://10.10.1.10:9200

Where 10.10.1.10 is the IP address for the server where we have installed elasticsearch & 9200 is the default port number for elasticsearch. If the configuration made are right you should get output. Something like,

install ElasticSearch on Ubuntu

This completes our tutorial on how to install Elasticsearch on Ubuntu. Please feel free to send in any questions or comments using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of your hard earned money:

Linux TechLab is thankful for your continued support.

Shusain

Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *