pcs permet de configurer pacemaker et corosync en ligne de commande sans avoir à éditer le fichier de configuration de corosync ou la CIB (un splendide fichier XML) de pacemaker. Cet outil est souvent comparé à crmsh.
IP | Nom du contenair | Rôle |
192.168.1.104 | * | IP virtuelle |
192.168.1.102 | proxybis | Contenair LXC |
192.168.1.103 | proxy | Contenair LXC |
192.168.1.102 proxybis 192.168.1.103 proxy
/apt update & apt dist-upgrade -y /apt install -y pcsd
Une fois l'installation effectuée, l'user hacluster est créé. Donnons lui un mot de passe via la commande :
passwd hacluster
systemctl start pcsd.service
systemctl enable pcsd.service
systemctl enable corosync
systemctl enable pacemaker
A faire sur les 2 CT
systemctl disable nginx.service
pcs host auth [nom du CT1] [nom du CT2] -u hacluster
pcs cluster setup [nom du cluster] [nom du CT1] [nom du CT2] --start --enable
pcs property set stonith-enabled=false
pcs property set no-quorum-policy=ignore
N'hésitez pas a consulter l'aide pour la création de resources : pcs -h resource create
Option | Description |
virtual-IP-rsc | l’IP virtuelle partager entre les CTs |
Service nginx | Vérification présence du service nginx |
pcs resource create ip ocf:heartbeat:IPaddr2 ip=192.168.1.104 cidr_netmask=24 op monitor interval=5s pcs resource create nginx systemd:nginx op monitor interval=5s pcs constraint colocation add ip with nginx INFINITY pcs constraint location ip prefers [nom du CT1] pcs constraint order ip then nginx
Quelques explications :
Nous pouvons voir nos contraintes avec la commande pcs constraint list :
Location Constraints: Resource: ip Enabled on: proxy (score:INFINITY) Resource: nginx Enabled on: proxy (score:INFINITY) Ordering Constraints: start nginx then start ip (kind:Mandatory) Colocation Constraints: ip with nginx (score:INFINITY) Ticket Constraints:
Une fois ces opérations effectuées vous pouvez voir l'état de votre cluster via la commande pcs status :
Cluster name: [nom du cluster] Stack: corosync Current DC: [nom du CT2] (version 2.0.1-9e909a5bdd) - partition with quorum Last updated: Sun Oct 13 01:19:04 2019 Last change: Sat Oct 12 19:22:31 2019 by root via cibadmin on [nom du CT1] 2 nodes configured 2 resource configured Online: [ [nom du CT1] [nom du CT2]] Full list of resources: nginx (systemd:nginx): Started proxy ip (ocf::heartbeat:IPaddr2): Started [nom du CT1] Daemon Status: corosync: active/enabled pacemaker: active/enabled pcsd: active/enabled
sources : salsa.debian.org Ce cher ehlo