Installation de elasticsearch
Le 6 novembre 2024
En utilisant https://www.aukfood.fr/recherche-plein-texte-avec-nextcloud-et-elasticsearch/
mais en V8 au lie de V7
Installation d'Elasticsearch
J'ai remonté certains bugs (en v6) que je n'ai pas rencontrés en v7. C'est pourquoi je vous conseille d'utiliser la version 7.
Tout d'abord, installer Java :
apt-get update apt-get install apt-transport-https default-jdk
Vérifier que Java est bien installé :
java -version
openjdk version "11.0.24" 2024-07-16
OpenJDK Runtime Environment (build 11.0.24+8-post-Ubuntu-1ubuntu322.04)
OpenJDK 64-Bit Server VM (build 11.0.24+8-post-Ubuntu-1ubuntu322.04, mixed mode, sharing)
On installe la clé GPG et la source APT :
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list remplacé par echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
Puis on installe le paquet :
<apt-get update apt-get install elasticsearch
Activer le service au démarrage :
systemctl enable elasticsearch
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentification requise pour gérer les fichiers d'un service ou d'une unité système.
Multiple identities can be used for authentication:
1. François Bernigaud,,, (francois)
2. Côme Bernigaud,,, (come)
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /lib/systemd/system/elasticsearch.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentification requise pour recharger l’état de systemd.
Multiple identities can be used for authentication:
1. François Bernigaud,,, (francois)
2. Côme Bernigaud,,, (come)
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
systemctl start elasticsearch
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentification requise pour démarrer « elasticsearch.service ».
Multiple identities can be used for authentication:
1. François Bernigaud,,, (francois)
2. Côme Bernigaud,,, (come)
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xeu elasticsearch.service" for details.
sudo systemctl status elasticsearch.service
elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2024-11-06 15:31:48 CET; 7s ago
Docs: https://www.elastic.co
Process: 8011 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=78)
Main PID: 8011 (code=exited, status=78)
CPU: 3.125s
nov. 06 15:31:46 E6320 systemd[1]: Starting Elasticsearch...
nov. 06 15:31:48 E6320 systemd-entrypoint[8011]: ERROR: Missing logging config file at /etc/elasticsearch/log4j2.properties, with exit code 78
nov. 06 15:31:48 E6320 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=78/CONFIG
nov. 06 15:31:48 E6320 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
nov. 06 15:31:48 E6320 systemd[1]: Failed to start Elasticsearch.
nov. 06 15:31:48 E6320 systemd[1]: elasticsearch.service: Consumed 3.125s CPU time.
Une succession d'erreurs, en suivant chatGpt, je crée les fichiers avec le contenu suggéré :
/etc/elasticsearch/log4j2.properties
/etc/elasticsearch/jvm.options
/etc/elasticsearch/elasticsearch.yml
Pour consulter la version d'Elasticsearch :
curl -XGET 'http://localhost:9200'
OK après avoir réactivé la sécurité
Si vous souhaitez ajouter des fichiers PDF à votre index, vous devez installer un plugin :
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment
-> Installing ingest-attachment
[ingest-attachment] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch
-> Please restart Elasticsearch to activate any plugins installed
Et redémarrer Elasticsearch :
systemctl restart elasticsearch
Par défaut, Elasticsearch écoute sur le port 9200.