esup-pod

Arborescence des pages

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.


Avertissement

Les commandes suivantes ont été lancées sur une distribution Debian 11.4

Sommaire

Environnement

Création de l'utilisateur Pod

...

Bloc de code
pod@pod:~$ sudo python3 -V
pod@pod:~$ sudo python -V
pod@pod:~$ sudo apt-get install -y python3-pip
pod@pod:~$ sudo pip3 install virtualenvwrapper

Depuis python 3.10, il n'est plus possible d'installer avec pip en dehors d'un environnement. Pour pouvoir installer virtualenvwrapper il faut ajouter à la fin de la ligne --break-system-packages


À la fin du .bashrc, il faut ajouter ces lignes :

...

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
 OK
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install apt-transport-https
(django_pod3) pod@pod:~/django_projects/podv3$ echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update && sudo apt-get install elasticsearch

Ensuite il faut paramétrer l’instance Voici pour ES8 :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ sudo vim /etc/elasticsearch/elasticsearch.yml

Puis  préciser ces valeurs :

Bloc de code
cluster.name: pod-application
node.name: pod-1
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["pod-1"]

Lancement et vérification d'Elasticsearch

Il faut enfin le lancer et vérifier son bon fonctionnement :

...

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
 OK
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install apt-transport-https
(django_pod3) pod@pod:~/django_projects/

...

podv3$ echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update && sudo apt-get install elasticsearch


Ensuite il faut paramétrer l’instance :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ sudo vim /etc/elasticsearch/elasticsearch.yml

Puis préciser ces valeurs :

Bloc de code
cluster.name: pod-application
node.name: pod-1
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["pod-1"]

Il est recommandé d'utiliser le mode security d'ES8.

Générer l'utilisateur pod pour ES :

Bloc de code
cd /etc/elasticsearch/
touch users
touch users_roles
chown root:elasticsearch users
chown root:elasticsearch users_roles
sudo /usr/share/elasticsearch/bin/elasticsearch-users useradd pod -p podpod -r superuser

Génération des certificats (CA + cert) :

Bloc de code
sudo /usr/share/elasticsearch/bin/elasticsearch-certutil ca
sudo /usr/share/elasticsearch/bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add xpack.security.http.ssl.truststore.secure_password

Copier le fichier .p12 dans /etc/elasticsearch/

Bloc de code
sudo cp /usr/share/elasticsearch/elastic-stack-ca.p12 /usr/share/elasticsearch/elastic-certificates.p12 /etc/elasticsearch/
sudo chown pod:pod /etc/elasticsearch/elastic-stack-ca.p12 /etc/elasticsearch/elastic-certificates.p12
sudo chmod +r /etc/elasticsearch/elastic-stack-ca.p12 /etc/elasticsearch/elastic-certificates.p12

Dans /etc/elasticsearch/elasticsearch.yml :

Bloc de code
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.verification_mode: certificate
xpack.security.http.ssl.keystore.path: /etc/elasticsearch/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: /etc/elasticsearch/elastic-certificates.p12

Lancement et vérification d'Elasticsearch

Il faut enfin le lancer et vérifier son bon fonctionnement :

(django_pod3) pod@pod:~/django_projects/podv3$ sudo /etc/init.d/elasticsearch start

(django_pod3) pod@pod:~/django_projects/podv3$ curl -XGET "127.0.0.1:9200"

ou pour ES8 (django_pod3) pod@pod:~/django_projects/podv3$ curl -k -XGET 'https://127.0.0.1:9200' -u pod:podpod

Bloc de code
{
 "name" : "pod-1",
"cluster_name" : "pod-application",
  "cluster_uuid" : "5yhs9zc4SRyjaKYyW7uabQ",
  "version" : {
    "number" : "8.4.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "f56126089ca4db89b631901ad7cce0a8e10e2fe5",
    "build_date" : "2022-08-19T19:23:42.954591481Z",
    "build_snapshot" : false,
    "lucene_version" : "9.3.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Pour utiliser la recherche dans Pod, nous allons avoir besoin également du plugin ICU :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ cd /usr/share/elasticsearch/
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo bin/elasticsearch-plugin install analysis-icu
-> Downloading analysis-icu from elastic
[=================================================] 100%   
-> Installed analysis-icu
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo /etc/init.d/elasticsearch restart
[ ok ] Restarting elasticsearch (via systemctl): elasticsearch.service.

Si vous utilisez derrière un proxy

...

(django_pod3) pod@pod:~/django_projects/podv3$ curl -XGET "127.0.0.1:9200"

Bloc de code
{
 "name" : "pod-1",
"cluster_name" : "pod-application",
  "cluster_uuid" : "5yhs9zc4SRyjaKYyW7uabQ",
  "version" : {
    "number" : "8.4.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "f56126089ca4db89b631901ad7cce0a8e10e2fe5",
    "build_date" : "2022-08-19T19:23:42.954591481Z",
    "build_snapshot" : false,
    "lucene_version" : "9.3.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Pour utiliser la recherche dans Pod, nous allons avoir besoin également du plugin ICU :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ cd cd /usr/share/elasticsearch/
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo ES_JAVA_OPTS="-Dhttp.proxyHost=proxy.univ.fr -Dhttp.proxyPort=3128 -Dhttps.proxyHost=proxy.univ.fr -Dhttps.proxyPort=3128" /usr/share/elasticsearch/
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo bin/elasticsearch-plugin install analysis-icu
 -> Downloading analysis-icu from elastic
[=================================================] 100%   
-> Installed analysis-icu
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo /etc/init.d/elasticsearch restart
[ ok ] Restarting elasticsearch (via systemctl): elasticsearch.service.

Si vous utilisez Attention, pour ES8 derrière un proxy :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ cd /usr/share/elasticsearch/
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo ESCLI_JAVA_OPTS="-Dhttp.proxyHost=proxy.univ.fr -Dhttp.proxyPort=3128 -Dhttps.proxyHost=proxy.univ.fr -Dhttps.proxyPort=3128" /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
 -> Downloading analysis-icu from elastic
[=================================================] 100%   
-> Installed analysis-icu
(django_pod3) pod@pod:/usr/share/elasticsearch$ sudo /etc/init.d/elasticsearch restart
[ ok ] Restarting elasticsearch (via systemctl): elasticsearch.service.

...

Bloc de code
(django_pod3) pod@pod:/usr/share/elasticsearch$ cd ~/django_projects/podv3
(django_pod3) pod@pod:~/django_projects/podv3$ python manage.py create_pod_index
DELETE http://127.0.0.1:9200/pod [status:404 request:0.140s]
An error occured during index video deletion: 404-index_not_found_exception : no such index
Successfully create index Video
(django_pod3) pod@pod:~/django_projects/podv3$ curl -XGET "127.0.0.1:9200/pod/_search"
{"took":35,"timed_out":false,"_shards":{"total":2,"successful":2,"skipped":0,"failed":0},"hits":{"total":0,"max_score":null,":null,"hits":[]}}hits":[]}}

Si la commande python ne fonctionne pas, créez d'abord l'index à la main avec un curl  -XPUT "http://127.0.0.1:9200/pod" (options -k --noproxy -u <user>:<pwd> à prévoir si ES8 en mode security)


Si vous déportez l'elastic search sur une autre machine, rajoutez dans le fichier settings_local.py son URL d'accès :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ vim pod/custom/ pod/custom/settings_local.py

Copiez la ligne suivante :

Bloc de code
ES_URL = ['http://elastic.domaine.fr:9200/']


Avec le mode security et ES8, vous devrez parametrer les éléments suivants dans votre settings_local.py

...

Copiez la ligne suivante :

Bloc de code
languagepy
ES_URL = ['httphttps://elastic127.0.domaine0.fr1:9200/'] # ou votre instance déportée
ES_OPTIONS = {'verify_certs' : False, 'basic_auth' : ('es_user', 'password')} 


Installation des dépendances

...

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install -y ca-certificates curl gnupg
(django_pod3) pod@pod:~/django_projects/podv3$ sudo mkdir -p /etc/apt/keyrings
(django_pod3) pod@pod:~/django_projects/podv3$ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
(django_pod3) pod@pod:~/django_projects/podv3$ NODE_MAJOR=18 && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt update && sudo apt install -y nodejs
(django_pod3) pod@pod:~/django_projects/podv3$ sudo corepack enable


Info
titleCentOS

Alternativement, si vous êtes sur CentOS 8, installez les dépendances nodejs+npm et yarn ainsi :

root@pod:~/$ dnf module reset nodejs
root@pod:~/$ dnf module enable nodejs:14
root@pod:~/$ dnf module -y update nodejs
root@pod:~/$ yum install nodejs
root@pod:~/$ npm install yarn -g

...


Vous trouverez l'ensemble des variables disponibles sur cette page :

Configuration de la plateforme

SuperUtilisateur

Il faut créer un premier utilisateur qui aura tous les pouvoirs sur votre instance.

...

--> exemple : (django_pod3) pod@pod:~/django_projects/podv3$ python manage.py runserver pod.univ.fr:8080 --insecure

- Attention -

...

Quand le site est lancé, il faut se rendre dans la partie administration puis dans site pour renseigner le nom de domaine de votre instance de Pod (par défaut 'example.com').

Avant la mise en production, il faut vérifier le fonctionnement de la plateforme dont l'ajout d'une vidéo, son encodage et sa suppression.

Attention, pour ajouter une vidéo, il doit y avoir au moins un type de vidéo disponible. Si vous avez correctement peuplé votre base de données avec le fichier initial_data.json vous devez au moins avoir other/autres.

il faut vérifier l'authentification CAS, le moteur de recherche etc.