Elasticsearch is a powerful real-time search engine. It is a free, open-source analytics application capable of storing and recalling big data in real-time. It’s an excellent option for anyone searching through large amounts of data regularly.
The easiest way to install Elasticsearch is from their repositories instead of the OS default repos. Check the installation steps below:
Since Elasticseach is written in Java, so before anything else, you will need to install a Java Runtime Environment (JRE) on your server. You can use the native CentOS OpenJDK package for the JRE:
yum install java
You can get the installed Java version(Current Java version 1.8.0_73 ) by running the following command:
java -version - - - - - - - - - - - - - - - - - - - - - - - - - - OR FOR THE CURRENT LATEST VERSION: yum install java-1.8.0-openjdk.x86_64
Once Java is installed, verify the verify your JRE is installed and can be used, run the command:
java -version openjdk version "1.8.0_262" OpenJDK Runtime Environment (build 1.8.0_262-b10) OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
Downloading and Installing Elasticsearch:
The next step is to download Elasticsearch's RPM package and then install it on the server: ( Please keep in mind that here we are using the current location of the Elasticsearch RPM package for an earlier version only for demonstration purposes ):
Before installing Elasticsearch, add the elastic.co key to the server:
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Next, add the Elastic repository. Use your preferred text editor to create the file elasticsearch.repo in the /etc/yum.repos.d/ directory. Here, we’ll use the vi text editor:
sudo vi /etc/yum.repos.d/elasticsearch.repo
To provide yum with the information it needs to download and install the components of the Elastic Stack, enter insert mode by pressing i and add the following lines to 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
When you’re finished, press ESC to leave insert mode, then:wq and ENTER to save and exit the file. The next step is to install Elasticsearch with the following command:
sudo yum install elasticsearch
Once Elasticsearch is finished installing, open its main configuration file,
elasticsearch.yml</code., in your editor:
sudo vi /etc/elasticsearch/elasticsearch.yml
Elasticsearch listens for traffic from everywhere on port 9200. You will want to restrict outside access to your Elasticsearch instance to prevent outsiders from reading your data or shutting down your Elasticsearch cluster through the REST API. Find the line that specifies network.host, uncomment it, and replace its value with localhost so it looks like this:
. . . network.host: localhost . . .
Now that we are done with the installation process, you can run the Elasticsearch service. That's it.