Déploiement et configuration

Déploiement et configuration d’un cluster Elasticsearch multi-nœuds

Vous êtes un administrateur système à qui l’on a demandé de déployer un cluster Elasticsearch à 6 nœuds avec des exigences de configuration très spécifiques :

Vous devrez créer un utilisateur élastique, puis installer Elasticsearch version 7.11.1 à partir d’une archive située dans /home/elastic/elasticsearch. Chaque instance d’Elasticsearch devra écouter à la fois sur l’adresse locale et sur l’adresse du site. Configurez chaque nœud comme indiqué dans le tableau ci-dessous.

+----------+-----------+-------------------+--------------+----------+
| Server   | Node Name | Attributes        | Roles        | JVM Heap |
+----------+-----------+-------------------+--------------+----------+
| master-1 | master-1  | zone=1            | master       | 768m     |
+----------+-----------+-------------------+--------------+----------+
| master-2 | master-2  | zone=2            | master       | 768m     |
+----------+-----------+-------------------+--------------+----------+
| master-3 | master-3  | zone=3            | master       | 768m     |
+----------+-----------+-------------------+--------------+----------+
| data-1   | data-1    | zone=1, temp=hot  | data, ingest | 2g       |
+----------+-----------+-------------------+--------------+----------+
| data-2   | data-2    | zone=2, temp=hot  | data, ingest | 2g       |
+----------+-----------+-------------------+--------------+----------+
| data-3   | data-3    | zone=3, temp=warm | data         | 2g       |
+----------+-----------+-------------------+--------------+----------+

Préparez chaque nœud, créez l’utilisateur élastique et déployez Elasticsearch.

Create the elastic user:

sudo useradd elastic

Open the limits.conf file as root:

sudo vim /etc/security/limits.conf

Add the following line near the bottom:

elastic - nofile 65536

Open the sysctl.conf file as root:

sudo vim /etc/sysctl.conf

Add the following line at the bottom:

vm.max_map_count=262144

Load the new sysctl values:

sudo sysctl -p

Become the elastic user:

sudo su - elastic

Download the binaries for Elasticsearch 7.11.1 in the elastic user’s home directory:

curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.1-linux-x86_64.tar.gz

Unpack the archive:

tar -xzvf elasticsearch-7.11.1-linux-x86_64.tar.gz

Remove the archive:

rm elasticsearch-7.11.1-linux-x86_64.tar.gz

Rename the unpacked directory:

mv elasticsearch-7.11.1 elasticsearch

Configurez le fichier elasticsearch.yml de chaque nœud selon les instructions.

Log in to each node and become the elastic user:

sudo su - elastic

Open the elasticsearch.yml file:

vim /home/elastic/elasticsearch/config/elasticsearch.yml

Change the following line:

#cluster.name: my-application

to

cluster.name: academy

Change the following line on master-1:

#node.name: node-1

to

node.name: master-1

Change the following line on master-2:

#node.name: node-1

to

node.name: master-2

Change the following line on master-3:

#node.name: node-1

to

node.name: master-3

Change the following line on data-1:

#node.name: node-1

to

node.name: data-1

Change the following line on data-2:

#node.name: node-1

to

node.name: data-2

Change the following line on data-3:

#node.name: node-1

to

node.name: data-3

Change the following line on master-1:

#node.attr.rack: r1

to

node.attr.zone: 1

Change the following line on master-2:

#node.attr.rack: r1

to

node.attr.zone: 2

Change the following line on master-3:

#node.attr.rack: r1

to

node.attr.zone: 3

Change the following line on data-1:

#node.attr.rack: r1

to

node.attr.zone: 1

Add the following line on data-1:

node.attr.temp: hot

Change the following line on data-2:

#node.attr.rack: r1

to

node.attr.zone: 2

Add the following line on data-2:

node.attr.temp: hot

Change the following line on data-3:

#node.attr.rack: r1

to

node.attr.zone: 3

Add the following line on data-3:

node.attr.temp: warm

Add the following lines on master-1:

node.master: true
node.data: false
node.ingest: false

Add the following lines on master-2:

node.master: true
node.data: false
node.ingest: false

Add the following lines on master-3:

node.master: true
node.data: false
node.ingest: false

Add the following lines on data-1:

node.master: false
node.data: true
node.ingest: true

Add the following lines on data-2:

node.master: false
node.data: true
node.ingest: true

Add the following lines on data-3:

node.master: false
node.data: true
node.ingest: false

Change the following on each node:

#network.host: 192.168.0.1

to

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"]

Configurez le heap pour chaque nœud par instructions.

Log in to each master node and become the elastic user:

sudo su - elastic

Open the jvm.options file:

vim /home/elastic/elasticsearch/config/jvm.options

Change the following lines:

-Xms1g
-Xmx1g

to

-Xms768m
-Xmx768m

Log in to each data node and become the elastic user:

sudo su - elastic

Open the jvm.options file:

vim /home/elastic/elasticsearch/config/jvm.options

Change the following lines:

-Xms1g
-Xmx1g

to

-Xms2g
-Xmx2g

Démarrez Elasticsearch en tant que démon sur chaque nœud.

Log in to each node and become the elastic user:

sudo su - elastic

Switch to the elasticsearch directory:

cd /home/elastic/elasticsearch

Start Elasticsearch as a daemon:

./bin/elasticsearch -d -p pid

Check the startup process:

less /home/elastic/elasticsearch/logs/academy.log

Check the node configuration:

curl localhost:9200/_cat/nodes?v