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.
Commentaire: Installation d'ES

...

Bloc de code
languagepy
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://<my_redis_host>:6379/3",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        },
        "KEY_PREFIX": "pod",
    },
    "select2": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://<my_redis_host>:6379/2",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        },
    },
}
SESSION_ENGINE = "redis_sessions.session"
SESSION_REDIS = {
    "host": "<my_redis_host>",
    "port": 6379,
    "db": 4,
    "prefix": "session",
    "socket_timeout": 1,
    "retry_on_timeout": False,
}


Elasticsearch

...

Selon la version d'Elasticsearch que vous allez utiliser, les versions des dépendances peuvent changer. Les versions 6 et 7 ne sont actuellement plus maintenues. La version 8 est à configurer plus bas. La version 6 est celle par défaut dans Pod.

Elasticsearch 6

Pour utiliser Elasticsearch 6, il faut avoir java 11 sur sa machine.

...

Puis pour installer Elasticsearch sur Debian en utilisant les paquets, il faut suivre les instructions situées à cette adresse : https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html.

Vous pouvez installer Elasticsearch en version 6 ou en version 7.

Voici :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
OK
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get install apt-transport-https

Pour Elasticsearch 6 :

Bloc de code

(django_pod3) pod@pod:~/django_projects/podv3$ echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list deb https://artifacts.elastic.co/packages/6.x/apt stable main
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update && sudo apt-get install elasticsearch

Pour Elasticsearch 7 Ensuite il faut paramétrer l’instance :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo teevim /etc/aptelasticsearch/sources.list.d/elastic-7.x.list
(django_pod3) pod@pod:~/django_projects/podv3$ sudo apt-get update && sudo apt-get install elasticsearchelasticsearch.yml

Puis  préciser ces valeurs :

Bloc de code
cluster.name: pod-application
node.name: pod-1
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

Elasticsearch 7 et 8

Pour utiliser Elasticsearch 7 ou 8, il faut avoir java 17 sur sa machine.Ensuite il faut paramétrer l’instance :

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

Pour préciser ces valeurs :
Pour Elasticsearch 6 :

Bloc de code
cluster.name: pod-application
node.name: pod-1
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

Pour Elasticsearch 7 :

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 faut enfin le lancer et vérifier son bon fonctionnement :

...

apt-get install default-jdk

Puis pour installer Elasticsearch sur Debian en utilisant les paquets, il faut suivre les instructions situées à cette adresse : https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html.

Vous pouvez installer Elasticsearch en version 7 (plus maintenue) ou en version 8.

Voici pour ES7 :

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/

...

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

...

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 :

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 :

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

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 :

Bloc de code
(django_pod3) pod@pod:~/django_projects/podv3$ 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/
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.

...

Avertissement

Pour une utilisation d'elasticsearch 7 .Xou 8, il faut absolument :

Ajouter ES_VERSION = 7 ou  ES_VERSION = 8 dans votre fichier de settings et modifiez la version du client elasticsearch dans le fichier requirements.txt

elasticsearch==7.17.9

ou

elasticsearch==8.9.0

Et ne pas oublier de relancer

(django_pod3) pod@podv3:~/django_projects/podv3$ pip3 install -r requirements.txt

...