Run Elasticsearch Locally: A Step-by-Step Installation Guide

Author

Reads 260

Computer server in data center room
Credit: pexels.com, Computer server in data center room

Running Elasticsearch locally is a great way to test and experiment with its features without the need for a dedicated server. You can download the Elasticsearch package from the official Elasticsearch website.

First, you need to download and install Elasticsearch on your local machine. This can be done by running the following command in your terminal: `bin/elasticsearch`.

Next, you'll need to configure Elasticsearch by creating a configuration file. This file is typically named `elasticsearch.yml` and is located in the same directory as the Elasticsearch executable.

To start Elasticsearch, simply run the `elasticsearch` command in your terminal.

Setting Up Locally

To run Elasticsearch locally, you'll first need to download and install it on your machine. You can get it directly from the official Elastic website.

Elasticsearch is a Java application, so you'll need to have Java installed or use the JVM bundled with the Elasticsearch distribution. The recommended version for Elasticsearch 8 is Java 17, but newer versions are also compatible.

You can install only Elasticsearch without Kibana by using the --esonly option. This can be useful if you're low on resources and want to test Elasticsearch separately.

Here are the installation options:

  • Download Elasticsearch from the official Elastic website.
  • Use the --esonly option to install only Elasticsearch.

Setup

Beautifully arranged seaside dinner setup with candles at sunset, perfect for a memorable evening.
Credit: pexels.com, Beautifully arranged seaside dinner setup with candles at sunset, perfect for a memorable evening.

To set up Elasticsearch locally, you'll need to download and install it on your machine. This can be done directly from the official Elastic website, where you can extract the files to your desired location once downloaded.

You can install only Elasticsearch without Kibana by using the --esonly option. This is useful if you don't have enough resources and want to test only Elasticsearch.

To run the start-local script, use curl to execute it. This will create an elastic-start-local folder containing essential files for Elasticsearch and Kibana.

The elastic-start-local folder includes several important files, such as:

  • docker-compose.yml: Docker Compose configuration for Elasticsearch and Kibana
  • .env: Environment settings, including the Elasticsearch password
  • start.sh and stop.sh: Scripts to start and stop Elasticsearch and Kibana
  • uninstall.sh: The script to uninstall Elasticsearch and Kibana

You can change the default location of the elastic-start-local folder by using the ES_LOCAL_DIR env variable. For example, you can create a new folder named another-folder by running the command.

Recommended read: Dropbox Local Folder

Running Tests

Running tests is a crucial step in setting up your project locally.

First, you'll need to install bashunit, which can be done using a single command: curl -s https://bashunit.typeddevs.com/install.sh | bash.

To run the tests, simply execute the lib/bashunit command.

The tests will start by running the start-local.sh script, which checks if Elasticsearch and Kibana are working properly.

For URL pipeline testing, a local web server is required, which also happens to require PHP.

Consider reading: Azure Run Command

Running

Credit: youtube.com, Install and Configure Elasticsearch in Windows

To run Elasticsearch locally, you can navigate to the bin directory within the Elasticsearch installation folder and run the `elasticsearch` command (or `elasticsearch.bat` on Windows). This will start Elasticsearch with the default settings.

Elasticsearch 8.0.0 and later versions enable security by default, generating a default password for the elastic user and printing it out in the terminal window. You'll also find certificates and TLS keys set up to secure HTTP traffic, and an enrollment token to log into Kibana, valid for 30 minutes.

To verify that Elasticsearch is running, enter the address `localhost:9200` in your web browser or use a tool like curl in a new terminal window to send a GET request to `localhost:9200`.

You can run Elasticsearch using Docker by pulling the Elasticsearch Open Source (OSS) image tagged with version 7.10.2 and binding the ports 9200 to your localhost. This makes Elasticsearch available on `http://localhost:9200`.

Here's a breakdown of the Docker command:

  • `-p 9200:9200` binds the port from the Docker container to your local machine.
  • `--name elasticsearch` names your Docker container for easy reference.
  • `discovery.type=single-node` tells Elasticsearch not to look for other nodes in the network.
  • `docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2-amd64` pulls the OSS image of Elasticsearch.

You can also use the `docker run` command to start Elasticsearch with the default settings.

Credit: youtube.com, How to Install Elasticsearch & Kibana Locally: Step-by-Step Setup | Spring Data Elasticsearch

To stop and start the Elasticsearch and Kibana Docker services, use the `stop` and `start` commands available in the `elastic-start-local` folder. Docker Compose is used to manage the services.

To run the Elasticsearch container using Docker Compose, follow these steps:

  • Run the Elasticsearch container by clicking on "Run" under the "Actions" tab.
  • Provide the following information:

+ Container name

+ Host ports

+ Set discovery.type environment variable with the value set to single node

Configuring and Optimizing

Configuring Elasticsearch is a straightforward process that can be done by editing the `elasticsearch.yml` file. Here, you can set parameters such as the cluster name, node name, and network host. To change the port that Elasticsearch runs on, simply add the following line to `elasticsearch.yml`: `http.port: 9201`.

To optimize Elasticsearch for your specific use case, you can adjust memory allocation by setting the `ES_JAVA_OPTS` environment variable. For example, to allocate 2GB of memory to Elasticsearch, run the following command before starting Elasticsearch: `ES_JAVA_OPTS=-Xms2g -Xmx2g`.

You can also optimize indexing by adjusting the refresh interval. By default, Elasticsearch refreshes indices every second, but you can increase this interval to reduce CPU usage by adding the following line to `elasticsearch.yml`: `index.refresh_interval: 5s`.

If this caught your attention, see: Gas Line

Configuring

Computer server in data center room
Credit: pexels.com, Computer server in data center room

To configure Elasticsearch, you'll need to edit the `elasticsearch.yml` file, located in the config directory of the Elasticsearch installation. This is where you can set parameters like the cluster name, node name, and network host.

You can change the port that Elasticsearch runs on by adding a specific line to the `elasticsearch.yml` file. After making changes to the configuration file, you'll need to restart Elasticsearch for the changes to take effect.

If you're looking to change the password for the elastic built-in user, you can refer to a separate guide for instructions.

To change settings like the Elasticsearch password, you'll need to edit the `.env` file. This file contains example contents that you can use as a reference.

Optimizing

Optimizing Elasticsearch can make a big difference in its performance. You can start by adjusting the memory allocation to suit your needs. To allocate more memory, you can set the `ES_JAVA_OPTS` environment variable to a higher value, such as 2GB.

A computer room with a monitor and computer
Credit: pexels.com, A computer room with a monitor and computer

Increasing the JVM heap size can help with large datasets. This can be done by setting the `ES_JAVA_OPTS` environment variable before starting Elasticsearch.

Optimizing indexing is another crucial step. By default, Elasticsearch refreshes indices every second. If you're performing a large number of writes, you may want to increase this interval to reduce CPU usage.

Env Variable Settings

You can adjust Elasticsearch's memory allocation by setting the `ES_JAVA_OPTS` environment variable. This allows you to increase or decrease the default 1GB of memory allocated to the JVM heap.

To allocate more memory to Elasticsearch, you can run a command before starting Elasticsearch, such as allocating 2GB of memory.

You can also adjust indexing settings by modifying the `elasticsearch.yml` file. For example, you can increase the refresh interval to reduce CPU usage when performing a large number of writes.

We also offer some advanced environment variable settings for changing the settings of start-local. These settings are suitable for advanced use cases, such as CI/CD integrations.

To change settings like Elasticsearch password, you can edit the .env file.

A unique perspective: How to Run an Html File

System Requirements and Setup

Credit: youtube.com, How to Install Elasticsearch & Kibana on Windows 10/11 (2025) | Step-by-Step Guide

To run Elasticsearch locally, you'll need to set up the necessary environment.

The setup process begins by running the start-local script using curl. This script creates a folder called elastic-start-local containing essential files.

The files created by the script include Docker Compose configuration, environment settings, and scripts to start and stop Elasticsearch and Kibana.

Choose Installation Version

To choose the installation version, you can specify a different version using the -v parameter. This allows you to install a specific version of Elastic Stack, such as Elasticsearch and Kibana 8.16.0.

You can also use the -v parameter to install beta releases, which can be useful for testing an upcoming release. For instance, you can install the 9.0.0-beta1 using the command.

The default installation installs the latest stable version of Elastic Stack.

System Requirements

To get started with our system, you'll need to meet some basic requirements.

You'll need at least 5 GB of available disk space to run our system smoothly.

Credit: youtube.com, User and System Requirements - Georgia Tech - Software Development Process

We've tested our system on Linux and macOS, and it works like a charm on both platforms.

If you're using Microsoft Windows, you can still use our system by enabling the Windows Subsystem for Linux (WSL).

Here's a quick rundown of our system requirements:

  • 5 GB of available disk space
  • Docker
  • Works on Linux and macOS
  • On Microsoft Windows it works using Windows Subsystem for Linux (WSL)

Docker

To run Elasticsearch locally, you'll need to have Docker installed. You can download the Docker installation script by running a command in your terminal.

If you're new to Docker, it's a great way to run and manage Elasticsearch locally. The installation process is straightforward and easy to follow.

To get started, you'll need to download the Docker installation script. Run this command in your terminal:

This will download the Docker installation script.

Once Docker is installed, you can download the Elasticsearch container by running the following command:

This command will download the Elasticsearch container.

After downloading the container, you'll need to verify that it's running. Run this command to check the status of the container:

Credit: youtube.com, Elasticsearch on Docker Tutorial | Elastic Docker Containers Configuration - Sematext

This command will show a list of containers, with Elasticsearch listed among them.

Here's a quick rundown of the steps to get Elasticsearch up and running with Docker:

  • Download the Docker installation script
  • Install Docker
  • Download the Elasticsearch container
  • Verify that the container is running

Troubleshooting and Maintenance

If you encounter issues with your locally running Elasticsearch, the first step is to check the Elasticsearch logs, which can be found in the `logs` directory of your Elasticsearch installation.

You can also use the `elasticsearch --version` command to verify that you're running the correct version of Elasticsearch.

Check the Elasticsearch configuration file, `elasticsearch.yml`, to ensure that it's correctly configured for local development.

Running Elasticsearch on a different port, such as 9202, can help resolve port conflicts with other applications.

If you've made changes to the Elasticsearch configuration, you may need to restart the Elasticsearch service for the changes to take effect.

Regularly backing up your Elasticsearch data is essential for maintaining data integrity and ensuring that you can recover in case of a disaster.

Security and Authentication

Credit: youtube.com, Elasticsearch 8 Security Tutorial - Setup Elasticsearch Password (Authentication)

To run Elasticsearch locally, you'll want to ensure you have a secure connection. Elasticsearch uses SSL/TLS to encrypt data in transit, which is enabled by default.

You can verify this by checking the Elasticsearch configuration file, which is typically located at `elasticsearch.yml`. By default, this file includes settings for SSL/TLS, such as the path to the keystore and the keystore password.

To disable SSL/TLS, you can simply comment out these settings in the configuration file.

Api Key

An API key is a crucial component of security and authentication, and it's used to connect to Elasticsearch with the Elastic SDK or REST API.

The API key is generated and stored in the .env file as ES_LOCAL_API_KEY. You can find this key in the elastic-start-local folder.

To check the connection to Elasticsearch, use curl in the elastic-start-local folder.

Discover more: Bulk Api Elasticsearch

Es Local Password

Setting the Elasticsearch password manually can be done using the ES_LOCAL_PASSWORD environment variable. This is done by setting the variable before executing the script.

You need to set the environment variable with a strong password to avoid security risks. Please note that using a weak password can be dangerous for Elasticsearch authentication.

To set the supersecret password for Elasticsearch, use the command: This command will set the password.

Logging

Credit: youtube.com, Setup ELK in local | elastic search, kibana, logstash

To log Elasticsearch locally, you'll need to configure the logging settings in your Elasticsearch configuration file.

The logging settings are stored in the `logging.yml` file, which is located in the `config` directory of your Elasticsearch installation.

You can configure the logging level by setting the `log.level` property to a specific level, such as `INFO`, `WARN`, or `DEBUG`.

For example, to set the logging level to `INFO`, you would add the following line to your `logging.yml` file: `log.level: INFO`.

The logging output can be directed to a file or the console by setting the `log.output` property.

For example, to log to a file named `elasticsearch.log`, you would add the following line to your `logging.yml` file: `log.output: elasticsearch.log`.

Elasticsearch also supports logging to a remote server using the `logstash` plugin.

To use the `logstash` plugin, you'll need to add the following line to your `logging.yml` file: `logstash: true`.

The logging settings can be overridden at runtime using the `elasticsearch.log` command-line option.

For example, to set the logging level to `DEBUG` when starting Elasticsearch, you would use the following command: `elasticsearch -log.level=DEBUG`.

For more insights, see: Debug Azure Function Locally

Customizing Settings

Credit: youtube.com, Elasticsearch 8.9 install/start with custom user process

Customizing settings is a breeze. You can change settings like the Elasticsearch password by editing the .env file.

The .env file contains example contents that show you how to make these changes. For instance, you can edit the Elasticsearch password by adding the relevant information to the file.

After changing the .env file, don't forget to restart the services using the stop and start commands. This ensures that your changes take effect.

Using ENV variables is another way to customize settings, but it's recommended for advanced use cases only. This approach is best suited for CI/CD integrations where you need to automate certain tasks.

Oscar Hettinger

Writer

Oscar Hettinger is a skilled writer with a passion for crafting informative and engaging content. With a keen eye for detail, he has established himself as a go-to expert in the tech industry, covering topics such as cloud storage and productivity tools. His work has been featured in various online publications, where he has shared his insights on Google Drive subtitle management and other related topics.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.