This is a tutorial on how to install and Configure Elasticsearch on CentOS 8, 7 step by step. In today’s world of technology, large amounts of data are generated every day at approximately 2.5 quintillion bytes or about 2.5 billion bytes. This information comes mainly from a variety of sources, such as mass media sites, video-sharing sites, and media for large organizations. This data is called the ocean of data or, more generally, the Big Data. A significant portion of this data is unstructured and fragmented, and one needs analytical tools to understand it. There are many analytical tools on the market that can be used to review, record, analyze, and process this data. One of the most widely used tools is Elasticsearch. So in this article, we want to teach you about Tutorial Configure Elasticsearch on CentOS 8.
Elasticsearch is a product of a company called Elastic, which was founded in 2012. Elasticsearch, a search engine developed in Java, is an open-source tool. It is designed to handle unstructured data from different sources and store it in an optimized format for efficient text search. At its core, Elasticsearch utilizes Lucene Apache for indexing and searching purposes. Lucene is a really complicated library to work with; Elasticsearch eliminates all the hassle by providing API usability. The API is a RESTful HTTP API that uses JSON as the data exchange format; As a result, using Elasticsearch, a large amount of data can be stored and analyzed quickly and efficiently. This is especially useful when dealing with semi-structured natural language data.
Applications with complex search requirements, like big e-commerce stores and analytic applications, often rely on Elasticsearch as their search engine of choice. Elasticsearch has gained significant popularity due to its ability to power such applications effectively. There are many benefits to using Elasticsearch. One of these advantages is its scalability, which means that as the volume of data increases, the performance remains very simple and the results are reliable. Elasticsearch uses reverse indexing. Reverse indexing is a word-based method used to quickly search for documents containing a particular word. Another feature of Elasticsearch is that it is multilingual.
First, you must install the Java application because Elasticsearch is a Java application. Then if Java is installed, check its version using the Java grammar in CMD.
You should run the following command as a user or root with the Sudo privileges command to install the OpenJDK:
Sudo dnf install java-11-OpenJDK-devel
Then you must also print the Java version to verify the Java installation:
java -version
The output should be as follows:
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)
First, you can download Elasticsearch directly from the Elastic site. Because rpm installs everything you need to run Elasticsearch, you should use the rpm package for CentOS 8 Linux VPS.
The first step is to import the repository’s GPG using the following command:
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Then you need to open your text editor by executing the following command and create the repository file in the /etc/yum.repos.d directory:
sudo nano /etc/yum.repos.d/elasticsearch.repo
You should now paste the following commands in the file:
[elasticsearch-7.x] name=Elasticsearch repository for 7.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
In order for the changes you made to take effect, you must save the file and exit it.
Next, you need to install the Elasticsearch package using the following command:
sudo dnf install elasticsearch
Now that you have successfully completed the installation process, you can start and activate the service by running the following command:
sudo systemctl enable elasticsearch.service --now
To check if Elasticsearch is running, you can use the following command. Note that you can use curl to send an HTTP request to port 9200 on localhost:
curl -X GET "localhost:9200/"
Finally, you can view the messages recorded by the Elasticsearch service using the following command:
sudo journalctl -u elasticsearch
In this section, we will look at how to configure Elasticsearch. Note that Elasticsearch data is stored in the /var/lib/elasticsearch directory. Configuration files are also in /etc/elasticsearch. It should note that by default, Elasticsearch is configured to listen only on localhost. So if the client connected to the database also runs on the same host and you are setting up a single cluster, there is no need to change the default configuration file.
You must configure your firewall to allow remote access to the Elasticsearch server. It is, therefore, necessary to grant access to the Elasticsearch port 9200 only through trusted clients. Suppose you want to allow connection only through IP 123.456.789.01 on port 9200. This command is enabled using the following commands:
sudo firewall-cmd --new-zone=elasticsearch --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --zone=elasticsearch --add-source=123.456.789.01/32 --permanent
sudo firewall-cmd --zone=elasticsearch --add-port=9200/tcp --permanent
sudo firewall-cmd --reload
If you want to allow access through another IP address, you can use the following commands:
sudo firewall-cmd --zone=elasticsearch --add-source=<IP_ADDRESS> --permanent
sudo firewall-cmd --reload
Save and exit the configuration file to apply the changes.
If you want to allow Elasticsearch to listen to external connections, you must open the Elasticsearch configuration file using the editor you want:
sudo nano /etc/elasticsearch/elasticsearch.yml
Then in the next step, you have to search for the line that contains network.host. Then uncomment it and change its value to 0.0.0.0:
network.host: 0.0.0.0
You may have multiple network interfaces on your device. In this case, you must specify the IP address of the interface to force Elasticsearch to listen only to the given interface. Finally, restart the system using the following command to apply the changes:
sudo systemctl restart elasticsearch
Elasticsearch is a powerful engine with high capabilities for data search and analysis. In this article, we first introduced Elasticsearch and then explained how to install and configure it step by step.
How useful was this post?
Click on a star to rate it!
Average rating 0 / 5. Vote count: 0
No votes so far! Be the first to rate this post.
V2Ray is a powerful and flexible open-source network proxy that allows you to bypass internet censor...
If you are one of the online businesses that provide hosting services to your customers, you may enc...
What is your opinion about this Blog?