Install Elasticsearch on CentOS 7,Elasticsearch is an open source disbursed complete-text seek and analytics engine. It supports RESTful operations and permits you to save, seek, and examine massive volumes of statistics in real time. Because Elasticsearch is one of the most famous search engines powering programs that have complicated seek requirements together with big e-trade stores and analytic packages.
This tutorial explains how to install Elasticsearch on CentOS 7.
Install Elasticsearch on CentOS 7,Prerequisites
The user you are logged in as must have sudo privileges to be able to install packages.
Install Elasticsearch on CentOS 7,Installing Elasticsearch
The endorsed manner to put in Elasticsearch on CentOS 7 is by way of putting in the rpm package from the reputable Elasticsearch repository.
Furthermore At the time of writing this newsletter, the today’s version of Elasticsearch is 6.7 and requires Java eight or later. To set up OpenJDK eight for your CentOS machine 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)
As a result 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:
/etc/yum.repos.d/elasticsearch.repo
[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.
If you want to install a previous version of Elasticsearch, change 6.x
in the command above with the version you need.
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 also take five-10 seconds for the service to start. If you see curl: (7) Failed to connect with localhost port 9200: Connection refused, look ahead to a few seconds and attempt once more.
To view the messages logged via the Elasticsearch provider you could use the command under:
sudo journalctl -u elasticsearch
At this point, you have Elasticsearch installed on your CentOS server.
Configuring Elasticsearch
Elasticsearch facts is saved in the /var/lib/elasticsearch listing, configuration files are located in /etc/elasticsearch.
By default, Elasticsearch is configured to concentrate on localhost most effective. If the client connecting to the database is likewise going for walks on the identical host and you’re putting in place a unmarried node cluster you don’t want to change the default configuration file.
Remote Access
Out of field Elasticsearch, does now not put in force authentication so it may be accessed via absolutely everyone who can get admission to the HTTP API. If you need to allow faraway get entry to for your Elasticsearch server, you will want to configure your firewall and permit get entry to to the Elasticsearch port 9200 simplest from trusted clients.
Starting with CentOS 7, FirewallD replaces iptables because the default firewall control tool.
Run the subsequent command to allow determine from the faraway depended on IP cope with on port 9200 :
sudo firewall-cmd –new-zone=elasticsearch –permanentsudo firewall-cmd –reloadsudo firewall-cmd –zone=elasticsearch –add-source=192.168.121.80/32 –permanentsudo firewall-cmd –zone=elasticsearch –add-port=9200/tcp –permanentsudo firewall-cmd –reload
Do not forget to change 192.168.121.80
with your remote IP Address.
Later, if you want to allow access from another IP Address use:
sudo firewall-cmd –zone=elasticsearch –add-source= –permanentsudo firewall-cmd –reload
Furthermore Once the firewall is configured the subsequent step is to edit the Elasticsearch configuration and allow Elasticsearch to listen for external connections.
To do so, open the elasticsearch.Yml configuration report:
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
:
/etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0
If you’ve got a couple of network interfaces on your gadget you could specify the interface IP address a good way to motive Elasticsearch to pay attention only on the required interface.
Restart the Elasticsearch service for the adjustments to take effect:
sudo systemctl restart elasticsearch
That’s it. You can now connect to the Elasticsearch server from your remote location.