Jump to content

Recommended Posts

  • Superior Administrator
Posted

Elasticsearch is an open source distributed full-text search and analytics engine. It supports RESTful operations and allows you to store, search, and analyze big volumes of data in real time. Elasticsearch is one of the most popular search engines powering applications that have complex search requirements such as big e-commerce stores and analytic applications.

 

This tutorial explains how to install Elasticsearch on CentOS 7.

 

Prerequisites

 

The user you are logged in as must have sudo privileges to be able to install packages.

 

Installing Elasticsearch

The recommended way to install Elasticsearch on CentOS 7 is by installing the rpm packagefrom the official Elasticsearch repository.

 

At the time of writing this article, the latest version of Elasticsearch is 6.7 and requires Java 8 or later.

 

To

This is the hidden content, please
8 on your CentOS system type:

 

sudo yum install java-1.8.0-openjdk-devel

 

Verify the Java installation by printing the Java version:

 

java -version

 

The output should look something like this:

 

openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Superior Administrator
Posted

Now that Java is installed, the next step is to add the Elasticsearch repository.

 

Import the repository’s GPG key using the following command:

 

sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

 

Open your text editor and create the following repo file:

 

sudo nano /etc/yum.repos.d/elasticsearch.repo

 

Paste the following content into the file:

 

[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

 

Save the file and close your text editor.

 

You can now install the Elasticsearch package by typing:

 

sudo yum install elasticsearch

 

Once the installation process is complete, start and enable the service by running:

 

sudo systemctl enable elasticsearch.servicesudo systemctl start elasticsearch.service

 

You can verify that Elasticsearch is running by sending an HTTP request to port 9200 on localhost with the following curl command:

 

curl -X GET "localhost:9200/"

 

The output will look similar to the following:

 

{
 "name" : "fLVNqN_",
 "cluster_name" : "elasticsearch",
 "cluster_uuid" : "6zKcQppYREaRH0tyfJ9j7Q",
 "version" : {
   "number" : "6.7.0",
   "build_flavor" : "default",
   "build_type" : "rpm",
   "build_hash" : "8453f77",
   "build_date" : "2019-03-21T15:32:29.844721Z",
   "build_snapshot" : false,
   "lucene_version" : "7.7.0",
   "minimum_wire_compatibility_version" : "5.6.0",
   "minimum_index_compatibility_version" : "5.0.0"
 },
 "tagline" : "You Know, for Search"
}

 

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

 

To view the messages logged by the Elasticsearch service you can use the command below:

 

sudo journalctl -u elasticsearch

 

At this point, you have Elasticsearch installed on your CentOS server.

  • Superior Administrator
Posted

Configuring Elasticsearch

 

Elasticsearch data is stored in the /var/lib/elasticsearch directory, configuration files are located in /etc/elasticsearch.

 

By default, Elasticsearch is configured to listen on localhost only. If the client connecting to the database is also running on the same host and you are setting up a single node cluster you don’t need to change the default configuration file.

 

Remote Access

Out of box Elasticsearch, does not implement authentication so it can be accessed by anyone who can access the HTTP API. If you want to allow remote access to your Elasticsearch server, you will need to configure your firewall and allow access to the Elasticsearch port 9200 only from trusted clients.

 

Starting with CentOS 7, FirewallD replaces iptables as the default firewall management tool.

 

Run the following command to allow assess from the remote trusted IP address on port 9200 :

 

sudo firewall-cmd --new-zone=elasticsearch --permanentsudo firewall-cmd --reload
sudo firewall-cmd --zone=elasticsearch --add-source=192.168.121.80/32 --permanent
sudo firewall-cmd --zone=elasticsearch --add-port=9200/tcp --permanent
sudo firewall-cmd --reload

 

[iCODE]Do not forget to change 192.168.121.80 with your remote IP Address. [/iCODE]

 

Later, if you want to allow access from another IP Address use:

 

sudo firewall-cmd --zone=elasticsearch --add-source=<IP_ADDRESS> --permanent
sudo firewall-cmd --reload

 

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

 

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

 

sudo nano /etc/elasticsearch/elasticsearch.yml

 

Search for the line that contains network.host, uncomment it, and change the value to 0.0.0.0

 

network.host: 0.0.0.0

 

If you have multiple network interfaces on your machine you can specify the interface IP address which will cause Elasticsearch to listen only on the specified interface.

 

Restart the Elasticsearch service for the changes to take effect:

 

sudo systemctl restart elasticsearch

 

That’s it. You can now connect to the Elasticsearch server from your remote location.

 

Conclusion

You have successfully installed Elasticsearch on your CentOS 7

 

This is the hidden content, please

 

Credits to: Linuxize

 

This is the hidden content, please

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
×
GloTorrents Community Forum
Home
Activities
Sign In
Search
More
×