Step‑by‑Step Guide to Install an ElasticSearch 7.17.x Cluster on Ubuntu
This tutorial walks through installing Java, configuring hostnames and hosts files, synchronizing time, tuning system parameters, creating Elasticsearch directories and users, downloading and extracting ElasticSearch 7.17.x, setting up its configuration and systemd service, starting the three‑node cluster, and verifying its health on Ubuntu 22.04.
Overview
The article explains how to build a three‑node ElasticSearch 7.17.x cluster on Ubuntu 22.04 using binary packages. It covers prerequisite software, host and network configuration, system tuning, user and directory setup, ElasticSearch installation, service definition, startup, and health verification.
Environment Information
The cluster consists of three servers:
ELK01 : IP 10.0.0.40, Ubuntu 22.04
ELK02 : IP 10.0.0.41, Ubuntu 22.04
ELK03 : IP 10.0.0.42, Ubuntu 22.04
Practical Steps
Install JDK (required on all nodes)
ElasticSearch runs on Java, so JDK 11 is installed on each host.
# wget https://mirrors.huaweicloud.com/openjdk/11.0.2/openjdk-11.0.2_linux-x64_bin.tar.gz
# tar -xvf openjdk-11.0.2_linux-x64_bin.tar.gz
# ln -s /root/jdk-11.0.2 /usr/local/jdk11
# vim /etc/profile # add:
# export JAVA_HOME=/usr/local/jdk11
# export PATH=$JAVA_HOME/bin:$PATH
# source /etc/profile
# java -version # should show OpenJDK 11.0.2Configure Hostnames and /etc/hosts
Set each node's hostname and add name‑to‑IP mappings.
# hostnamectl set-hostname ELK01 # on ELK01
# hostnamectl set-hostname ELK02 # on ELK02
# hostnamectl set-hostname ELK03 # on ELK03
# vim /etc/hosts
10.0.0.40 ELK01
10.0.0.41 ELK02
10.0.0.42 ELK03Synchronize System Time
Install ntpdate and schedule periodic sync.
# ln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# apt -y install ntpdate
# ntpdate ntp.aliyun.com
# echo "*/5 * * * * /usr/sbin/ntpdate ntp.aliyun.com" > /var/spool/cron/crontabs/rootSystem Parameter Tuning (all nodes)
Increase file descriptors, virtual memory, and network limits for ElasticSearch.
# vim /etc/sysctl.conf
fs.file-max = 655360
vm.max_map_count = 2147483642
vm.swappiness = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 60
net.ipv4.tcp_keepalive_probes = 10
net.ipv4.tcp_max_syn_backlog = 4096
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 16384
net.core.rmem_max = 262144
net.core.wmem_max = 262144
# sysctl -p
# sysctl -q vm.max_map_count # verify valueCreate Directories and Elasticsearch User
Prepare data and log directories and a dedicated user.
# mkdir -p /data/elasticsearch
# mkdir -p /var/log/elasticsearch
# useradd elasticsearch
# chown elasticsearch:elasticsearch -R /data/elasticsearch
# chown elasticsearch:elasticsearch -R /var/log/elasticsearchSet User Limits
Allow the elasticsearch user to open many files and processes.
# vim /etc/security/limits.conf
elasticsearch hard nofile 655360
elasticsearch soft nofile 655360
elasticsearch hard nproc 8192
elasticsearch soft nproc 8192
elasticsearch hard memlock unlimited
elasticsearch soft memlock unlimitedDownload and Extract ElasticSearch
Obtain the 7.17.x tarball from the official archive, extract it, and create a symlink.
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.26-linux-x86_64.tar.gz
# tar -xvf elasticsearch-7.17.26-linux-x86_64.tar.gz
# mv elasticsearch-7.17.26 /data/
# chown elasticsearch:elasticsearch -R /data/elasticsearch-7.17.26
# ln -s /data/elasticsearch-7.17.26 /usr/local/es7Configure ElasticSearch
Edit /usr/local/es7/config/elasticsearch.yml with cluster settings.
# vim /usr/local/es7/config/elasticsearch.yml
cluster.name: es7
path.data: /data/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["ELK01", "ELK02", "ELK03"]
cluster.initial_master_nodes: ["ELK01", "ELK02", "ELK03"]
# node.name can be set per host, e.g. node.name: ELK01Create systemd Service
Define a service unit to manage ElasticSearch.
# vim /lib/systemd/system/es.service
[Unit]
Description=elasticsearch service
Documentation=https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index.html
After=network.target auditd.service
[Service]
LimitMEMLOCK=infinity
User=elasticsearch
ExecStart=/usr/local/es7/bin/elasticsearch
TimeoutStopSec=0
TimeoutStartSec=0
[Install]
WantedBy=multi-user.targetStart the Cluster
Reload systemd, enable and start the service on each node.
# systemctl daemon-reload
# systemctl start es
# systemctl status es # should show active (running)Verify Cluster Health
Check that all three nodes are joined and the cluster is green.
# curl 10.0.0.40:9200/_cat/nodes
# curl 10.0.0.40:9200/_cat/health?vWhen the health output shows green and lists three nodes, the ElasticSearch cluster is successfully deployed.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
