OntoPop
Search…
⌃K

Elasticsearch

Install and configure a one-node self-managed Elasticsearch cluster for development and testing purposes.
Last Updated: 08 February 2022 • Page Author: Jillur Quddus

Overview

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).
This page provides instructions on how to install and configure a one-node self-managed Elasticsearch cluster for development and testing purposes only. To configure a secure, distributed and production-ready Elasticsearch cluster, please refer to the Elasticsearch documentation.
The instructions below are for Ubuntu 20.04. Installation instructions for other Linux distributions and Windows may be found at https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html.

Installation

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

Configuration

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
cluster.name: es-development-cluster
node.name: es-development-node-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: localhost
http.port: 9200
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
discovery.type: single-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.
For further and much more extensive information regarding configuring Elasticsearch, please visit https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html

JVM Heap Size

Optionally, we may explicitly set the JVM heap size by editing /etc/elasticsearch/jvm.options.d/jvm-heap-size.options as follows:
# Edit the JVM heap size
$ vi /etc/elasticsearch/jvm.options.d/jvm-heap-size.options
-Xmx2g
In the example configuration above, we have set the maximum JVM heap size that can be used by Elasticsearch to 2GB.
For further information regarding configuring the Elasticsearch JVM heap size, please visit https://www.elastic.co/guide/en/elasticsearch/reference/current/advanced-configuration.html.

Starting Elasticsearch

To start Elasticsearch, please run the following command via your command line:
# Start Elasticsearch
$ sudo systemctl start elasticsearch.service
After starting Elasticsearch with the configuration above, Elasticsearch will listen for HTTP requests at http://localhost:9200.
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 curl package and send a HTTP GET request to Elasticsearch as follows:
# Test that Elasticsearch is running and accepting HTTP requests
$ curl -X GET "localhost:9200/?pretty"

OntoPop Context

To configure OntoPop to use Elasticsearch, please configure the storage.search namespace in application.yml as follows:
Property
Description
Example Value
service
The name of the search service used by OntoPop. Set this to either elasticsearch.
elasticsearch
elasticsearch.url
If using Elasticsearch, the URL to the Elasticsearch server. Note that the URL should be set as an externalized variable and NOT stored as plaintext in application.yml.
http://localhost:9200
elasticsearch.username
If using an instance of Elasticsearch that requires authentication, the username to use as part of basic authentication requests. Note that the username should be set as an externalized variable and NOT stored as plaintext in application.yml.
user
elasticsearch.password
If using an instance of Elasticsearch that requires authentication, the password to use as part of basic authentication requests. Note that the password should be set as an externalized variable and NOT stored as plaintext in application.yml.
password
elasticsearch.ssl
Whether communication with the Elasticsearch instance is secured by SSL.
true
elasticsearch.shards
If using Elasticsearch, the default number of shards to create when creating a new index.
1
elasticsearch.replicas
If using Elasticsearch, the default number of replicas to create when creating a new index.
0