The cart is empty

Elasticsearch is a highly scalable search and analytics engine distributed as open-source. Based on the Lucene library, it enables fast searching, aggregation, and analysis of large volumes of data in real-time. In this article, we will look at how to install and perform basic configuration of Elasticsearch.

Prerequisites

Before installing Elasticsearch, you need to have Java Virtual Machine (JVM) installed. Elasticsearch requires at least Java 8. It is recommended to use either OpenJDK or Oracle Java. After installing Java, verify its version using the following command:

java -version

Installing Elasticsearch

Elasticsearch can be installed in various ways depending on your operating system.

  • For Linux (Debian/Ubuntu):

    1. Add Elasticsearch to the list of repositories using the following command:

      wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
      
    2. Add the Elasticsearch repository to your system:

      sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
      
    3. Update the package list and install Elasticsearch:

      sudo apt update && sudo apt install elasticsearch
      
  • For Windows:

    Download the Elasticsearch installation package from the official Elastic website and run the installer.

Basic Configuration

After installing Elasticsearch, basic configuration needs to be performed. The configuration file elasticsearch.yml is usually located in /etc/elasticsearch on Linux or in the installation directory on Windows.

  • Open the configuration file in a text editor and set the following values:

    • cluster.name: The name of your cluster.
    • node.name: The name of this node.
    • network.host: Set to localhost if accessing Elasticsearch from the local machine. For access from other machines in the network, set it to the IP address of your server.
    • http.port: The port on which Elasticsearch will accept HTTP requests. The default value is 9200.
  • Save the changes and restart Elasticsearch:

    • For Linux:

      sudo systemctl restart elasticsearch
      
    • For Windows, restart the Elasticsearch service via the Service Manager.

Verifying the Installation

Verify that Elasticsearch is running and responding to requests by sending a GET request to port 9200 using curl or a web browser:

curl -X GET "localhost:9200/"

You should receive a response containing information about the Elasticsearch version and cluster status.

Securing Elasticsearch

It is important to ensure the security of your Elasticsearch instance, especially if it is accessible from the public internet. Consider implementing the following security measures:

  • Enabling basic authentication and encrypting communication using SSL/TLS.
  • Restricting access to Elasticsearch ports using a firewall or network settings.

 

Now that Elasticsearch is installed and basic configuration is done, you can start indexing and searching data. Elasticsearch provides a RESTful API, allowing you to work with data directly from a web browser or using tools such as Postman or curl.

This article provided an overview of how to install and perform basic configuration of Elasticsearch. For deeper understanding and advanced configurations, it is recommended to consult the official Elasticsearch documentation.