How to Set Up Elasticsearch and Kibana on CentOS 7 (2023 Guide)

Real-Time Search and Analytics: The Challenge

Picture this: your team is tasked with implementing a robust real-time search and analytics solution, but time isn’t on your side. You’ve got a CentOS 7 server at your disposal, and the pressure is mounting to get Elasticsearch and Kibana up and running quickly, securely, and efficiently. I’ve been there countless times, and through trial and error, I’ve learned exactly how to make this process smooth and sustainable. In this guide, I’ll walk you through every essential step, with no shortcuts and actionable tips to avoid common pitfalls.

Step 1: Prepare Your System for Elasticsearch

Before diving into the installation, it’s crucial to ensure your CentOS 7 environment is primed for Elasticsearch. Neglecting these prerequisites can lead to frustrating errors down the line. Trust me—spending an extra 10 minutes here will save you hours later. Let’s break this down step by step.

Networking Essentials

Networking is the backbone of any distributed system, and Elasticsearch clusters are no exception. To avoid future headaches, it’s important to configure networking properly from the start.

  • Set a static IP address:

    A dynamic IP can cause connectivity issues, especially in a cluster. Configure a static IP by editing the network configuration:

    sudo vi /etc/sysconfig/network-scripts/ifcfg-ens3

    Update the file to include settings for a static IP, then restart the network service:

    sudo systemctl restart network
    Pro Tip: Use ip addr to confirm the IP address has been set correctly.
  • Set a hostname:

    A clear, descriptive hostname helps with cluster management and debugging. Set a hostname like es-node1 using the following command:

    sudo hostnamectl set-hostname es-node1

    Don’t forget to update /etc/hosts to map the hostname to your static IP address.

Install Prerequisite Packages

Elasticsearch relies on several packages to function properly. Installing them upfront will ensure a smoother setup process.

  • Install essential utilities: Tools like wget and curl are needed for downloading files and testing connections:

    sudo yum install wget curl vim -y
  • Install Java: Elasticsearch requires Java to run. While Elasticsearch 8.x comes with a bundled JVM, it’s a good idea to have Java installed system-wide for flexibility:

    sudo yum install java-1.8.0-openjdk.x86_64 -y
    Warning: If you decide to use the bundled JVM, avoid setting JAVA_HOME to prevent conflicts.

Step 2: Install Elasticsearch 8.x on CentOS 7

Now that your system is ready, it’s time to install Elasticsearch. Version 8.x brings significant improvements, including built-in security features like TLS and authentication. Follow these steps carefully.

Adding the Elasticsearch Repository

The first step is to add the official Elasticsearch repository to your system. This ensures you’ll always have access to the latest version.

  1. Import the Elasticsearch GPG key:

    Verify the authenticity of the packages by importing the GPG key:

    sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
  2. Create the repository file:

    Add the Elastic repository by creating a new file:

    📚 Continue Reading

    Sign in with your Google or Facebook account to read the full article.
    It takes just 2 seconds!

    Already have an account? Log in here