Install Elasticsearch 7.x on Debian Buster.
Installation
Install the required packages.
$ sudo apt-get install curl gnupg apt-transport-https
Import Elasticsearch public key using curl
.
$ curl https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
Define the Elasticsearch repository.
$ echo "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
Update package index.
$ sudo apt-get update
Install Elasticsearch.
$ sudo apt-get install elasticsearch-oss
The service will be disabled by default.
$ systemctl status elasticsearch.service ● elasticsearch.service - Elasticsearch Loaded: loaded (/lib/systemd/system/elasticsearch.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: http://www.elastic.co
JVM configuration
The first thing is to increase JVM heap size, which is by default set to 1G.
Small instance
If it is a small server that contains less than 32G
of available memory, then use about half that.
$ grep ^MemTotal /proc/meminfo | awk '{printf "%d\n",$2/1024}' 7865
$ grep ^MemTotal /proc/meminfo | awk '{printf "%d\n",($2*0.5)/1024}' 3932
Use around 4G
in this case.
Regular instance
If the server contains more than 32G
(like 64G
) of available memory, and you can assign 32G
or more, but you still want to take advantage of the Compressed Oops, then perform the following steps to determine the correct value.
In general, you need to find the transition point.
$ /usr/share/elasticsearch/jdk/bin/java -Xmx30g -XX:+PrintFlagsFinal 2>/dev/null | grep UseCompressedOops bool UseCompressedOops = true {lp64_product} {ergonomic}
$ /usr/share/elasticsearch/jdk/bin/java -Xmx32g -XX:+PrintFlagsFinal 2>/dev/null | grep UseCompressedOops bool UseCompressedOops = false {lp64_product} {default}
Use this simple shell script to determine the sweet spot.
$ compressed_oops_true=""; \ [ -f /usr/share/elasticsearch/jdk/bin/java ] && \ for compressed_oops in $(seq 30000 100 34000); do /usr/share/elasticsearch/jdk/bin/java -Xmx${compressed_oops}m -XX:+PrintFlagsFinal 2>/dev/null | \ grep UseCompressedOops | \ grep false >/dev/null && \ break; compressed_oops_true=$compressed_oops; \ done; \ [ -n "$compressed_oops_true" ] && \ echo "Compressed Oops was true for ${compressed_oops_true}m and false for ${compressed_oops}m" Compressed Oops was true for 32700m and false for 32800m
Use no more then 32700M
in this case.
Alter JVM heap size
Edit /etc/elasticsearch/jvm.options
to edit min and max JVM heap size.
-Xms4g -Xmx4g
Elasticsearch configuration
Edit /etc/elasticsearch/elasticsearch.yml
to alter initial settings like listen address, cluster, and node name.
cluster.name: elasticsearch-single-node-cluster node.name: single-node network.host: 10.0.2.15 discovery.type: single-node
I also have disabled discovery, so it will not join a cluster with any other node.
Manage service
Start the Elasticsearch service.
$ sudo systemctl start elasticsearch.service
Enable Elasticsearch service at boot.
$ sudo systemctl enable elasticsearch.service
Check service status
Node name and version.
$ curl http://10.0.2.15:9200 { "name" : "single-node", "cluster_name" : "elasticsearch-single-node-cluster", "cluster_uuid" : "g6PWsnkFRWG-RLyt1-aXSw", "version" : { "number" : "7.5.1", "build_flavor" : "oss", "build_type" : "deb", "build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96", "build_date" : "2019-12-16T22:57:37.835892Z", "build_snapshot" : false, "lucene_version" : "8.3.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
Cluster status.
$ curl http://10.0.2.15:9200/_cluster/health?pretty { "cluster_name" : "elasticsearch-single-node-cluster", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 0, "active_shards" : 0, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }
List of nodes.
$ curl http://10.0.2.15:9200/_cat/nodes?v ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name 10.0.2.15 55 98 0 0.17 0.18 0.08 dim * single-node