Modifications entre les versions 9 et 10
Version 9 à la date du 2016-09-27 13:49:44
Taille: 4739
Éditeur: LionelValentin
Commentaire:
Version 10 à la date du 2016-09-27 13:55:34
Taille: 6286
Éditeur: LionelValentin
Commentaire:
Texte supprimé. Texte ajouté.
Ligne 173: Ligne 173:

upstream proxy-idneuf {
 ip_hash;
 server prod-drupal02-idneuf.vpc02.auf;
 server prod-drupal03-idneuf.vpc02.auf;
}

server {

 listen 80;
 listen [::]:80;

 server_name prod-prox-vip.vpc02.auf;
 #server_name prod-proxy01.vpc02.auf;
 #server_name idneuf.org;
 #server_name ori-oai.idneuf.org;
 
 root /var/www/html/;
 
 # log level
 #error_log /var/log/nginx/prod-proxy01.vpc02.auf.error debug; #debug

 error_log /var/log/nginx/prod-proxy01.vpc02.auf.error; #normal
Ligne 176: Ligne 200:
   rewrite ^ http://serveur_web_rw/ permanent;    rewrite ^ http://prod-drupal01-idneuf.vpc02.auf/ permanent;
Ligne 180: Ligne 204:
   rewrite ^ http://serveur_web_rw/ permanent;    rewrite ^ http://prod-drupal01-idneuf.vpc02.auf/ permanent;
Ligne 183: Ligne 207:
  proxy_set_header Host hostname_du_site;   proxy_set_header Host prod-proxy-vip.vpc02.auf;
Ligne 189: Ligne 213:
 location /admin {
  proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  rewrite ^/(.*)$ http://prod-drupal01-idneuf.vpc02.auf/$1 permanent;
 }

 location /user {
  proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  rewrite ^/(.*)$ http://prod-drupal01-idneuf.vpc02.auf/$1 permanent;
 }

 location /ressources/ {
  #try_files $uri $uri/ $uri/index.html =404;
  proxy_set_header Host prod-proxy-vip.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_pass http://prod-ori-oai01-idneuf.vpc02.auf;
 }

 location /ori-oai-thumbnail/ {
  proxy_set_header Host prod-proxy-vip.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_pass http://prod-ori-oai01-idneuf.vpc02.auf;
 }

}

Rédiger « OVH/VPC02/idneuf/Drupal » ici.

Installation des paquets

apt-get install apache2 haproxy php5 php5-gd php5-durl libssh2-php php5-memcache memcached

Installation d'HAProxy

Configuration d'HAProxy

Contenu du fichier : /etc/haproxy/haproxy.cfg :

global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
        daemon


defaults
        log     global
        mode    tcp
        option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000

listen mysql-cluster
        bind 127.0.0.1:3306
        mode tcp
        option mysql-check user haproxy
        balance roundrobin
        server prod-db02-idneuf database_server01:3306 check
        server prod-db03-idneuf database_server02:3306 check

Configuration des serveurs slaves

Sur chaque serveur slave, exécuter les commandes SQL suivante :

INSERT INTO mysql.user (Host,User) values ('server_web_hostname','haproxy'); FLUSH PRIVILEGES;

Cette commande va permettre a HAProxy de pourvoir tester la disponibilité du serveur via le check définie dans la configuration d'HAProxy (option mysql-check user haproxy)

Il faut ensuite creer un utilisateur en lecture seule pour la connexion de Drupal.

Sur le master, exécuter la commande SQL suivante :

grant select on drupal.* to 'haproxy_auf'@'%' identified by 'xxxxxxxxxxx';

Utilisation de HAProxy avec Drupal

Dans le fichier sites/default/settings.php, insérer les lignes suivantes :

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal',
      'username' => 'haproxy_auf',
      'password' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      'host' => '127.0.0.1',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
      'readonly' => TRUE ,
    ),
  ),
);

/!\ Le host ne doit pas être "localhost" sinon la connexion ne se fera pas.

Installation de memcache

Dans le fichier /etc/memcache.conf, configurer la quantité de RAM a allouer :

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 1024

Configuration de Drupal

Installer le module suivant depuis l'interface d'administration :

https://ftp.drupal.org/files/projects/memcache-7.x-1.5.tar.gz

Dans le fichier sites/default/settings.php, insérer les lignes suivantes :

//Use memcache
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_inc'] = 'sites/all/modules/contrib/memcache/memcache.inc';

//Memcache session
$conf['session_inc'] = 'sites/all/modules/memcache/unstable/memcache-session.inc';

//Memcache lock
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';

//Add in stampede protection
$conf['memcache_stampede_protection'] = TRUE;

//Don't bootstrap the database when serving pages from the cache.
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

Lien avec ORI-OAI

Fichiers a modifier afin de faire le lien vers ORI-OAI :

ori-oai-search-idneuf.css

http_header/index.php

sites/default/files/xmlsitemap/Xh****************************wOM/1.xml 

sites/all/themes/theme1005/templates/views-view—block₁--block.tpl.php

sites/all/themes/theme1005/css/style-header-footer.css

sites/all/themes/theme1005/css/custom.css

Utilisation de NginX comme ReverseProxy

Definition d'un cluster

Dans le fichier de configuration du site :

upstream proxy-idneuf {
        ip_hash;
        server server_web_01;
        server server_web_02;
}

L'option ip_hash permet de conserver la connexion de chaque client sur le même serveur.

Configurer une ressource en cluster

Dans le fichier de configuration du site :

upstream proxy-idneuf {
        ip_hash;
        server prod-drupal02-idneuf.vpc02.auf;
        server prod-drupal03-idneuf.vpc02.auf;
}

server {

        listen 80;
        listen [::]:80;

        server_name prod-prox-vip.vpc02.auf;
        #server_name prod-proxy01.vpc02.auf;
        #server_name idneuf.org;
        #server_name ori-oai.idneuf.org;
        
        root /var/www/html/;
        
        # log level
        #error_log /var/log/nginx/prod-proxy01.vpc02.auf.error debug; #debug

        error_log /var/log/nginx/prod-proxy01.vpc02.auf.error; #normal

        location / {

                if ($args ~ q=user){
                        rewrite ^ http://prod-drupal01-idneuf.vpc02.auf/ permanent;
                }

                if ($args ~ q=admin){
                        rewrite ^ http://prod-drupal01-idneuf.vpc02.auf/ permanent;
                }

                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://proxy-idneuf;
        }

        location /admin {
                proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                rewrite ^/(.*)$ http://prod-drupal01-idneuf.vpc02.auf/$1 permanent;
        }

        location /user {
                proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                rewrite ^/(.*)$ http://prod-drupal01-idneuf.vpc02.auf/$1 permanent;
        }

        location /ressources/ {
                #try_files $uri $uri/ $uri/index.html =404;
                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-ori-oai01-idneuf.vpc02.auf;
        }

        location /ori-oai-thumbnail/ {
                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-ori-oai01-idneuf.vpc02.auf;
        }

}

Config pour récupérer le X-Forward-For

Modifier le fichier sites/default/settings.php :

$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('1.1.1.1','1.1.1.2');

OVH/VPC02/idneuf/Drupal (dernière édition le 2016-10-06 18:47:41 par LionelValentin)