Elasticsearch back-end

java

Check java version:

$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1deb10u1, mixed mode, sharing)

If not installed, install with:

(search) [user]@[machine]:~/Development/search/collection/documents$ sudo apt install default-jdk

Make sure the JAVA_HOME environment variable is configured:

(search) [user]@[machine]:~/Development/search$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64

If no path is returned, check where it is:

(search) [user]@[machine]:~/Development/search$ readlink -f $(which java)
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

And in ~/.bashrc or ~/.bash_profile, set: (note: without the /bin/java tail):

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

source the .bashrc or .bash_profile and check again.

https

A package for https support for both server and client.

[user]@[machine]:~$ sudo apt-get install apt-transport-https

Import the elasticsearch PGP key:

[user]@[machine]:~$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Add a repository file in /etc/apt/sources.list.d:

[user]@[machine]:~$ echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

And install with:

[user]@[machine]:~$ sudo apt-get update && sudo apt-get install elasticsearch
Preparing to unpack .../elasticsearch_7.6.1_amd64.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (7.6.1) ...
Setting up elasticsearch (7.6.1) ...
Created elasticsearch keystore in /etc/elasticsearch
Processing triggers for systemd (241-7~deb10u3) ...

There was a warning that On systemd-based distributions, the installation scripts will attempt to set kernel parameters (e.g., vm.max_map_count); you can skip this by masking the systemd-sysctl.service unit. I didn't have the problem, but if that happens you can use the systemctl mask and systemctl unmask commands as a workaround.

Elasticsearch has three configuration files: elasticsearch.yml for configuring Elasticsearch itself, jvm.options for configuring its JVM settings, and log4j2.properties for configuring its logging. For package distributions, the config directory location defaults to /etc/elasticsearch.

Elasticsearch runs in distributed mode by default. Nodes assume that there are or will be a part of the cluster, and during setup nodes try to automatically join the cluster. For now, we are using Elasticsearch for development and testing of data models for parsing and search engine indexing, so we only need a single node that does not need to communicate with other nodes in a LAN. We can play with that later.

$ sudo vi /etc/elasticsearch/elasticsearch.yml

Name the cluster and node:

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: no-cluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: kefir
#

By setting the network host to 0.0.0.0 the node listens on all interfaces and makes it publicly available. The LAN address can be used for LAN access only. By using 127.0.01 it is a stand-alone:

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200

If you now start the service, and point browser to localhost:9200, it looks like:

$ sudo systemctl start elasticsearch.service
$ sudo systemctl stop elasticsearch.service
  • Last modified: 2020/03/25 17:23