Elasticsearch is a highly scalable, open-source full-text search and analytics engine. It is built on Apache Lucene and allows users to store, search, and analyze large volumes of data quickly and in near real-time. In this article, we will guide you through the process of installing and configuring Elasticsearch on a Fedora system.
Prerequisites
- A Fedora system
- Sudo or root privileges
- Basic knowledge of terminal commands
Step 1: System Update
Before installing any package, it is recommended to update your system’s package repository. Open a terminal and execute the following command:
sudo dnf update -y
Step 2: Install Java
Elasticsearch requires Java, so the next step is to install it. If you already have Java installed, you can skip this step.
sudo dnf install java-11-openjdk-devel
You can verify the installation using:
java -version
Step 3: Download and Install Elasticsearch
Option 1: Install from the official repository
First, import the Elasticsearch PGP key with the following command:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Next, create a new file called elasticsearch.repo in the /etc/yum.repos.d/ directory:
sudo nano /etc/yum.repos.d/elasticsearch.repo
Add the following lines to the file:
1 2 3 4 5 6 7 8 | [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 |
Save and close the file, then install Elasticsearch with:
sudo dnf install elasticsearch
Option 2: Install from the RPM package
Alternatively, you can download the RPM package from the official Elasticsearch website and install it using the rpm command:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.x.x-x86_64.rpm
sudo rpm -ivh elasticsearch-7.x.x-x86_64.rpm
Make sure to replace the 7.x.x with the actual version number.
Step 4: Configure Elasticsearch
You can adjust the settings of Elasticsearch by editing the /etc/elasticsearch/elasticsearch.yml file.
sudo nano /etc/elasticsearch/elasticsearch.yml
In a production environment, you might want to adjust the following settings:
- `network.host`: Set it to the IP address of your server.
- `http.port`: By default, Elasticsearch runs on port 9200. You can change this if needed.
- `cluster.name`: Name your Elasticsearch cluster. By default, it’s called “elasticsearch”.
After you’ve made your changes, save and close the file.
Step 5: Enable and Start Elasticsearch
After the installation and configuration, enable Elasticsearch to start on boot, and then start the service:
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
You can check the status of the service using:
sudo systemctl status elasticsearch
Step 6: Test Elasticsearch
Now that Elasticsearch is running, you can perform a quick test by sending an HTTP request to port 9200 on localhost:
curl -X GET "localhost:9200"
The output will contain information about the installed Elasticsearch, including the name, version, and more.
Output:{ "name" : "tecadmin", "cluster_name" : "elasticsearch", "cluster_uuid" : "HY8HoLHnRCeb3QzXnTcmrQ", "version" : { "number" : "7.9.2", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e", "build_date" : "2020-09-23T00:45:33.626720Z", "build_snapshot" : false, "lucene_version" : "8.6.2", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
Conclusion
n this article, we’ve shown you how to install and configure Elasticsearch on Fedora. We also discussed some basic configuration options that you can adjust according to your needs. Remember, Elasticsearch is a powerful tool that can handle huge amounts of data. Make sure to study its documentation to understand its full potential.