next
+=
+
+
sinatra
weaviate
vue
+
node
!
esbuild
hack
&
numpy
โˆซ
+
+
+
โŠ‚
+
tf
+
+
+
+
soap
+
swift
+
+
+
{}
dns
!
+
+
graphdb
!!
+
+
qdrant
+
gin
nim
+
java
cargo
hack
+
kali
bundler
composer
@
vite
koa
+
+
+
android
clickhouse
+
redhat
+
*
+
marko
+
azure
+
[]
+
+
surrealdb
mocha
==
+
+
http
swift
+
+
axum
+
+
soap
elixir
+
+
+
jenkins
Back to Blog
๐Ÿ” Elasticsearch Search & Analytics on AlmaLinux: Power Your Data Discovery
elasticsearch search almalinux

๐Ÿ” Elasticsearch Search & Analytics on AlmaLinux: Power Your Data Discovery

Published Aug 29, 2025

Master Elasticsearch on AlmaLinux! Learn installation, indexing, searching, Kibana dashboards, and clustering. Perfect beginner's guide to search analytics!

5 min read
0 views
Table of Contents

๐Ÿ” Elasticsearch Search & Analytics on AlmaLinux: Power Your Data Discovery

Welcome to the amazing world of search and analytics! ๐ŸŽ‰ Ready to search through millions of records in milliseconds? Elasticsearch is like having Googleโ€™s search power for your own data! Itโ€™s the engine that powers search for Netflix, Wikipedia, and GitHub! Think of it as your personal data detective! ๐Ÿ•ต๏ธโœจ

๐Ÿค” Why is Elasticsearch Important?

Elasticsearch revolutionizes how we find and analyze data! ๐Ÿš€ Hereโ€™s why itโ€™s incredible:

  • โšก Lightning Fast Search - Find anything in milliseconds, not minutes!
  • ๐Ÿ“Š Real-Time Analytics - Analyze data as it arrives instantly
  • ๐ŸŒ Full-Text Search - Search like Google across all your data
  • ๐Ÿ“ˆ Scalable to Petabytes - From laptop to data center seamlessly
  • ๐ŸŽฏ Smart Relevance - AI-powered search that understands context
  • ๐Ÿ›ก๏ธ Built for Reliability - Automatic failover and data redundancy

Itโ€™s like having a super-intelligent librarian who knows where everything is! ๐Ÿ“š

๐ŸŽฏ What You Need

Before diving into search paradise, ensure you have:

  • โœ… AlmaLinux server (8 or 9)
  • โœ… Root or sudo access
  • โœ… At least 4GB RAM (8GB recommended)
  • โœ… 20GB free disk space
  • โœ… Java 11 or higher
  • โœ… Curiosity about data! ๐Ÿ“Š

๐Ÿ“ Step 1: Installing Elasticsearch - Your Search Engine!

Letโ€™s get Elasticsearch installed! ๐Ÿ—๏ธ

First, install Java (Elasticsearchโ€™s foundation):

# Install Java 11
sudo dnf install -y java-11-openjdk java-11-openjdk-devel

# Verify Java installation
java -version

# Set JAVA_HOME
echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' | sudo tee -a /etc/profile
source /etc/profile

Now install Elasticsearch:

# Import Elasticsearch GPG key
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

# Create repository file
sudo nano /etc/yum.repos.d/elasticsearch.repo

# Add this content:
[elasticsearch]
name=Elasticsearch 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

Install Elasticsearch:

# Install Elasticsearch
sudo dnf install -y elasticsearch

# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch

# Wait 30 seconds for startup
sleep 30

# Test connection
curl -X GET "localhost:9200/"

You should see cluster information! ๐ŸŽ‰

๐Ÿ”ง Step 2: Configuring Elasticsearch - Optimizing Your Engine!

Letโ€™s configure Elasticsearch for optimal performance! ๐ŸŽฏ

Edit the main configuration:

# Backup original config
sudo cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak

# Edit configuration
sudo nano /etc/elasticsearch/elasticsearch.yml

Add these important settings:

# Cluster name (change for your environment)
cluster.name: my-elastic-cluster

# Node name (unique per node)
node.name: node-1

# Data and logs paths
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

# Network settings
network.host: 0.0.0.0  # Listen on all interfaces
http.port: 9200

# Discovery settings (for single node)
discovery.type: single-node

# Memory lock (important for performance!)
bootstrap.memory_lock: true

# Security (disable for now, enable in production!)
xpack.security.enabled: false

# Enable CORS for Kibana
http.cors.enabled: true
http.cors.allow-origin: "*"

Configure JVM heap size:

# Edit JVM options
sudo nano /etc/elasticsearch/jvm.options.d/heap.options

# Add (use half of your RAM, max 32GB):
-Xms2g  # Minimum heap
-Xmx2g  # Maximum heap

Configure system limits:

# Set memory lock limits
sudo nano /etc/systemd/system/elasticsearch.service.d/override.conf

# Add:
[Service]
LimitMEMLOCK=infinity

# Reload and restart
sudo systemctl daemon-reload
sudo systemctl restart elasticsearch

๐ŸŒŸ Step 3: Installing Kibana - Your Visual Dashboard!

Kibana makes Elasticsearch visual and beautiful! ๐ŸŽจ

# Install Kibana
sudo dnf install -y kibana

# Configure Kibana
sudo nano /etc/kibana/kibana.yml

# Add these settings:
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
elasticsearch.username: "kibana_system"  # If security enabled
# elasticsearch.password: "password"  # If security enabled

# Start Kibana
sudo systemctl enable kibana
sudo systemctl start kibana

# Open firewall ports
sudo firewall-cmd --permanent --add-port=9200/tcp
sudo firewall-cmd --permanent --add-port=5601/tcp
sudo firewall-cmd --reload

Access Kibana at http://your-server-ip:5601 ๐ŸŽŠ

โœ… Step 4: Creating Your First Index - Storing Data!

Time to store and search data! ๐Ÿ“š

Create an index with mapping:

# Create an index for blog posts
curl -X PUT "localhost:9200/blog" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "analyzer": "standard"
      },
      "content": {
        "type": "text",
        "analyzer": "english"
      },
      "author": {
        "type": "keyword"
      },
      "publish_date": {
        "type": "date"
      },
      "tags": {
        "type": "keyword"
      },
      "views": {
        "type": "integer"
      }
    }
  }
}'

Index some documents:

# Add a blog post
curl -X POST "localhost:9200/blog/_doc/1" -H 'Content-Type: application/json' -d'
{
  "title": "Getting Started with Elasticsearch",
  "content": "Elasticsearch is an amazing search engine that can handle massive amounts of data...",
  "author": "John Doe",
  "publish_date": "2024-01-15",
  "tags": ["elasticsearch", "search", "tutorial"],
  "views": 1500
}'

# Add another post
curl -X POST "localhost:9200/blog/_doc/2" -H 'Content-Type: application/json' -d'
{
  "title": "Advanced Elasticsearch Queries",
  "content": "Learn how to write complex queries using the Query DSL...",
  "author": "Jane Smith",
  "publish_date": "2024-01-20",
  "tags": ["elasticsearch", "advanced", "queries"],
  "views": 2500
}'

# Refresh index to make documents searchable
curl -X POST "localhost:9200/blog/_refresh"

๐Ÿ” Step 5: Searching Your Data - Finding Needles in Haystacks!

Letโ€™s search our data with powerful queries! ๐ŸŽฏ

Simple search:

# Search for all documents
curl -X GET "localhost:9200/blog/_search?pretty"

# Search by term
curl -X GET "localhost:9200/blog/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match": {
      "content": "elasticsearch"
    }
  }
}'

Advanced queries:

# Multi-field search with boosting
curl -X GET "localhost:9200/blog/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "multi_match": {
      "query": "elasticsearch tutorial",
      "fields": ["title^3", "content", "tags^2"]
    }
  },
  "highlight": {
    "fields": {
      "content": {}
    }
  }
}'

# Range query with aggregation
curl -X GET "localhost:9200/blog/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "range": {
      "views": {
        "gte": 1000,
        "lte": 3000
      }
    }
  },
  "aggs": {
    "popular_tags": {
      "terms": {
        "field": "tags",
        "size": 10
      }
    }
  }
}'

Letโ€™s set up a multi-node cluster for high availability! ๐ŸŒ

On the master node:

# Edit elasticsearch.yml
sudo nano /etc/elasticsearch/elasticsearch.yml

# Master node configuration:
cluster.name: production-cluster
node.name: master-1
node.roles: [master, data]
network.host: 0.0.0.0
discovery.seed_hosts: ["master-1-ip", "node-2-ip", "node-3-ip"]
cluster.initial_master_nodes: ["master-1"]

On additional nodes:

# Node 2 configuration:
cluster.name: production-cluster
node.name: data-node-2
node.roles: [data]
network.host: 0.0.0.0
discovery.seed_hosts: ["master-1-ip", "node-2-ip", "node-3-ip"]

# Restart all nodes
sudo systemctl restart elasticsearch

# Check cluster health
curl -X GET "localhost:9200/_cluster/health?pretty"

You should see all nodes joined! ๐ŸŽŠ

๐ŸŽฎ Quick Examples

Example 1: Log Analysis Pipeline

Set up log ingestion with Logstash:

# Install Logstash
sudo dnf install -y logstash

# Create pipeline config
sudo nano /etc/logstash/conf.d/apache.conf

# Add:
input {
  file {
    path => "/var/log/httpd/access_log"
    start_position => "beginning"
  }
}

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}" }
  }
  date {
    match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
  }
  geoip {
    source => "clientip"
  }
}

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "apache-logs-%{+YYYY.MM.dd}"
  }
}

# Start Logstash
sudo systemctl start logstash

Example 2: Real-Time Monitoring Dashboard

Create a monitoring dashboard in Kibana:

  1. Open Kibana at http://your-server:5601
  2. Go to Stack Management > Index Patterns
  3. Create pattern: apache-logs-*
  4. Go to Dashboard > Create New
  5. Add visualizations:
    • Line chart for requests over time
    • Pie chart for response codes
    • Map for geographic distribution
    • Data table for top URLs

Example 3: Python Application Integration

Use Elasticsearch from Python:

# Install: pip install elasticsearch
from elasticsearch import Elasticsearch
from datetime import datetime

# Connect to Elasticsearch
es = Elasticsearch(['http://localhost:9200'])

# Index a document
doc = {
    'author': 'Python App',
    'text': 'Elasticsearch from Python!',
    'timestamp': datetime.now(),
}
resp = es.index(index="test-index", document=doc)
print(f"Indexed: {resp['_id']}")

# Search documents
resp = es.search(index="test-index", query={"match_all": {}})
print(f"Found {resp['hits']['total']['value']} documents")

๐Ÿšจ Fix Common Problems

Problem 1: Elasticsearch Wonโ€™t Start

Symptom: Service fails to start ๐Ÿ˜ฐ

Fix:

# Check logs
sudo journalctl -u elasticsearch -n 100

# Common issues:
# 1. Memory lock failed
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

# 2. Port already in use
sudo netstat -tlnp | grep 9200

# 3. Permissions issue
sudo chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
sudo chown -R elasticsearch:elasticsearch /var/log/elasticsearch

Problem 2: Out of Memory Errors

Symptom: Cluster becomes unresponsive ๐Ÿ’พ

Fix:

# Increase heap size
sudo nano /etc/elasticsearch/jvm.options.d/heap.options
# Set to 50% of RAM, max 32GB

# Enable memory lock
sudo nano /etc/elasticsearch/elasticsearch.yml
# Add: bootstrap.memory_lock: true

# Restart
sudo systemctl restart elasticsearch

Problem 3: Slow Searches

Symptom: Queries take too long โฑ๏ธ

Fix:

# Check shard health
curl -X GET "localhost:9200/_cat/shards?v"

# Optimize index
curl -X POST "localhost:9200/your-index/_forcemerge?max_num_segments=1"

# Increase refresh interval
curl -X PUT "localhost:9200/your-index/_settings" -H 'Content-Type: application/json' -d'
{
  "index": {
    "refresh_interval": "30s"
  }
}'

๐Ÿ“‹ Simple Commands Summary

CommandWhat It DoesWhen to Use
curl localhost:9200Check if runningHealth check
/_cat/health?vCluster healthMonitor status
/_cat/nodes?vList nodesCheck cluster
/_cat/indices?vList indicesSee all data
/_cat/shards?vShard statusDebug issues
/index/_searchSearch dataQuery documents
/index/_doc/idGet documentRetrieve specific
/_cluster/settingsCluster configView settings
/_statsIndex statisticsPerformance data
/_aliasesList aliasesCheck mappings

๐Ÿ’ก Tips for Success

๐Ÿš€ Performance Optimization

Make Elasticsearch blazing fast:

# Disable swapping
sudo swapoff -a

# Optimize kernel settings
echo "net.ipv4.tcp_retries2 = 5" | sudo tee -a /etc/sysctl.conf
echo "vm.max_map_count = 262144" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

# Use SSDs for data directory
# Mount SSD to /var/lib/elasticsearch

# Optimize index settings
curl -X PUT "localhost:9200/your-index/_settings" -H 'Content-Type: application/json' -d'
{
  "index": {
    "number_of_replicas": 0,
    "refresh_interval": "30s"
  }
}'

๐Ÿ”’ Security Best Practices

Secure your cluster:

  1. Enable X-Pack Security - Authentication and encryption! ๐Ÿ”
  2. Use TLS/SSL - Encrypt all communications! ๐Ÿ”’
  3. Set up RBAC - Role-based access control! ๐Ÿ‘ฅ
  4. Regular backups - Snapshot your data! ๐Ÿ’พ
  5. Monitor everything - Use Elastic APM! ๐Ÿ“Š
# Enable security
echo "xpack.security.enabled: true" | sudo tee -a /etc/elasticsearch/elasticsearch.yml

# Generate passwords
sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto

๐Ÿ“ˆ Monitoring Excellence

Keep an eye on everything:

# Enable monitoring
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "xpack.monitoring.collection.enabled": true
  }
}'

# Key metrics to watch:
# - Heap usage < 75%
# - CPU usage < 90%
# - Disk usage < 85%
# - Search latency < 100ms

๐Ÿ† What You Learned

Youโ€™re now an Elasticsearch expert! ๐ŸŽ“ Youโ€™ve successfully:

  • โœ… Installed Elasticsearch and Kibana
  • โœ… Created indices and mappings
  • โœ… Indexed and searched documents
  • โœ… Built powerful queries
  • โœ… Set up clustering
  • โœ… Created visualizations
  • โœ… Optimized performance

Your search infrastructure is production-ready! ๐Ÿ”

๐ŸŽฏ Why This Matters

Elasticsearch gives you data superpowers! With your search cluster, you can:

  • ๐Ÿ” Search instantly - Find anything in milliseconds!
  • ๐Ÿ“Š Analyze in real-time - Understand patterns immediately!
  • ๐Ÿ“ˆ Scale infinitely - From GB to PB seamlessly!
  • ๐ŸŽฏ Power applications - Add Google-like search!
  • ๐Ÿ’ก Gain insights - Discover hidden patterns!

Youโ€™re not just searching data - youโ€™re unlocking its potential! Your infrastructure now has the same search capabilities as tech giants! ๐ŸŒŸ

Keep searching, keep discovering, and remember - with Elasticsearch, no data is too big to explore! โญ

May your searches be fast and your insights be deep! ๐Ÿš€๐Ÿ”๐Ÿ™Œ