Fedora

How To Install Elasticsearch on Fedora 42

Elasticsearch is a distributed search and analytics engine built on Apache Lucene. It handles full-text search, structured queries, and real-time analytics at scale – making it the backbone of the Elastic Stack (ELK). This guide walks through installing Elasticsearch 8.x on Fedora 42 from the official Elastic repository.

Elasticsearch 8.x ships with security enabled by default – TLS encryption, authentication, and role-based access control are all turned on out of the box. We will install it on Fedora 42, configure the systemd service, open firewall ports, and verify the setup with curl. For full documentation, see the official Elasticsearch 8.x reference.

Prerequisites

  • A server or VM running Fedora 42 with at least 2GB RAM (4GB recommended for production)
  • Root or sudo access
  • Firewall ports: 9200/tcp (HTTP API), 9300/tcp (node communication)
  • Internet access to reach the Elastic package repository

Step 1: Install Java on Fedora 42

Elasticsearch 8.x bundles its own JDK, but having a system-wide Java installation is useful for related tools and plugins. Install OpenJDK 17 on Fedora along with a few helpful utilities.

sudo dnf install -y java-17-openjdk java-17-openjdk-devel lsof curl

Verify the Java version.

java -version

Expected output:

openjdk version "17.0.14" 2025-01-21
OpenJDK Runtime Environment (Red_Hat-17.0.14.0.7-1.fc42) (build 17.0.14+7)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.14.0.7-1.fc42) (build 17.0.14+7, mixed mode, sharing)

Step 2: Add Elasticsearch 8.x Repository

Import the Elastic GPG signing key first.

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

Create the Elasticsearch 8.x repository file.

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

Add the following content:

[elastic-8.x]
name=Elastic repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Press Ctrl+D after pasting to save and close. Alternatively, write the file directly.

echo '[elastic-8.x]
name=Elastic repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md' | sudo tee /etc/yum.repos.d/elasticsearch.repo

Verify the repository is available.

sudo dnf repolist | grep elastic

Step 3: Install Elasticsearch on Fedora 42

With the repository configured, install Elasticsearch.

sudo dnf install -y elasticsearch

During installation, Elasticsearch 8.x generates security credentials automatically. The installer output contains the superuser password, enrollment tokens, and TLS certificate fingerprint. Save this output – you will need the password shortly.

If you missed the installer output, reset the elastic superuser password.

sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i

You will be prompted to enter and confirm the new password.

Step 4: Configure Elasticsearch

The main configuration file is /etc/elasticsearch/elasticsearch.yml. For a single-node setup, the defaults work out of the box. Open the configuration file to review or customize settings.

sudo vi /etc/elasticsearch/elasticsearch.yml

Common settings to adjust for a single-node deployment:

# Cluster name - used to auto-discover nodes
cluster.name: my-cluster

# Node name - defaults to hostname
node.name: node-1

# Network - bind to localhost only (default) or specific IP for remote access
network.host: 0.0.0.0

# Discovery - single node mode
discovery.type: single-node

# Data and log paths (defaults are fine for most setups)
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

JVM heap size is configured separately in /etc/elasticsearch/jvm.options. The default is 1GB. For production, set it to half of available RAM (max 32GB).

sudo vi /etc/elasticsearch/jvm.options

Adjust the heap size lines:

-Xms2g
-Xmx2g

Step 5: Start and Enable Elasticsearch Service

Reload systemd to pick up the Elasticsearch unit file, then enable and start the service.

sudo systemctl daemon-reload
sudo systemctl enable --now elasticsearch

Verify the service is running.

$ systemctl status elasticsearch
 elasticsearch.service - Elasticsearch
     Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; preset: disabled)
     Active: active (running) since Fri 2026-03-21 10:15:32 UTC; 12s ago
       Docs: https://www.elastic.co
   Main PID: 2541 (java)
      Tasks: 89 (limit: 4543)
     Memory: 2.5G
        CPU: 48.231s
     CGroup: /system.slice/elasticsearch.service
             ├─2541 /usr/share/elasticsearch/jdk/bin/java ...
             └─2612 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Confirm Elasticsearch is listening on port 9200.

sudo lsof -i :9200

Step 6: Configure Firewall

If firewalld is active, open ports 9200/tcp (REST API) and 9300/tcp (inter-node communication). Port 9300 is only needed if you plan to run a multi-node Elasticsearch cluster.

sudo firewall-cmd --add-port=9200/tcp --permanent
sudo firewall-cmd --add-port=9300/tcp --permanent
sudo firewall-cmd --reload

Verify the ports are open.

sudo firewall-cmd --list-ports

Step 7: Test Elasticsearch with curl

Elasticsearch 8.x has TLS enabled by default. Query the API using the CA certificate and the elastic superuser credentials.

sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200

Enter the password when prompted. A successful response looks like this:

{
  "name" : "node-1",
  "cluster_name" : "my-cluster",
  "cluster_uuid" : "abc123XYZ...",
  "version" : {
    "number" : "8.19.13",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "...",
    "build_snapshot" : false,
    "lucene_version" : "9.12.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Check cluster health.

sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200/_cluster/health?pretty

Step 8: Create a Test Index

Create a sample index to confirm read and write operations work. This creates an index called test-index and adds a document.

sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic \
  -X POST "https://localhost:9200/test-index/_doc/1" \
  -H "Content-Type: application/json" \
  -d '{"name": "Elasticsearch on Fedora", "message": "Installation successful"}'

Retrieve the document to confirm it was indexed.

sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic \
  "https://localhost:9200/test-index/_doc/1?pretty"

Expected output:

{
  "_index" : "test-index",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "name" : "Elasticsearch on Fedora",
    "message" : "Installation successful"
  }
}

List all indices on the node.

sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic \
  "https://localhost:9200/_cat/indices?v"

Clean up the test index when done.

sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic \
  -X DELETE "https://localhost:9200/test-index"

For more on managing index data, see how to delete Elasticsearch index data with curl.

Conclusion

Elasticsearch 8.x is now running on Fedora 42 with TLS encryption and authentication enabled by default. The service is managed through systemd and the firewall is configured for API and cluster communication on ports 9200 and 9300.

For production deployments, consider setting up a multi-node cluster for high availability, configuring automated snapshots for backups, and deploying the rest of the Elastic Stack (Kibana, Logstash, Beats) for log aggregation and visualization. You can also add Filebeat and Logstash to build a complete log pipeline.

Related Articles

CentOS Install Node.js 22 LTS on Fedora 42/41/40 Fedora Fedora 41 vs Ubuntu 24.04 – Comparison Table CentOS Install PHP 8.4 on Fedora 42/41/40 Virtualization Automate RHEL and CentOS Installation on KVM using Kickstart

Press ESC to close