- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
Deploy and Configure a Multi-Node Elasticsearch Cluster
Before we can get hands-on with indexing, searching, and aggregating our data with Elasticsearch, we first need to know how to prepare a system and how to deploy and configure Elasticsearch. In this hands-on lab, you will deploy a 6-node Elasticsearch cluster with a specific set of configuration requirements. Specifically, you will: * Create an `elastic` user * Configure the open limit * Set memory map limits via sysctl * Deploy Elasticsearch from an archive * Specify Elasticsearch cluster and node names * Create custom attributes for Elasticsearch nodes * Assign Elasticsearch node roles * Configure the Elasticsearch Java virtual machine (JVM) heap * Bind Elasticsearch to specific network addresses * Configure Elasticsearch node discovery * Configure Elasticsearch cluster bootstrap * Start Elasticsearch as a daemon * `curl` the Elasticsearch nodes to check status and configuration
Lab Info
Table of Contents
-
Challenge
Prepare each node, create the elastic user, and deploy Elasticsearch.
Create the
elasticuser:sudo useradd elasticOpen the
limits.conffile as root:sudo vim /etc/security/limits.confAdd the following line near the bottom:
elastic - nofile 65536Open the
sysctl.conffile asroot:sudo vim /etc/sysctl.confAdd the following line at the bottom:
vm.max_map_count=262144Load the new sysctl values:
sudo sysctl -pBecome the
elasticuser:sudo su - elasticDownload the binaries for Elasticsearch 7.2.1 in the
elasticuser's home directory:curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.1-linux-x86_64.tar.gzUnpack the archive:
tar -xzvf elasticsearch-7.2.1-linux-x86_64.tar.gzRemove the archive:
rm elasticsearch-7.2.1-linux-x86_64.tar.gzRename the unpacked directory:
mv elasticsearch-7.2.1 elasticsearch -
Challenge
Configure each node's elasticsearch.yml per instructions.
Log in to each node and become the
elasticuser:sudo su - elasticOpen the
elasticsearch.ymlfile:vim /home/elastic/elasticsearch/config/elasticsearch.ymlChange the following line:
#cluster.name: my-applicationto
cluster.name: linux_academyChange the following line on master-1:
#node.name: node-1to
node.name: master-1Change the following line on master-2:
#node.name: node-1to
node.name: master-2Change the following line on master-3:
#node.name: node-1to
node.name: master-3Change the following line on data-1:
#node.name: node-1to
node.name: data-1Change the following line on data-2:
#node.name: node-1to
node.name: data-2Change the following line on data-3:
#node.name: node-1to
node.name: data-3Change the following line on master-1:
#node.attr.rack: r1to
node.attr.zone: 1Change the following line on master-2:
#node.attr.rack: r1to
node.attr.zone: 2Change the following line on master-3:
#node.attr.rack: r1to
node.attr.zone: 3Change the following line on data-1:
#node.attr.rack: r1to
node.attr.zone: 1Add the following line on data-1:
node.attr.temp: hotChange the following line on data-2:
#node.attr.rack: r1to
node.attr.zone: 2Add the following line on data-2:
node.attr.temp: hotChange the following line on data-3:
#node.attr.rack: r1to
node.attr.zone: 3Add the following line on data-3:
node.attr.temp: warmAdd the following lines on master-1:
node.master: true node.data: false node.ingest: falseAdd the following lines on master-2:
node.master: true node.data: false node.ingest: falseAdd the following lines on master-3:
node.master: true node.data: false node.ingest: falseAdd the following lines on data-1:
node.master: false node.data: true node.ingest: trueAdd the following lines on data-2:
node.master: false node.data: true node.ingest: trueAdd the following lines on data-3:
node.master: false node.data: true node.ingest: falseChange the following on each node:
#network.host: 192.168.0.1to
network.host: [_local_, _site_]Change the following on each node:
#discovery.seed_hosts: ["host1", "host2"]to
discovery.seed_hosts: ["10.0.1.101", "10.0.1.102", "10.0.1.103"]Change the following on each node:
#cluster.initial_master_nodes: ["node-1", "node-2"]to
cluster.initial_master_nodes: ["master-1", "master-2", "master-3"] -
Challenge
Configure the heap for each node per instructions.
Log in to each master node and become the
elasticuser:sudo su - elasticOpen the
jvm.optionsfile:vim /home/elastic/elasticsearch/config/jvm.optionsChange the following lines:
-Xms1g -Xmx1gto
-Xms768m -Xmx768mLog in to each data node and become the
elasticuser:sudo su - elasticOpen the
jvm.optionsfile:vim /home/elastic/elasticsearch/config/jvm.optionsChange the following lines:
-Xms1g -Xmx1gto
-Xms2g -Xmx2g -
Challenge
Start Elasticsearch as a daemon on each node.
Log in to each node and become the
elasticuser:sudo su - elasticSwitch to the
elasticsearchdirectory:cd /home/elastic/elasticsearchStart Elasticsearch as a daemon:
./bin/elasticsearch -d -p pidCheck the startup process:
less /home/elastic/elasticsearch/logs/linux_academy.logCheck the node configuration:
curl localhost:9200/_cat/nodes?v
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.