Skip to content

elastic/start-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Try Elasticsearch and Kibana locally

Try Elasticsearch and Kibana using a simple shell script for local development. It uses docker to install the services and offers a trial Platinum license for 1 month. After the month the license will become Free and Open Basic.

For instance, the Platinum version offers ELSER retrieval model and the Inference API. The Free and Open Basic includes the vector search and ES|QL. For a full list of subscription and features read this page.

This script can be executed only on Linux and Mac environments. We do not support Microsoft Windows at the moment.

Please note: this script is only for local testing, do not run it in a production environment!

For production installation please reference to the official documentation. For Kibana, this is the page to read.

How to execute the script

The start-local script has been designed to be executed using curl, as follows (NOTE: the script has not yet been published on elastic.co):

curl -fsSL https://elastic.co/start-local | sh

The script will create theelastic-start-local folder with two files: docker-compose.yml and .env. The first docker-compose.yml is a standard docker file containing the configurations for Elasticsearch and Kibana services. The second file .env contains all the settings, like the Elasticsearch password.

After the execution

After executing the start-local script you will have Elasticsearch running on http://localhost:9200 and Kibana on http://localhost:5601.

The script generates a random password for the elastic user. The password is displayed at the end of the installation and stored in the .env file.

We disabled HTTPS and we used Basic acces authentication to connect to Elasticsearch. This configuration should be used only for local testing. For security reason, Elasticsearch and Kibana are accessible only using localhost.

We also generated an API key for Elasticsearch, this can be useful to connect to Elasticsearch using the Elastic SDK or directly with REST API. The API key is stored in the .env file with the key ES_LOCAL_API_KEY.

For instance, using curl, you can check the connection to Elasticsearch using the following command, inside the elastic-start-local folder:

. .env
curl $ES_LOCAL_URL -H "Authorization: ApiKey ${ES_LOCAL_API_KEY}"

Docker compose

If you navigate to the elastic-start-local folder, you can manage the services using docker compose command.

For instance, to restart the services, you can run the command:

docker compose up --wait

To stop the services you can run the command:

docker compose stop

If you are using docker-compose instead of docker compose the syntax is the same, apart for the up --wait option which may not be available. In this case you can use the following command, to start the services:

docker-compose up -d

Uninstall

We provided a uninstall.sh script for removing the installation of start-local.

You can just run this script. Please note, this will erase all data without the possibility of recovery.

cd elastic-start-local
./uninstall.sh

Logging

In case of failure, the start-local generates a log error in the file error-start-local.log.

This file contains the logs generated by Elasticsearch and Kibana using the docker logs command.

How to change the settings

If you want to change the settings, for instance the Elasticsearch password, you can edit the .env file and change the values.

The .env file contains some settings like as follows:

ES_LOCAL_VERSION=8.15.2
ES_LOCAL_URL=http://localhost:9200
ES_LOCAL_CONTAINER_NAME=es-local-dev
ES_LOCAL_DOCKER_NETWORK=elastic-net
ES_LOCAL_PASSWORD=hOalVFrN
ES_LOCAL_PORT=9200
KIBANA_LOCAL_CONTAINER_NAME=kibana-local-dev
KIBANA_LOCAL_PORT=5601
KIBANA_LOCAL_PASSWORD=YJFbhLJL
ES_LOCAL_API_KEY=df34grtk...==

For instance, ES_LOCAL_VERSION is the Elasticsearch and Kibana version used for the installation (e.g. 8.15.2).

After changing the .env file you need to restart the services using the command:

docker compose restart

If you are using docker-compose the command will be:

docker-compose restart

Testing the installer

We used bashunit for testing the script.

The tests are in the /tests folder.

To run the tests you need first to install bashunit as follows:

curl -s https://bashunit.typeddevs.com/install.sh | bash

This command will create a lib folder with the bashunit command.

You can now execute the tests using the following command:

lib/bashunit

The tests execute the start-local.sh and check if Elasticsearch and Kibana are running.

We also executed a local web server to test the installation using a pipeline from an URL. To test this you need to have PHP installed.