Site Admin
Site Admin
Posts: 218
Joined: Fri Jan 31, 2025 7:06 pm
Location: California
Mood:
Contact:
  • Scotland
  • Genuine Addict

    Installing Elasticsearch on Ubuntu Server
    Elasticsearch is a powerful open-source search and analytics engine. This guide will walk you through the process of installing Elasticsearch on an Ubuntu server.

    Prerequisites
    • []An Ubuntu server (20.04 or later recommended).
      []A user with sudo privileges.
    • At least 2GB of RAM for optimal performance.
    Step 1: Update Your System
    Ensure your system is up to date.

    Code: Select all

    sudo apt update && sudo apt upgrade -y
    Step 2: Install Java
    Elasticsearch requires Java. Install the OpenJDK package:

    Code: Select all

    sudo apt install openjdk-17-jdk -y
    Verify the installation:

    Code: Select all

    java -version
    You should see output similar to:

    Code: Select all

    openjdk version "17.x.x"
    Step 3: Add Elasticsearch Repository

    1. Download and install the public signing key:

    Code: Select all

    curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
    2. Add the Elasticsearch repository:

    Code: Select all

    echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
    3. Update the package list:

    Code: Select all

    sudo apt update
    Step 4: Install Elasticsearch
    Install Elasticsearch using the apt package manager:

    Code: Select all

    sudo apt install elasticsearch -y
    Step 5: Configure Elasticsearch
    Open the configuration file:

    Code: Select all

    sudo nano /etc/elasticsearch/elasticsearch.yml
    Make the following changes:

    Set the network host to allow external connections:

    Code: Select all

    network.host: 0.0.0.0
    Set a unique cluster name:

    Code: Select all

    cluster.name: my-cluster
    Save and exit (Ctrl+O, Enter, Ctrl+X).

    Step 6: Enable and Start Elasticsearch
    Enable Elasticsearch to start on boot:

    Code: Select all

    sudo systemctl enable elasticsearch
    Start Elasticsearch:

    Code: Select all

    sudo systemctl start elasticsearch
    Check the status:

    Code: Select all

    sudo systemctl status elasticsearch
    Step 7: Verify Installation
    Test if Elasticsearch is running:

    Code: Select all

    curl -X GET "http://localhost:9200/"
    Expected JSON response:

    Code: Select all

    {
    "name" : "your-server-name",
    "cluster_name" : "my-cluster",
    "version" : {
    "number" : "8.x.x",
    ...
    }
    }
    Step 8: Secure Elasticsearch
    Set up a password for the elastic user:

    Code: Select all

    sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
    Follow the prompts to configure the password.

    Optional: Allow Remote Access
    To access Elasticsearch from other machines, open port 9200 in the firewall:

    Code: Select all

    sudo ufw allow 9200
    Restart Elasticsearch:

    Code: Select all

    sudo systemctl restart elasticsearch
    Step 9: Install Kibana (Optional)
    Kibana is a visualization tool for Elasticsearch. To install it:

    1. Install Kibana:

    Code: Select all

    sudo apt install kibana -y
    2. Enable and start Kibana:

    Code: Select all

    sudo systemctl enable kibana
    sudo systemctl start kibana
    3. Access Kibana at

    Code: Select all

    http://your-server-ip:5601
    .

    Conclusion
    Elasticsearch is now successfully installed on your Ubuntu server! 🎉 Use it to enhance search and analytics on your projects. Don't forget to monitor performance and implement security for production environments.
    Social Plug |•| Forum Addicts |•| Sports Wrestling Community |•| Our Partners |•| Our Partners
    Image