Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to Install Elastic Stack (ELK) on Red Hat Enterprise Linux (RHEL)

June 7, 2016
Hemant Jain
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

Share:

    Sometimes, software just goes together. Linux, the Apache Web server, MySQL, and PHP, the four ingredients of the LAMP stack, which revolutionized data centers and made open source a big deal two decades ago, are probably the most famous example. But there are lots of others.

    Here's another open source software stack you should know about in our present age of cloud and big data: the Elastic Stack, or ELK. Based on Elasticsearch, Logstash and Kibana, ELK is a fully open source solution for searching, analyzing and visualizing data in any format, at any scale.

    Since ELK has multiple parts, and some of them have other dependencies, setting up ELK is not as simple as installing other stacks, which sometimes require a simple one-line yum installation command. But fear not. ELK is still easy enough to install if you follow the proper steps.

    Below, we'll walk through configuring a Red Hat Enterprise Linux (RHEL) server for ELK, installing each of the requisite components and configuring them to work with one another. (RHEL is now free for development use --- download it here.)

    Prerequisites

    First, let's go over some prerequisites. This guide assumes:

    • Your server runs RHEL 6 or RHEL 7. Some parts of the ELK stack support RHEL 5, but not all, so don't try using it. (By the way, if you're still using RHEL 5, you should probably be upgrading soon, since its EOL date is fast approaching.)
    • You want to install ELK using the official RPM packages from the developers. (Yes, you could pull the source through git and compile it yourself, but that's outside the scope of this post.)
    • You want to install the latest version of ELK. You could install older versions by telling yum to download specific packages (but I assume you want to be as up-to-date as possible).
    • You're happy using Oracle Java, which is what we'll install to meet the Java dependency of ELK. If you want to use a different version of Java, check the Elasticsearch support matrix to make sure it will work. (Yes, OpenJDK is supported.)

    Step 1: Install Java

    Let's dive into the installation process. Our first task is to install Java, since Elasticsearch and Logstash require Java to run. As noted above, we'll install Oracle Java, although you could use OpenJDK if you like.

    To do this, we'll use curl to download the latest Java RPM (Java 8 revision 77) from Oracle's site, then install it via yum, with these two commands:

    cd /tmp
    curl --insecure --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" -L "http://download.oracle.com/otn-pub/java/jdk/8u77-b02/jdk-8u77-linux-x64.rpm" > jdk-8u77-linux-x64.rpm

    Lest I start a war between curl and wget fans, I suppose I should tell you how to download Java using wget, too. The commands are:

    cd /tmp
    wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u77-b02/jdk-8u77-linux-x64.rpm"

    Whether you use curl or wget to download Java, you should end up with a file in /tmp called jdk-8u77-linux-x64.rpm. The next step is to install this file by running yum (as root) like so:

    yum -y localinstall jdk-8u73-linux-x64.rpm

    All set. You just installed Java.

    Step 2: Install Elasticsearch

    The next step, installing Elasticsearch, is easier, since we can do it all using yum. (If only Java installation were equally simple...)

    To do this, first import the Elasticsearch GPG key with:

    rpm --import http://packages.elastic.co/GPG-KEY-elasticsearch

    Next, open a blank text file in your favorite text editor (be sure to run the editor as root, so that you have the necessary save permissions) and fill it with these lines:

    name=Elasticsearch repository for 2.x packages
    baseurl=http://packages.elastic.co/elasticsearch/2.x/centos
    gpgcheck=1
    gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
    enabled=1

    Save the file as /etc/yum.repos.d/elasticsearch.repo

    Next, install the Elasticsearch package with:

    sudo yum -y install elasticsearch

    Step 3: Configure and Start Elasticsearch

    Before installing the rest of the ELK stack, we should tweak Elasticsearch a little and start it up.

    Specifically, we want to prevent outside connections to the Elasticsearch HTTP API. To do this, open the file /etc/elasticsearch/elasticsearch.yml in an editor (again, run the editor as root), find the line with the value network.host, uncomment it and replace it with the (uncommented) line network.host: localhost Then save the file and exit.

    You can now start Elasticsearch using the systemctl interface. systemctl start elasticsearch starts it, systemctl stop elasticsearch stops it, and systemctl systemctl enable configures it to start automatically at boot.

    Step 4: Install Kibana

    We're going to follow a similar process to install Kibana. First, create a yum repository file for it by opening a blank text file and adding these lines:

    [kibana-4.4]
    name=Kibana repository for 4.4.x packages
    baseurl=http://packages.elastic.co/kibana/4.4/centos
    gpgcheck=1
    gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
    enabled=1
    
    

    Save the file as /etc/yum.repos.d/kibana.repo

    Then download and install the Kibana package with:

    yum -y install kibana

    We also need to do a quick configuration tweak for Kibana. Open the file /opt/kibana/config/kibana.yml, find the line that reads server.host: "0.0.0.0" and replace it with server.host: "localhost"

    You should now start Kibana with systemctl start kibana. You can stop it using systemctl as well. And to configure Kibana to start automatically at boot, run chkconfig kibana on

    Step 5: Install Logstash

    Our final step is to install the last piece of the ELK stack, Logstash. Here again, we need to create a yum repository file by adding the following lines to a blank text file:

    [logstash-2.2]
    name=logstash repository for 2.2 packages
    baseurl=http://packages.elasticsearch.org/logstash/2.2/centos
    gpgcheck=1
    gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
    enabled=1

    Save the file as /etc/yum.repos.d/logstash.repo. Then install Logstash with:

    yum -y install logstash

    Congrats! Logstash is installed.

    Using ELK

    You now have a basic ELK stack installed. Depending on exactly what you want to do with it, however, you may want to take some additional steps. Consider the following tweaks and additions:

    • By default, Kibana (the Web interface that you use to search and analyze your Elasticsearch data) listens on localhost at port 5601. That means you can connect to it from your RHEL server at localhost:5601. If you want to be able to access Kibana from other servers, too, you'll need to do some additional configuration. Refer here for details.
    • Above, we did a basic installation of Logstash. Your exact configuration of the tool will depend on which plugins you want to use and how you want to work with data. Basic configuration instructions are available here, and more complex examples are here.
    • By default, your ELK stack will only let you collect and analyze logs from your local server. But you can add remote logs to the mix by using Filebeat, which collects logs from other hosts. Here are instructions for installing and setting up Filebeat to work with your ELK stack.

    Screen Shot 2016-05-27 at 3.47.23 PMAbout Hemant Jain

    Hemant Jain is the founder and owner of Rapidera Technologies, a full service software development shop. He and his team focus a lot on modern software delivery techniques and tools. Prior to Rapidera he managed large scale enterprise development projects at Autodesk and Deloitte.

    Last updated: January 19, 2023

    Recent Posts

    • How Trilio secures OpenShift virtual machines and containers

    • How to implement observability with Node.js and Llama Stack

    • How to encrypt RHEL images for Azure confidential VMs

    • How to manage RHEL virtual machines with Podman Desktop

    • Speech-to-text with Whisper and Red Hat AI Inference Server

    What’s up next?

     

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue