Installing Elasticsearch
Elasticsearch can be downloaded from the following URL: https://www.elastic.co/downloads/elasticsearch
This document is using elasticsearch-7.16.2-linux-x86_64.tar.gz.
Installing a small instance of a single node Elasticsearch cluster will involve the following steps:
- Logon as the root user (or prefix commands with ‘sudo’).
-
Set the vm.max_map_count setting in the current context and the /etc/sysctl.conf file.
echo 'vm.max_map_count=262144' >> /etc/sysctl.conf sysctl vm.max_map_count=262144
-
Create an Elasticsearch user.
useradd -c "Elasticsearch User" elastic
-
Create folder structure and change ownership.
mkdir -p /opt/es/data mkdir -p /opt/es/logs mkdir -p /opt/es/backups chown -R elastic:elastic /opt/es
-
Extract the downloaded Elasticsearch package into /opt, create a symlink and change ownerships.
cd /opt tar xzf /path/to/elasticsearch-7.14.0-linux-x86_64.tar.gz ln -s elasticsearch-7.14.0 elasticsearch chown -R elastic:elastic elasticsearch-7.14.0
-
Create/edit the elasticsearch configuration file and ensure the following are set: /opt/elasticsearch/config/elasticsearch.yml
cluster.name: esdata node.name: solo path.data: /opt/es/data path.logs: /opt/es/logs path.repo: /opt/es/backups network.host: ["_local_","_site_"] http.port: 9200 discovery.type: single-node xpack.security.enabled: false
-
Create/edit the jvm parameters in the configuration file /opt/elasticsearch/config/jvm.options. Set the memory requirements for the Elasticsearch instance. No more than half the available RAM available on a machine. You could use 256m as well.
-Xms512m -Xmx512m
-
Create a systemd service (if your system uses systemd) by creating the following file: /etc/systemd/system/elasticsearch.service with the following content:
[Service] User=elastic Group=elastic LimitNOFILE=65536 LimitNPROC=4096 ExecStart=/opt/elasticsearch/bin/elasticsearch Restart=always RestartSec=10 [Install] WantedBy=multi-user.target
-
Open the firewall (if using firewalld and the elasticsearch service is already in place)
firewall-cmd --zone=public --add-service=elasticsearch --permanent firewall-cmd --zone=public --add-service=elasticsearch
-
Enable and start the elasticsearch service.
systemctl enable elasticsearch systemctl start elasticsearch
-
View the startup logs and ensure all looks good:
journalctl -efu elasticsearch