Skip to content
Snippets Groups Projects
README.md 4.74 KiB
Newer Older
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
### Installer Elasticsearch

# Installation Elasticsearch & Kibana 

## Installer et lancer Elasticsearch
``` bash
# Creer un network 
docker network create elastic 
# Télécharger l'image Elastic
Yifan.Tian's avatar
Yifan.Tian committed
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.6.0
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
# Lancer l'image 
Yifan.Tian's avatar
Yifan.Tian committed
docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -t docker.elastic.co/elasticsearch/elasticsearch:8.6.0
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
```
Yifan.Tian's avatar
Yifan.Tian committed
**Note** : Durant le lancement dans le terminal ou dans Docker desktop vont apparaitre des informations suivantes (pensez à les copier-coller dans un fichier, elles vont vous servir après) :
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
```
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-> Elasticsearch security features have been automatically configured!
-> Authentication is enabled and cluster connections are encrypted.
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
->  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
  IvI2WWQ89b2jXfeFvDHN
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
->  HTTP CA certificate SHA-256 fingerprint:
  ae12d482d7f1e668c091d17d81e94b13f1d6ab45bb6afafd0c9de6a66fadbe57
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
->  Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMTkuMC4yOjkyMDAiXSwiZmdyIjoiYWUxMmQ0ODJkN2YxZTY2OGMwOTFkMTdkODFlOTRiMTNmMWQ2YWI0NWJiNmFmYWZkMGM5ZGU2YTY2ZmFkYmU1NyIsImtleSI6IlQwbG81SU1CNm9sMWo5bnN0YklrOjJsdXBWM0hPUU1pWmN4cl9JNGZ1elEifQ==
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
-> Configure other nodes to join this cluster:
* Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMTkuMC4yOjkyMDAiXSwiZmdyIjoiYWUxMmQ0ODJkN2YxZTY2OGMwOTFkMTdkODFlOTRiMTNmMWQ2YWI0NWJiNmFmYWZkMGM5ZGU2YTY2ZmFkYmU1NyIsImtleSI6IlVVbG81SU1CNm9sMWo5bnN0YkkzOktFbkRKYlVOVDhTMXQyMklSZDlEMncifQ==
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
  If you're running in Docker, copy the enrollment token and run:
  `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.4.3`
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
```
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
### ATTENTION **Converser ses informations**
* Mot de passe pour votre user "elasticsearch"
* Enrollment token pour Kibana

Yifan.Tian's avatar
Yifan.Tian committed

Laissez le terminal roule, ouvrez un nouveau terminal et lancez les commandes suivantes

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
``` bash
# Copier le certificat
docker cp es-node01:/usr/share/elasticsearch/config/certs/http_ca.crt .
# Lancer la commande 
curl --cacert http_ca.crt -u elastic https://localhost:9200
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
```
Yifan.Tian's avatar
Yifan.Tian committed
Cela va vous demander votre mot de passe, ce sera le mot de passe que vous avez sauvegardé précédemment 
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
Réponse attendu :
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
![attendu1](/images/reponseattenduinstallation.PNG)
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
``` bash
### Installer Kibana
docker pull docker.elastic.co/kibana/kibana:8.4.2  
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.4.2
```
Pour accéder au Kibana, vous devez utiliser le login "elasticsearch" et le mot de passe
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
## Partie 1 : Elastic Search dans Kibana et REST API
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
Aller dans Kibana, choisir Dev Tools>Console
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
#### Q1. Ajouter le nom d'une personne qui s'appelle Brayan dans l'index customer 1
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
Réponse attendu :
> POST /customer/_doc/1  
{  
    "name": "Brayan"  
}
#### Q2. Ajouter l'age de 23 pour Brayan
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Réponse attendu :
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
> POST /customer/_doc/1  
{  
    "age": 23  
}
#### Q3. Ajouter 10000 dans la balance de Brayan
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Réponse attendu :
Anh.Nguyen2's avatar
Anh.Nguyen2 committed
> POST /customer/_doc/1  
{  
    "balance": 10000  
}
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
#### Q4. Ouvrir un nouveau terminal, lancer la commande :
>  curl --cacert http_ca.crt -u elastic https://localhost:9200/customer/_doc/1  
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
On doit pouvoir voir Brayan 23 ans avec 5000€ dans sa balance
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
#### Q5. Supprimer Brayan :) 
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
Vous pouvez utiliser la ligne de commande ou Kibana comme vous voulez. Vérifiez bien que Brayan n'existe plus dans notre base de données
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
Note : Pour ajouter plusieurs documents en même temps, nous allons utiliser la requête _bulk
#### Q6.  Ajouter le tableau suivant :
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
 ![Q2](/images/tableau.png)
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
#### Q7. Trouver le client le plus jeune
#### Q8. Trouver la balance la plus élevé
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
### Partie 2 : Agrégation de données et visualisation dans Kibana
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
Grâce aux visualisation, répondez aux questions suivants :
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
* Le nombre total de vol
* Le pourcentage de vol en retard
* Le billet moyen le plus cher
* Le jour où il y a eu le plus de vol
* Le nombre de vol retardé avec un retard supérieur à 360 minutes
Anh.Nguyen2's avatar
Anh.Nguyen2 committed

Anh.Nguyen2's avatar
Anh.Nguyen2 committed
### Partie 3 : API Elasticsearch