Jump to content

Elasticsearch Installation Guide for Linux, macOS, and Windows

Featured Replies

Posted
  • Administrators
comment_273

Elasticsearch is an open-source distributed search engine widely used for log analysis, full-text search, and data analytics. Its powerful real-time data querying capabilities make it an essential part of modern data platforms. In this guide, we will walk through the detailed installation and configuration of Elasticsearch on various operating systems (Linux, macOS, and Windows), offering step-by-step instructions for each system.

1. Introduction to Elasticsearch

Elasticsearch is built on top of Apache Lucene and is designed to provide distributed full-text search functionality. It supports various data types, including structured, unstructured, and multimedia data, and offers fast search and analytics capabilities. Typically, Elasticsearch is used in conjunction with Logstash (for data ingestion) and Kibana (for data visualization) as part of the ELK Stack for big data analytics and log management.

Key features of Elasticsearch:

  • Distributed Architecture: Scalable to handle large data volumes.

  • Real-time Search: Fast indexing and instant querying.

  • High Availability and Fault Tolerance: Ensures data safety through replication and sharding.

2. Installing Elasticsearch on Linux

Linux is the most common platform for deploying Elasticsearch. Below are the installation steps for Ubuntu and CentOS/RHEL systems.

2.1 Ubuntu/Debian Installation

Step 1: Install Java

Elasticsearch is written in Java, so you need to install Java Runtime Environment (JRE). OpenJDK 11 is recommended.

sudo apt update
sudo apt install openjdk-11-jre -y
java -version

Step 2: Add Elasticsearch Repository

To install Elasticsearch from the official repository, add the GPG key and APT source.

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
sudo apt update

Step 3: Install Elasticsearch

sudo apt install elasticsearch -y

Step 4: Configure Elasticsearch

The configuration file is located at /etc/elasticsearch/elasticsearch.yml. Adjust the settings as needed.

  1. Set the cluster name:

    cluster.name: my-cluster
    
  2. Set the node name:

    node.name: node-1
    
  3. Configure network settings: By default, Elasticsearch binds to localhost. To allow external connections, modify the network.host setting:

    network.host: 0.0.0.0
    

Step 5: Start Elasticsearch

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch

Step 6: Verify Installation

Check if Elasticsearch is running by executing the following:

curl -X GET "localhost:9200/"

You should see a JSON response containing version and cluster information if everything is working correctly.

2.2 CentOS/RHEL Installation

Step 1: Install Java

sudo yum install java-11-openjdk -y
java -version

Step 2: Configure Elasticsearch Repository

sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo sh -c 'echo "[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
enabled=1" > /etc/yum.repos.d/elasticsearch.repo'

Step 3: Install Elasticsearch

sudo yum install elasticsearch -y

Step 4: Configure Elasticsearch

Edit the /etc/elasticsearch/elasticsearch.yml file and configure the cluster name, node name, and network settings.

Step 5: Start Elasticsearch

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch

Step 6: Verify Installation

Use curl to check if Elasticsearch is running:

curl -X GET "localhost:9200/"

3. Installing Elasticsearch on macOS

On macOS, the easiest way to install Elasticsearch is through Homebrew.

Step 1: Install Homebrew

If you don’t have Homebrew installed, use the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install Elasticsearch

Install Elasticsearch using Homebrew:

brew install elasticsearch

Step 3: Start Elasticsearch

Start Elasticsearch by running:

elasticsearch

By default, Elasticsearch will listen on localhost:9200.

Step 4: Verify Installation

Open a browser and go to http://localhost:9200/. You should see a JSON response indicating that Elasticsearch is running.

4. Installing Elasticsearch on Windows

On Windows, Elasticsearch can be installed by downloading the ZIP package and extracting it.

Step 1: Download Elasticsearch

Download the Windows version of Elasticsearch from the official website: Elasticsearch Downloads.

Step 2: Extract and Configure

Extract the ZIP file to a directory of your choice (e.g., C:\elasticsearch).

Step 3: Start Elasticsearch

  1. Open the Command Prompt (cmd) and navigate to the bin folder inside the extracted directory.

  2. Run the following command to start Elasticsearch:

    .\elasticsearch.bat
    

Step 4: Verify Installation

Open a browser and navigate to http://localhost:9200/ to verify that Elasticsearch is running.

5. Installing Kibana (Optional)

Kibana is an open-source analytics and visualization platform, often used alongside Elasticsearch. It allows you to visualize data and monitor Elasticsearch performance.

Step 1: Install Kibana

On Linux and macOS, install Kibana using the package manager:

sudo apt install kibana -y  # Ubuntu/Debian
sudo yum install kibana -y  # CentOS/RHEL

On Windows, download and extract the Windows version of Kibana.

Step 2: Configure Kibana

Edit the kibana.yml file to set the Elasticsearch host:

elasticsearch.hosts: ["http://localhost:9200"]

Step 3: Start Kibana

On Linux and macOS, use the following commands to start Kibana:

sudo systemctl start kibana
sudo systemctl enable kibana

On Windows, run bin/kibana.bat.

Step 4: Verify Installation

In a browser, go to http://localhost:5601/ to verify that Kibana is connected to Elasticsearch.

6. Conclusion

Elasticsearch is a powerful distributed search engine that allows you to build scalable search platforms. With this guide, you can easily install and configure Elasticsearch on Linux, macOS, and Windows. To enhance your data analytics capabilities, you can also install Kibana for real-time data visualization.

  • Cavalry changed the title to Elasticsearch Installation Guide for Linux, macOS, and Windows

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...