Install and configure a one-node self-managed Elasticsearch cluster for development and testing purposes.
Elasticsearch is a distributed RESTful search and analytics engine supporting textual, numeric, geospatial and other types of structured and unstructured data. This page provides instructions on how to install and configure a one-node self-managed Elasticsearch cluster for development and testing purposes only (i.e. non-production).
Please run the following commands via your command line to install Elasticsearch 7.x and all required dependencies.
# Install dependencies and add the Elastic repository
$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ sudo apt-get install apt-transport-https
$ echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
$ sudo apt-get update
$ sudo apt-get install elasticsearch
We shall configure our one-node Elasticsearch cluster by defining an explicit cluster name, node name, network host and port, and node type in the Elasticsearch configuration file found at
/etc/elasticsearch/elasticsearch.yml, as follows:
# Start a root shell
$ sudo -s
# Edit the Elasticsearch configuration
$ vi /etc/elasticsearch/elasticsearch.yml
# Single-node cluster and node configuration
discovery.seed_hosts: ["localhost", "127.0.0.1"]
# Set the node type for our one-node development cluster
# Single node means that the node will elect itself master and not join a cluster with any other node
In the example configuration above, we have configured a single node via the discovery.type property, meaning that the node will elect itself master and not join a cluster with any other node. We have also explicitly set the network interface (
localhost) and HTTP port number (
9200) to listen on for requests via the network.host and http.port properties respectively.
Optionally, we may explicitly set the JVM heap size by editing
# Edit the JVM heap size
$ vi /etc/elasticsearch/jvm.options.d/jvm-heap-size.options
In the example configuration above, we have set the maximum JVM heap size that can be used by Elasticsearch to 2GB.
To start Elasticsearch, please run the following command via your command line:
# Start Elasticsearch
$ sudo systemctl start elasticsearch.service
To configure Elasticsearch to start on-boot, please run the following command via your command line:
# Configure Elasticsearch to start on-boot
$ sudo systemctl daemon-reload
$ sudo systemctl enable elasticsearch.service
To test that Elasticsearch is running, we can use the
curlpackage and send a HTTP
GETrequest to Elasticsearch as follows:
# Test that Elasticsearch is running and accepting HTTP requests
$ curl -X GET "localhost:9200/?pretty"