Skip to main content

🚀 Installing and Configuring Elasticsearch

📌 Step 1: Install Java Runtime and Development Kit​

Elasticsearch requires Java to run. Install the default JRE and JDK using:

sudo apt install default-jre 

sudo apt install default-jdk

📌 Step 2: Add Elasticsearch Repository​

Before installing Elasticsearch, add its repository to your system:

curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg

echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

Update the package list:

sudo apt update

📌 Step 3: Install Elasticsearch​

Now, install Elasticsearch using:

sudo apt install elasticsearch

📌 Step 4: Configure Elasticsearch​

Edit the main configuration file:

sudo vi /etc/elasticsearch/elasticsearch.yml

Modify the following section to configure the cluster and network settings:

# ---------------------------------- Cluster -----------------------------------
cluster.name: elasticsearch
node.name: node-1

# ---------------------------------- Network -----------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 0.0.0.0

# ---------------------------------- Discovery ---------------------------------
discovery.seed_hosts: []
cluster.initial_master_nodes: ["node-1"]

🔹 Understanding These Settings:

  • cluster.name: Defines the name of your Elasticsearch cluster. Change this for better organization in multi-node setups.
  • node.name: Specifies the name of the Elasticsearch node. Useful when running multiple nodes.
  • network.host:
    • localhost: Elasticsearch is only accessible from the same machine.
    • 0.0.0.0: Allows access from any IP. Required for multi-node clusters and remote access.
  • discovery.seed_hosts: A list of other nodes in the cluster. Since this is a single-node setup, we leave it empty ([]).
  • cluster.initial_master_nodes: Defines the initial master node(s) when forming a new cluster. In a single-node setup, this should match the node.name.

📌 Multi-Node Setup & Kibana Integration​

🔹 What is a Multi-Node Setup?

  • A multi-node setup consists of multiple Elasticsearch nodes working together as a cluster.
  • Each node can have different roles, such as master node, data node, and coordinating node.
  • This improves performance, availability, and scalability.

🔹 Effect on Kibana:

  • Kibana connects to the entire cluster, not just a single node.
  • Under Stack Management → Nodes, you will see all the nodes in your cluster.
  • The cluster name (cluster.name: elasticsearch) will be visible in monitoring sections.
  • If multiple nodes exist, Kibana distributes queries across them for better performance.

📌 Step 5: Start and Enable Elasticsearch​

Start the Elasticsearch service:

sudo systemctl start elasticsearch

Enable Elasticsearch to start on boot:

sudo systemctl enable elasticsearch

📌 Step 6: Verify Elasticsearch Installation​

Run the following command to check if Elasticsearch is running:

curl -X GET "localhost:9200"

🎉 If everything is set up correctly, you should see a JSON response with Elasticsearch details!


✅ Now your Elasticsearch instance is installed and running. If you need to access it remotely, make sure to adjust the network.host setting accordingly and secure it with authentication mechanisms!🚀