How to install Elasticsearch on CentOS 8

This article was first published in: https://www.itcoder.tech/posts/how-to-install-elasticsearch-on-centos-8/

Elasticsearch is an open source full-text search and analysis engine. It supports RESTful operations, and allows you to store, search, and analyze large amounts of data in real time. Elasticsearch is one of the most popular search engines that can power applications with complex search requirements, such as large e-commerce stores and analytics applications.

This article mainly involves installing Elasticsearch on CentOS 8.

One, install Java

Elasticsearch is a Java application, so the first step is to install Java.

Run the following command as root or another sudo user to install the OpenJDK package:

sudo dnf install java-11-openjdk-devel

Verify the Java installation by printing the Java version:

java -version

The output will look like this:

openjdk version "11.0.5"2019-10-15 LTS

OpenJDK Runtime Environment 18.9(build 11.0.5+10-LTS)

OpenJDK 64-Bit Server VM 18.9(build 11.0.5+10-LTS, mixed mode, sharing)

Two, install Elasticsearch

Elasticsearch is not available in the standard CentOS 8 source. We will install it from the Elasticsearch RPM source.

Use the rpm command to import the source GPG:

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

Open your text editor and create the source file in the /etc/yum.repos.d directory:

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

Paste the following content into the file:

[ elasticsearch-7.x]

name=Elasticsearch repository for7.x packages

baseurl=https://artifacts.elastic.co/packages/7.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.

Now that the source is enabled, install the Elasticsearch package and enter:

sudo dnf install elasticsearch

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

sudo systemctl enable elasticsearch.service --now

To verify that Elasticsearch is running, use the curl command to send an HTTP request to the local port 9200:

curl -X GET "localhost:9200/"

The output will look like this:

{" name":"centos8.localdomain","cluster\_name":"elasticsearch","cluster\_uuid":"V\_mfjn2PRJqX3PlZb\_VD7w","version":{"number":"7.6.0","build\_flavor":"default","build\_type":"rpm","build\_hash":"7f634e9f44834fbc12724506cc1da681b0c3b1e3","build\_date":"2020-02-06T00:09:00.449973Z","build\_snapshot":false,"lucene\_version":"8.4.0","minimum\_wire\_compatibility\_version":"6.8.0","minimum\_index\_compatibility\_version":"6.0.0-beta1"},"tagline":"You Know, for Search"}

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

To view information about the Elasticsearch service, use the following command:

sudo journalctl -u elasticsearch

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

<!- - ad-->

Three, configure Elasticsearch

Elasticsearch data is stored in the /var/lib/elasticsearch directory, and the configuration file is in /etc/elasticsearch.

By default, Elasticsearch is configured to only listen on localhost. If the database that the client connects to is on the same host, and you set up a single-node cluster, you do not need to modify the default configuration file.

3.1 remote access###

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

For example, to only allow access from 192.168.121.80, enter the following command:

Run the following command to allow access to port 9200 from a remote trusted IP address:

sudo firewall-cmd --new-zone=elasticsearch --permanent

sudo 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
Don&#39;t forget to`192.168.121.80`Modify it to your remote IP address.

Later, if you want to allow access from other IP addresses, 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 modify the Elasticsearch configuration file and allow Elasticsearch to monitor external connections.

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

sudo nano /etc/elasticsearch/elasticsearch.yml

Search contains network.host, remove the comment, and modify it to:

network.host:0.0.0.0

If you have multiple network interfaces, specify the interface IP address to force Elasticsearch to only listen on the specified network interface.

Restart the Elasticsearch service to make the changes take effect:

sudo systemctl restart elasticsearch

that's it. You can now connect to the Elasticsearch server from a remote location.

Four, summary##

We have shown how to install Elasticsearch on CentOS 8.

< hr/>

< hr/>

< hr/>

If you have any questions, please contact us in the following ways:

WeChat: sn0wdr1am86

WeChat group:

Add the above WeChat, note the WeChat group

QQ: 3217680847

QQ Group: 82695646

Recommended Posts

How to install Elasticsearch on CentOS 8
How to install Elasticsearch on CentOS 8
How to install and configure Elasticsearch on CentOS 7
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on CentOS 8
How to install Elasticsearch on Ubuntu 20.04
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
Install Elasticsearch 6 on centos7
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&amp;D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
How to install offline JDK1.8 on centos7.0
Install ElasticSearch 7.x on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7
How to install RPM packages on CentOS Linux
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Elasticsearch on Ubuntu 16.04
How to install and configure Redis on CentOS 8
How to install Node.js and npm on CentOS 8
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and configure phpMyAdmin on CentOS 6
How to install and use Curl on CentOS 8
How to install and configure Owncloud on CentOS 8