Understanding Elasticsearch from Installation to Trouble Shooting

CK CK 3788 
Created at
Updated at  
915 0 0

Elasticsearch is a distributed search and analytics engine, scalable data store, and vector database built on Apache Lucene. It’s optimized for speed and relevance on production-scale workloads. Use Elasticsearch to search, index, store, and analyze data of all shapes and sizes in near real time.

Elasticsearch is the heart of the Elastic Stack. Combined with Kibana, it powers the following Elastic solutions:


How to install?

To install Elasticsearch, follow these steps based on your operating system:

1. For Linux (Debian/Ubuntu)

a. Import the Elasticsearch public GPG key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

b. Install the apt-transport-https package:

sudo apt-get install apt-transport-https

c. Add the Elasticsearch APT repository:

echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list

d. Update your package list and install Elasticsearch:

sudo apt-get update
sudo apt-get install elasticsearch

e. Enable and start the Elasticsearch service:

sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch

 

2. For macOS (Using Homebrew)

a. Install Elasticsearch:

brew tap elastic/tap
brew install elastic/tap/elasticsearch-full

b. Start Elasticsearch:

brew services start elastic/tap/elasticsearch-full

 

3. For Windows

a. Download the Elasticsearch ZIP file from the official Elastic website.

b. Extract the ZIP file and navigate to the bin folder inside the extracted directory.

c. Start Elasticsearch by running:

elasticsearch.bat

 

4. Verifying Installation

Once Elasticsearch is running, you can verify the installation by running this command:

curl -X GET "localhost:9200/"

This should return basic information about your Elasticsearch instance.


To install Elasticsearch using Docker, follow these steps:

1. Install Docker

If Docker is not already installed, follow the installation instructions for your OS from the Docker website.

 

2. Pull the Elasticsearch Docker Image

To get the official Elasticsearch Docker image, run:

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.10.2

Replace 8.10.2 with the version you'd like to use, if necessary.

 

3. Run Elasticsearch in Docker

To start an Elasticsearch container, run the following command:

docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:8.10.2
  • -d: Runs the container in detached mode.
  • --name elasticsearch: Names the container "elasticsearch".
  • -p 9200:9200: Maps port 9200 (HTTP) to your host, so you can interact with Elasticsearch.
  • -p 9300:9300: Maps port 9300 (transport), mainly used for clustering.
  • -e "discovery.type=single-node": This sets up Elasticsearch in single-node mode (useful for development).

 

4. Verify Installation

Once the container is running, you can verify that Elasticsearch is working by sending an HTTP request:

curl -X GET "localhost:9200/"

This should return the Elasticsearch instance information in JSON format.

 

5. Optional: Managing the Container

  • Stop Elasticsearch:

    docker stop elasticsearch
    
  • Start the container again:

    docker start elasticsearch
    

This Docker setup is great for development or testing environments. If you're planning to run Elasticsearch in production via Docker, you may want to configure persistent storage, networking, and cluster settings.


Trouble Shooting when the default port (9200) is not mapped correctly.

You can't directly modify the port of a running container, but you can change how Docker forwards the ports without reinstalling Elasticsearch. Here's how:

Step-by-Step Instructions:

  1. Stop the Container First, stop the currently running Elasticsearch container:

    docker stop <container_id_or_name>
    
  2. Create a New Container with Correct Port Mapping

    Use Docker’s commit and run commands to create a new container from your existing one without having to pull and reinstall the image. This will preserve the current setup and data.

    First, commit the stopped container to a new image:

    docker commit <container_id_or_name> my_elasticsearch:v1
    

    Now, create and run a new container with the proper port mapping (in this case, mapping port 9200 on the host to port 9200 inside the container):

    docker run -d --name elasticsearch_fixed -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" my_elasticsearch:v1
    

    This will create a new container using the existing state, but with updated port bindings.

  3. Verify the Change

    You can now verify that Elasticsearch is running on the new port (9200) by running:

    curl -X GET “localhost:9200/”

     


Key Takeaways: Understanding Elasticsearch from Installation to Troubleshooting

  • Elasticsearch is a powerful, distributed search and analytics engine that provides scalable data storage and vector database capabilities, optimized for high-speed relevance.
  • Easy installation across platforms: Elasticsearch offers straightforward installation guides for Linux (Debian/Ubuntu), macOS (using Homebrew), and Windows.
  • Leverage Docker for streamlined development and testing: Docker simplifies Elasticsearch setup by providing an isolated container environment with easy management.
  • Troubleshooting common issues: Learn to handle scenarios where the default port (9200) isn't mapped correctly by adjusting Docker port forwarding without reinstalling Elasticsearch.
Tags Analytics Engine Apache Lucene Distributed Search Engine Elastic Stack Elasticsearch Kibana Near Real-Time Data Scalable Data Store Vector Database Facebook X
Comments 0
Similar posts
  1. Milvus & FAISS: Decoding Their ML Synergy
    286
  2. Recommended Vector DB Structure for Amazon Bedrock Integration
    393
  3. Milvus and LLM Integration - Very Smart Approach!
    304
  4. Integrating VectorDB stored in S3 with Amazon Bedrock
    429
  5. Architecting ML/LLM Ad Targeting with Kafka, Flink, FAISS, and Milvus
    284
  6. The Core of Vector Databases: Embeddings and LLM Dependency
    266
  7. Your Blueprint for an LLM & Vector DB Insurance Product Q&A
    266
  8. Demystifying FAISS: Your Guide to ANN(Approximate Nearest Neighbor) Search
    326
  9. Image Embeddings for Vector Databases
    254
  10. Vector Database Integration on Fully Managed Multi-Agent Environment
    318
  11. Embeddings on the Lakehouse: What Snowflake and Databricks Actually Do (and Don't)
    303
  12. Vector Databases: From Embeddings to Application
    322
  13. Designing a Data Curation System Around a Vector Database
    230
  14. What is RedisVL?
    114
  1. How to post content (image or video) to Instagram using the Instagram Graph API
    6,412
  2. Font name correctly having the same width space
    1,228
  3. JavaScript Algorithms
    722
  4. GraphQL Tutorial on CentOS 7: From Installation to Deployment
    564
  5. Capture all browser console logs including errors for debugging
    2,189
  6. Simple asynchronous/synchronous $.ajax() example using jQuery to make an HTTP GET request
    861
  7. JavaScript Code to Get Page Keywords
    350
  8. What is OpenGraph?
    367
  9. What is Twitter Cards?
    403
  10. Code to Extract the Site Thumbnail Image for Twitter or Facebook
    394
  11. JavaScript Code to Get the Page Title
    339
  12. JavaScript Code to Get Meta Description from HTML
    397
  13. Javascript code to extract favicon URL
    402
  14. RSS to Array in JavaScript
    2,166
  15. Javascript function to convert sitemap.xml to array
    602
  16. IndexNow for better SEO
    320
  17. Enhancing SEO for Single Page Applications: Implementing Dynamic URL Updates
    1,042
  18. Method to ignore JavaScript Errors globally instead of try... catch for each of cases
    973
  19. Method to catch the browser console log and errors for remote web debugging
    2,188
  20. Atlassian Jira Ticket API Response Example
    2,803
  21. Three different type of Word-Wrap options in HTML CSS
    1,189
  22. JavaScript code to load XML Document
    604
  23. Creating a Pinterest-Style Card Layout with Bootstrap and Masonry
    599
  24. Equal Height Blocks in Bootstrap with JavaScript
    713
  25. Copy text to clipboard in Javascript
    1,716
  26. To block copy & paste on your blog content
    904
  27. Shake your browser window by Javascript
    939
  28. Photoshop script programming in Javascript
    532
  29. To compare two HTML tables on web page in real time
    516
  30. To hide/show area of web page without re-loading a page
    1,026
Recently updated
  1. Google OAuth Token Expiration: Causes and Solutions
    28
  2. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    55
  3. Why SPF and DKIM Are Essential for Linux Email Servers?
    49
  4. How do I create animated background for Google Meet?
    22,830
  5. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    271
  6. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    103
  7. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    168
  8. Array of arguments passed to script in PHP
    97
  9. Invalid Auction Storms in Ad Tech
    106
  10. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    207
  11. The Two Clocks of Ad Server Architecture
    77
  12. Frequency Cap Architecture Overview
    526
  13. Collecting Proof-of-Play from 100,000 Screens
    152
  14. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    302
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    246
  16. TPU & GPU Cluster Management Tools
    257
  17. The Concept of Scaffolding in AI Agents
    244
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    596
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    267
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    353
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    206
  22. Machine Learning: Training vs. Ranking
    229
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    228
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    202
  25. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    263
  26. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    671
  27. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    200
  28. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    232
  29. Understanding Data Lineage
    271
  30. System Requirements and Architecture: Intelligent Priority-Based Scheduler
    175