Install ElasticSearch on Ubuntu

Chưa phân loại
In this quick post, we will see how we can install one of the most popular text indexing and search platforms, Elasticsearch on Ubuntu and start using it as well. We will get started now.

Elasticsearch Database

Elasticsearch is one of the most popular NoSQL databases which is used to store and search for text based based data.

Elasticsearch is based on the lucene indexing technology and allows for search retrieval in milliseconds based on data that is indexed. It supports database queries through REST APIs. This means that we can use simple HTTP calls and use HTTP methods like GET, POST, PUT, DELETE etc. to access data.

 Installing Java

To install Elasticsearch on Ubuntu, we must install Java first. Java might not be installed by default. We can verify it by using this command:

java version

When we run this command, we get the following output:

We will now install Java on our system. Use this command to do so:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Once these commands are done running, we can again verify that Java is now installed by using the same command.

Installing Elasticsearch

Now, installing Elasticsearch is just a matter of few commands. To start, download the Elasticsearch package file from ES page:


When we run the above command, we will see the following output:

Next we can install the downloaded file the dpkg command:

sudo dpkg -i elasticsearch-1.7.2.deb

When we run the above command, we will see the following output:

Make sure that you download the deb package only from the ES website.

The config files for Elasticsearch will be stored at /etc/elasticsearch.  To make sure that Elasticsearch is started and stopped with the machine, run the following command:

sudo update-rc.d elasticsearch defaults

Configuring Elasticsearch

We have an active installation for Elasticsearch now. To use Elasticsearch effectively, we can some important changes to the configuration. Run the following command to open the ES config file:

sudo nano /etc/elasticsearch/elasticsearch.yml

We first modify the and in elasticsearch.yml file. Remember to remove the # before each line you want to edit to unmark it as a comment.

Modify these properties:

Once you’re done with all the config changes, start the ES server first time:

sudo service elasticsearch start

When we run this command and check the service status, we get the following output:

Using Elasticsearch

Now that Elasticsearch has started, we can start using it for our commands.

To see the instance details and the cluster information, run the following command:

curl -X GET ‘http://localhost:9200’

You may have to install curl, do it so using this command:

sudo apt-get install curl

When we run this command, we get the following output:

Now, we can try inserting some data into ES using the following command:

curl -X POST ‘http://localhost:9200/linuxhint/hello/1’ -H ‘Content-Type: application
-d ‘{ "name" : "LinuxHint" }’

When we run this command, we get the following output:

Let’s try getting the data now:

curl -X GET ‘http://localhost:9200/linuxhint/hello/1’

When we run this command, we get the following output:


In this quick post, we learned how we can install Elasticsearch and run basic queries on it.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

50 Best Free Online Python Tutorials

According to TIOBE Programming Community Index released in August 2019 for the most popular programming languages, Python...

How to Use fdisk in Linux

fdisk is a tool for partitioning hard drives (HDDs), solid state drives (SSDs), USB thumb drives etc. The best thing about...

Uninstall Ubuntu and Debian packages with apt-get and dpkg

We already saw how to create Debian packages, now we’ll see how to remove them. Removing packages in Debian or Ubuntu...
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh

Mua proxy Onet uy tín tại

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?