« LINUX:Pacemaker - deux routers en failover - trois serveurs WEB en Loadbalancing, Galera et GlusterFs » : différence entre les versions

aucun résumé des modifications
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 328 : Ligne 328 :




=Configuration des ressources de Pacemaker=
==Script==
On effectue la suite des commandes suivantes à partir d'une des machines du cluster. On peut les mettre dans un script.
Particularité, si on applique ces commandes directement, diverses erreurs apparaissent car tant que mes contraintes ne sont pas mises en routes, le système essaie de lancer la ressource sur toutes les machines.
La solution vient via la création d'un fichier Pacemaker temporaire; ce dernier sera intégré globalement à Pacemaker en fin de traitement. Ce fichier intermédiaire sera nomme "create.xml". Il doit être inexistant au démarrage.
Voici le script:
----
#!/bin/bash
 
pcs cluster cib create.xml
 
pcs -f create.xml resource create ClusterIP0 ocf:heartbeat:IPaddr2 ip=192.168.1.70 nic=eth1 cidr_netmask=24 iflabel=ethcl0 lvs_support=true op monitor interval=30s
pcs -f create.xml constraint location ClusterIP0 prefers sv1.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterIP0 prefers sv2.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterIP0 prefers sv3.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterIP0 prefers sv4.home.dom=100
pcs -f create.xml constraint location ClusterIP0 prefers sv5.home.dom=200
 
pcs -f create.xml resource create ClusterDefaultRoute ocf:heartbeat:Route destination="default" gateway=192.168.2.70 device=eth1 family=ip4 clone
pcs -f create.xml constraint location ClusterDefaultRoute-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterDefaultRoute-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterDefaultRoute-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterDefaultRoute-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterDefaultRoute-clone prefers sv5.home.dom=-INFINITY
pcs -f create.xml constraint order ClusterIP0 then start ClusterDefaultRoute-clone
 
pcs -f create.xml resource create ClusterLdirectord systemd:ldirectord  op monitor interval=30s
pcs -f create.xml constraint location ClusterLdirectord prefers sv1.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterLdirectord prefers sv2.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterLdirectord prefers sv3.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterLdirectord prefers sv4.home.dom=100
pcs -f create.xml constraint location ClusterLdirectord prefers sv5.home.dom=200
pcs -f create.xml constraint order ClusterDefaultRoute-clone then start ClusterLdirectord
pcs -f create.xml constraint colocation add ClusterIP0 with ClusterLdirectord score=INFINITY
 
pcs -f create.xml resource create ClusterGlusterd systemd:glusterd op monitor interval=20s clone
pcs constraint order ClusterLdirectord then start ClusterGlusterd-clone
pcs -f create.xml constraint location ClusterGlusterd-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterGlusterd-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterGlusterd-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterGlusterd-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterGlusterd-clone prefers sv5.home.dom=-INFINITY
 
pcs -f create.xml resource create ClusterRsyncd systemd:rsyncd op monitor interval=30s clone
pcs -f create.xml constraint location ClusterRsyncd-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterRsyncd-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterRsyncd-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterRsyncd-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterRsyncd-clone prefers sv5.home.dom=-INFINITY
pcs -f create.xml constraint order ClusterGlusterd-clone then start ClusterRsyncd-clone
 
pcs -f create.xml resource create ClusterCheckGalera systemd:checkgalera op monitor interval=30s clone
pcs -f create.xml constraint location ClusterCheckGalera-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterCheckGalera-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterCheckGalera-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterCheckGalera-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterCheckGalera-clone prefers sv5.home.dom=-INFINITY
pcs -f create.xml constraint order ClusterRsyncd-clone then start ClusterCheckGalera-clone
 
pcs -f create.xml resource create ClusterFsWeb ocf:heartbeat:Filesystem \
  device="localhost:/diskgfs1" \
  directory="/data" fstype="glusterfs" \
  "options=defaults,_netdev" \
  op monitor interval=20s on-fail=stop clone
pcs -f create.xml constraint location ClusterFsWeb-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterFsWeb-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterFsWeb-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterFsWeb-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterFsWeb-clone prefers sv5.home.dom=-INFINITY
pcs -f create.xml constraint order ClusterCheckGalera-clone then start ClusterFsWeb-clone
 
pcs -f create.xml resource create ClusterHttpd systemd:httpd op monitor interval=30s clone
pcs -f create.xml constraint location ClusterHttpd-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterHttpd-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterHttpd-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterHttpd-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterHttpd-clone prefers sv5.home.dom=-INFINITY
pcs -f create.xml constraint order ClusterFsWeb-clone then start ClusterHttpd-clone
 
pcs -f create.xml resource create ClusterPhp systemd:php-fpm op monitor interval=30s clone
pcs -f create.xml constraint location ClusterPhp-clone prefers sv1.home.dom=100
pcs -f create.xml constraint location ClusterPhp-clone prefers sv2.home.dom=100
pcs -f create.xml constraint location ClusterPhp-clone prefers sv3.home.dom=100
pcs -f create.xml constraint location ClusterPhp-clone prefers sv4.home.dom=-INFINITY
pcs -f create.xml constraint location ClusterPhp-clone prefers sv5.home.dom=-INFINITY
pcs -f create.xml constraint order ClusterHttpd-clone then start ClusterPhp-clone
 
pcs -f create.xml resource create ClusterMailTo ocf:heartbeat:MailTo email=root subject="FailOver_Home" op monitor interval=30s clone
pcs -f create.xml constraint order ClusterPhp-clone then start ClusterMailTo-clone
 
pcs cluster cib-push create.xml
----