Install ElasticSearch on Ubuntu

28/12/2020
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:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.deb

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 node.name and cluster.name 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
/json’
-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:

Conclusion

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

How to Use Docker Registry

Docker is a technology which allows one to create virtual machines which encapsulate applications and all its dependences...
28/12/2020

QOwnNotes 17.03.7 released, Install QOwnNotes on Linux

Are you looking for a simple note taking editor, then checkout QOwnNotes. QOwnNotes is an open source plain-text file notepad editor,...
28/12/2020

Install Linux Mint MATE

Linux Mint is definitely one of the finest Linux distros out there. It’s suitable for both newbies and veterans. In fact,...
29/12/2020
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
03/06/2024

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

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

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

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