Product SiteDocumentation Site

Pacemaker 1.1

Clusters from Scratch

Creare cluster Active/Passive e Active/Active su Fedora

Edizione 3

Andrew Beekhof

Primary author 
Red Hat

Raoul Scarazzini

Italian translation 

Nota Legale

Copyright © 2010 Andrew Beekhof This material may only be distributed subject to the terms and conditions set forth in the GNU Free Documentation License (GFDL), V1.2 or later (the latest version is presently available at http://www.gnu.org/licenses/fdl.txt).
Sommario
Lo scopo di questo documento è di fornire una guida completa per costruire un cluster active/passive con Pacemaker e mostrare come può essere convertito in una configurazione active/active.
Il cluster userà:
  1. Fedora 13 come sistema operativo
  2. Corosync per fornire i servizi di messaging e membership,
  3. Pacemaker per la gestione delle risorse
  4. DRBD come alternativa prezzo/prestazioni allo storage condiviso,
  5. GFS2 come cluster filesystem (nella modalità active/active)
  6. La shell crm per la visualizzazione della configurazione e l'attuazione delle modifiche
Per via del processo grafico di installazione di Fedora, diversi screenshot sono inclusi. Ad ogni modo questa guida è composta primariamente dai comandi, dalle ragioni per cui questi vengono eseguiti e l'output da loro prodotto.

Prefazione
1. Convenzioni del documento
1.1. Convenzioni tipografiche
1.2. Convenzioni del documento
1.3. Note ed avvertimenti
2. Inviateci i vostri commenti!
1. Leggimi-Prima
1.1. Scopo di questo documento
1.2. Cos'è Pacemaker?
1.3. Tipologia dei cluster Pacemaker
1.4. Architettura di Pacemaker
1.4.1. Componenti interni
2. Installazione
2.1. Installazione del sistema operativo
2.2. Installazione del software cluster
2.2.1. Considerazioni sulla sicurezza
2.2.2. Installazione del software cluster
2.3. Prima di continuare
2.4. Setup
2.4.1. Definire la rete
2.4.2. Configuarazione di SSH
2.4.3. Nomi di nodi abbreviati
2.4.4. Configurare Corosync
2.4.5. Distribuire la configurazione
3. Verifica dell'installazione del cluster
3.1. Verifica dell'installazione di Corosync
3.2. Verifica dell'installazione di Pacemaker
4. Utilizzare i tool di Pacemaker
5. Creare un cluster Active/Passive
5.1. Esplorare la configurazione esistente
5.2. Aggiungere una risorsa
5.3. Effettuare un Failover
5.3.1. Quorum e Cluster a due nodi
5.3.2. Evitare che le risorse si muovano dopo il recovery
6. Apache - Aggiungere ulteriori servizi
6.1. Installazione
6.2. Preparazione
6.3. Enable the Apache status URL
6.4. Aggiornare la configurazione
6.5. Assicurarsi che le risorse funzionino sullo stesso host
6.6. Controllare l'ordinamento di start e stop di una risorsa
6.7. Specificare una Location preferita
6.8. Spostamento manuale delle risorse all'interno del cluster
6.8.1. Restituire il controllo nuovamente al cluster
7. Storage replicato con DRBD
7.1. Installare i pacchetti DRBD
7.2. Configurare DRBD
7.2.1. Creare una partizione per DRBD
7.2.2. Scrivere la configurazione DRBD
7.2.3. Inizializzare e caricare DRBD
7.2.4. Popolare DRBD con i dati
7.3. Configurare il cluster per DRBD
7.3.1. Testare la migrazione
8. Conversione in Active/Active
8.1. Requisiti
8.2. Installare un cluster filesystem - GFS2
8.3. Configurare l'integrazione fra Pacemaker e GFS2
8.3.1. Aggiunta del servizio DLM
8.3.2. Aggiunta del servizio GFS2
8.4. Creazione un Filesystem GFS2
8.4.1. Preparazione
8.4.2. Creazione e popolamento della partizione GFS2
8.5. Riconfigurare il cluster per GFS2
8.6. Riconfigurare Pacemaker per l'Active/Active
8.6.1. Testare il recovery
9. Configurare STONITH
9.1. Perché STONITH è necessario
9.2. Quale device STONITH andrebbe utilizzato
9.3. Configurare STONITH
9.3.1. Esempio
A. Riepilogo delle configurazioni
A.1. Configurazione finale del cluster
A.2. Lista nodi
A.3. Opzioni del cluster
A.4. Risorse
A.4.1. Opzioni di default
A.4.2. Fencing
A.4.3. Servizio Address
A.4.4. Distributed lock manager
A.4.5. Demone di controllo di GFS
A.4.6. DRBD - Storage condiviso
A.4.7. Cluster Filesystem
A.4.8. Apache
B. Sample Corosync Configuration
C. Using CMAN for Cluster Membership and Quorum
C.1. Background
C.2. Adding CMAN Support
C.2.1. Adding CMAN Support - cluster.conf
C.2.2. Adding CMAN Support - corosync.conf
D. Approfondimenti
E. Revision History
Indice analitico

Prefazione

1. Convenzioni del documento

Questo manuale utilizza numerose convenzioni per evidenziare parole e frasi, ponendo attenzione su informazioni specifiche.
Nelle edizioni PDF e cartacea questo manuale utilizza caratteri presenti nel set Font Liberation. Il set Font Liberation viene anche utilizzato nelle edizioni HTML se il set stesso è stato installato sul vostro sistema. In caso contrario, verranno mostrati caratteri alternativi ma equivalenti. Da notare: Red Hat Enterprise Linux 5 e versioni più recenti, includono per default il set Font Liberation.

1.1. Convenzioni tipografiche

Vengono utilizzate quattro convenzioni tipografiche per richiamare l'attenzione su parole e frasi specifiche. Queste convenzioni, e le circostanze alle quali vengono applicate, sono le seguenti.
Neretto monospazio
Usato per evidenziare l'input del sistema, incluso i comandi della shell, i nomi dei file ed i percorsi. Utilizzato anche per evidenziare tasti e combinazione di tasti. Per esempio:
Per visualizzare i contenuti del file my_next_bestselling_novel nella vostra directory di lavoro corrente, inserire il comando cat my_next_bestselling_novel al prompt della shell e premere Invio per eseguire il comando.
Quanto sopra riportato include il nome del file, un comando della shell ed un tasto, il tutto riportato in neretto monospazio e distinguibile grazie al contesto.
Le combinazioni di tasti possono essere distinte dai tasti tramite il trattino che collega ogni parte della combinazione. Per esempio:
Premere Invio per eseguire il comando.
Premere Ctrl+Alt+F1 per smistarsi sul primo virtual terminal. Premere Ctrl+Alt+F7 per ritornare alla sessione X-Windows.
Il primo paragrafo evidenzia il tasto specifico singolo da premere. Il secondo riporta due combinazioni di tasti, (ognuno dei quali è un set di tre tasti premuti contemporaneamente).
Se si discute del codice sorgente, i nomi della classe, i metodi, le funzioni i nomi della variabile ed i valori ritornati indicati all'interno di un paragrafo, essi verranno indicati come sopra, e cioè in neretto monospazio. Per esempio:
Le classi relative ad un file includono filesystem per file system, file per file, e dir per directory. Ogni classe possiede il proprio set associato di permessi.
Proportional Bold
Ciò denota le parole e le frasi incontrate su di un sistema, incluso i nomi delle applicazioni; il testo delle caselle di dialogo; i pulsanti etichettati; le caselle e le etichette per pulsanti di selezione, titoli del menu e dei sottomenu. Per esempio:
Selezionare SistemaPreferenzeMouse dalla barra del menu principale per lanciare Preferenze del Mouse. Nella scheda Pulsanti, fate clic sulla casella di dialogo mouse per mancini, e successivamente fate clic su Chiudi per cambiare il pulsante primario del mouse da sinistra a destra (rendendo così il mouse idoneo per un utilizzo con la mano sinistra).
Per inserire un carattere speciale in un file gedit, selezionare ApplicazioniAccessoriMappa carattere dalla barra menu principale. Successivamente, selezionare CercaTrova… dalla barra del menu Mappa carattere, inserire il nome del carattere nel campo Cerca e cliccare Successivo. Il carattere ricercato verrà evidenziato nella Tabella caratteri. Fare un doppio clic sul carattere evidenziato per posizionarlo nel campo Testo da copiare, e successivamente fare clic sul pulsante Copia. Ritornare ora al documento e selezionare ModificaIncolla dalla barra del menu di gedit.
Il testo sopra riportato include i nomi delle applicazioni; nomi ed oggetti del menu per l'intero sistema; nomi del menu specifici alle applicazioni; e pulsanti e testo trovati all'interno di una interfaccia GUI, tutti presentati in neretto proporzionale e distinguibili dal contesto.
Corsivo neretto monospazio o Corsivo neretto proporzionale
Sia se si tratta di neretto monospazio o neretto proporzionale, l'aggiunta del carattere corsivo indica un testo variabile o sostituibile . Il carattere corsivo denota un testo che non viene inserito letteralmente, o visualizzato che varia a seconda delle circostanze. Per esempio:
Per collegarsi ad una macchina remota utilizzando ssh, digitare ssh username@domain.name al prompt della shell. Se la macchina remota è example.com ed il nome utente sulla macchina interessata è john, digitare ssh john@example.com.
Il comando mount -o remount file-system rimonta il file system indicato. Per esempio, per rimontare il file system /home, il comando è mount -o remount /home.
Per visualizzare la versione di un pacchetto attualmente installato, utilizzare il comando rpm -q package. Esso ritornerà il seguente risultato: package-version-release.
Da notare la parola in Corsivo neretto — nome utente, domain.name, file-system, pacchetto, versione e release. Ogni parola racchiude il testo da voi inserito durante l'emissione di un comando o per il testo mostrato dal sistema.
Oltre all'utilizzo normale per la presentazione di un titolo, il carattere Corsivo denota il primo utilizzo di un termine nuovo ed importante. Per esempio:
Publican è un sistema di pubblicazione per DocBook.

1.2. Convenzioni del documento

Gli elenchi originati dal codice sorgente e l'output del terminale vengono evidenziati rispetto al testo circostante.
L'output inviato ad un terminale è impostato su tondo monospazio e così presentato:
books        Desktop   documentation  drafts  mss    photos   stuff  svn
books_tests  Desktop1  downloads      images  notes  scripts  svgs
Gli elenchi del codice sorgente sono impostati in tondo monospazio ma vengono presentati ed evidenziati nel modo seguente:
package org.jboss.book.jca.ex1;

import javax.naming.InitialContext;

public class ExClient
{
   public static void main(String args[]) 
       throws Exception
   {
      InitialContext iniCtx = new InitialContext();
      Object         ref    = iniCtx.lookup("EchoBean");
      EchoHome       home   = (EchoHome) ref;
      Echo           echo   = home.create();

      System.out.println("Created Echo");

      System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
   }
}

1.3. Note ed avvertimenti

E per finire, tre stili vengono usati per richiamare l'attenzione su informazioni che in caso contrario potrebbero essere ignorate.

Nota Bene

Una nota è un suggerimento o un approccio alternativo per il compito da svolgere. Non dovrebbe verificarsi alcuna conseguenza negativa se la nota viene ignorata, ma al tempo stesso potreste non usufruire di qualche trucco in grado di facilitarvi il compito.

Importante

Le caselle 'importante' riportano informazioni che potrebbero passare facilmente inosservate: modifiche alla configurazione applicabili solo alla sessione corrente, o servizi i quali necessitano di un riavvio prima di applicare un aggiornamento. Ignorare queste caselle non causa alcuna perdita di dati ma potrebbe causare irritazione e frustrazione da parte dell'utente.

Avvertenza

Un Avvertimento non dovrebbe essere ignorato. Se ignorato, potrebbe verificarsi una perdita di dati.

2. Inviateci i vostri commenti!

Potreste sovrascriverlo tramite la creazione di un vostro file Feedback.xml locale.

Capitolo 1. Leggimi-Prima

1.1. Scopo di questo documento

Lo scopo di questo documento è quello di spiegare in maniera definitiva i concetti utilizzati per configurare Pacemaker. Per ottenere il meglio, si focalizzera' esclusivamente sulla sintassi XML per configurare il CIB.
Per gli allergici ad XML, Pacemaker ha una cluster shell ed una GUI Python, ma questi tools non sono trattati nel presente documento [1], proprio perché questi nascondono l'XML.
Inoltre, questo documento NON E' un how-to passo-passo per configurare uno specifico scenario cluster. Sebbene questo tipo di guide esista, lo scopo di questo documento è quello di fornire la comprensione delle componenti che possono essere utilizzate per costruire qualsiasi cluster Pacemaker.

1.2. Cos'è Pacemaker?

Pacemaker è un cluster resource manager. Ottiene la massima affidabilità per i servizi cluster (conosciuti come risorse) rilevando e ripristinando malfunziomenti di nodi e di risorse facendo uso delle capacità di messaging e membership fornite dalla tua infrastruttura cluster preferita (sia questa Corosync o Heartbeat).
Le caratteristiche di Pacemaker includono:
  • Rilevazione e ripristino di malfunzionamenti di nodi e servizi
  • Storage agnostic, non richiede uno storage condiviso
  • Resource agnostic, tutto quello che può essere scriptato può essere clusterizzato
  • Supporto STONITH per garantire l'integrità dei dati
  • Supporto a cluster grandi e piccoli
  • Supporto a cluster quorati e resource driven
  • Supporto a praticamente qualsiasi configurazione ridondata
  • Configurazione replicata automaticamente che può essere aggiornata da qualsiasi nodo
  • Capacità di specificare ordine, collocazione e anti-collocazione per i servizi lato cluster
  • Supporto per servizi di tipo avanzato
    • Cloni: per servizi che necessitano di essere attivi su nodi multipli
    • Muliti-state: per servizi con modi multipli (ad esempio master/slave, primary/secondary/
  • cluster shell unificata e scriptabile

1.3. Tipologia dei cluster Pacemaker

Pacemaker non fa alcuna ipotesi in merito all'ambiente operativo, questo consente di supportare praticamente qualsiasi configurazione ridondata come Active/Active, Active/Passive, N+1, N+M, N-to-1 e N-to-N.
Ridondanza Active/Passive
I cluster a due nodi Active/Passive che utilizzano Pacemaker e DRBD sono soluzioni con rapporto qualità-prezzo ottimale in molti ambiti di alta affidabilità.
Figura 1.1. Ridondanza Active/Passive

Failover condiviso
Supportando più nodi, Pacemaker può ridurre drammaticamente i costi hardware consentendo a diversi cluster active/passive di combinare e condividere nodi di backup comuni
Figura 1.2. Failover condiviso

Ridondanza N a N
Quando è disponibile uno storage condiviso ogni nodo può essere utilizzato per il failover. Pacemaker può anche eseguire copie multiple dei servizi per distribuire il carico di lavoro.
Figura 1.3. Ridondanza N a N

1.4. Architettura di Pacemaker

Al livello più elevato il cluster è composto da tre componenti:
  • Infrastruttura core del cluster che rende disponibili le funzionalità di messaging e membership (illustrate in rosso)
  • Componenti non inerenti al cluster (illustrate in blu). In un cluster Pacemaker queste componenti includono non solo gli script che sanno come avviare, stoppare e monitorare le risorse, ma anche
  • Un cervello (illustrato in verde) che reagisce e processa gli eventi del cluster (nodi scomparsi o apparsi) e delle risorse (ad esempio il controllo delle anomalie) così come le modifiche effettuate dall'amministratore. In risposta a tutti questi eventi, Pacemaker elaborerà l'ideale stato del cluster ed il piano per renderlo effettivo. Questo potrebbe includere lo spostamento delle risorse, lo stop di nodi fino alla forzatura offline di questi attraverso la rimozione dell'alimentazione remota.
Panoramica concettuale dello Stack
Panoramica concettuale dello stack del cluster
Figura 1.4. Panoramica concettuale dello Stack

Quando viene combianato con Corosync, Pacemaker supporta anche i popolari cluster filesystem opensource [2]. Le recenti standardizzazioni all'interno della comunità del cluster filesystem hanno portato all'uso di un lock manager distribuito che utilizza Corsync per il supporto al messaging e Pacemaker per il membership (quali nodi sono vivi o morti) ed il fencing dei servizi.
Lo stack Pacemaker
Lo stack Pacemaker nell'esecuzione su Corosync
Figura 1.5. Lo stack Pacemaker

1.4.1. Componenti interni

Pacemaker stesso è composto da quatto componenti chiave (illustrati sotto nello stesso schema di colori del diagramma precedente):
  • CIB (acronimo di come Cluster Information Base)
  • CRMd (acronimo di Cluster Resource Management daemon)
  • PEngine (acronimo di Policy Engine)
  • STONITHd
Componenti interni
Sottosistemi di un cluster Pacemaker in esecuzione su Corosync
Figura 1.6. Componenti interni

Il CIB utilizza XML per rappresentare sia l'attuale configurazione del cluster sia lo stato di tutte le risorse all'interno dello stesso. I contenuti del CIB sono automaticamente tenuti in sincronia in tutto il cluster e vengono utilizzati dal PEngine per elaborare lo stato ideale del cluster e come questo debba essere raggiunto.
Questa lista di istruzioni viene inviata al DC (Designated Co-ordinator). Pacemaker centralizza tutte le decisioni in merito al cluster eleggendo una delle istanze di CRMd ad agire come master. Qualora il processo eletto CRMd o il nodo su cui questo è in esecuzione dovessero fallire, un nuovo DC viene rapidamente stabilito.
Il DC esegue le istruzioni inviategli dal PEngine nell'ordine richiesto passandole o al LRMd (Local Resource Management daemon) o ai CRMd in ascolto sugli altri nodi attraverso l'infrastruttura di messaging del cluster (che a loro volta passeranno le istruzioni ai proprio LRMd).
Gli altri nodi riferiscono i risultati delle loro operazioni al DC. Attraverso l'analisi dei risultati aspettati e di quelli attuali, i nodi eseguiranno qualsiasi azione necessaria per attendere il completamento della precedente oppure interromperanno il processo, richiedendo al PEngine di calcolare nuovamente lo stato ideale del cluster basandosi sui risulati inaspettati.
In alcuni casi, potrebbe essere necessario spegnere i nodi per preservare dati condifivi o completare il ripristino di una risorsa. Per questo in Pacemaker esiste STONITHd. STONITH è un acronimo per Shoot-The-Other-Node-In-The-Head e viene implementato tipicamente con un switch di potenza remoto. In Pacemaker i dispositivi STONITH sono modellati come risorse (e configurati all'interno del CIB) per facilitare il monitoraggio delle anomalie. STONITHd si prende cura di capire la topologia STONITH così che i suoi client debbano unicamente richiedere unicamente la morte di un nodo ed esso si preoccupi del resto.


[1] Si spera comunque che una volta compresi i concetti qui esposti sarà più semplice comprendere anche questi tools.

[2] Sebbene Pacemaker supporti anche Heartbeat, i filesystem necessitano di usare uno stack di messaging e membership e Corosync sembra essere quello su cui questi si stanno standardizzando. Tecnicamente potrebbe essere possibile per questi supportare anche Heartbeat, ma sembra esserci poco interesse in merito alla questione.

Capitolo 2. Installazione

2.1. Installazione del sistema operativo

Informazioni dettagliate su come installare Fedora sono disponibili presso http://docs.fedoraproject.org/install-guide/f13/ in numerose lingue. La versione abbreviata è la seguente...
Puntando il browser al link http://fedoraproject.org/en/get-fedora-all, individuare la sezione Install Media e scaricare il DVD di installazione adatto al proprio hardware.
Masterizzare l'immagine in un DVD [3] ed avviare da questo media. Oppure utilizzare l'immagine per avviare una virtual machine come illustrato qui. Dopo aver cliccato sulla schermata di benvenuto, selezionare la propria lingua ed il layout della tastiera [4]
Installazione di Fedora - Benvenuto
Installazione di Fedora: Buona scelta
Figura 2.1. Installazione di Fedora - Benvenuto

Installazione di Fedora - Storage Devices
Installazione di Fedora: Storage Devices
Figura 2.2. Installazione di Fedora - Storage Devices

Assegnare un nome alla macchina. [5] Il dominio utilizzato in questo progetto sarà clusterlabs.org.
Installazione di Fedora - Hostname
Installazione di Fedora: Selezionare un hostname
Figura 2.3. Installazione di Fedora - Hostname

You will then be prompted to indicate the machine’s physical location and to supply a root password. [6]
Now select where you want Fedora installed. [7] As I don’t care about any existing data, I will accept the default and allow Fedora to use the complete drive. However I want to reserve some space for DRBD, so I'll check the Review and modify partitioning layout box.
Installazione di Fedora - Tipo di installazione
Installazione di Fedora: Selezionare un tipo di installazione
Figura 2.4. Installazione di Fedora - Tipo di installazione

Di default, Fedora dedicherà tutto lo spazio alla partizione di root /.Questa verrà ridotta al fine di poter usare DRBD.
Installazione di Fedora - Partizionamento di default
Figura 2.5. Installazione di Fedora - Partizionamento di default

Lo schema di partizionamento finale dovrà somigliare a quanto illustrato nel diagramma sotto.

Importante

Se è nelle intenzioni di chi legge segure le parti di questa guida che trattano DRBD o GFS2 andrà riservato almeno 1Gb di spazio in ciascuna macchina da cui verrà tratto il volume condiviso.
Installazione di Fedora - Personalizzazione delle partizioni
Installazione di Fedora: Creare una partizione da usare (dopo) per i dati del sito web
Figura 2.6. Installazione di Fedora - Personalizzazione delle partizioni

Installazione di Fedora - Bootloader
Installazione di Fedora: A meno che non si abbiano sensate ragioni per non farlo è bene accettare le impostazioni di default del bootloader
Figura 2.7. Installazione di Fedora - Bootloader

Scegliere quindi quale software si vorrà installare. Cambiare la selezione a Web Server dal momento che si ha in programma di usare Apache. Non abilitare gli aggiornamenti, questo verrà fatto (insieme all'installazione di ulteriore software extra necessario) dopo. Dopo aver cliccato next, Fedora si installerà.
Installazione di Fedora - Software
Installazione di Fedora: Selezione del software
Figura 2.8. Installazione di Fedora - Software

Installazione di Fedora - Installazione
Installazione di Fedora: Prendere qualcosa da bere, questa parte dura abbastanza
Figura 2.9. Installazione di Fedora - Installazione

Installazione di Fedora - Installazione completata
Installazione di Fedora: Stage 1, completato
Figura 2.10. Installazione di Fedora - Installazione completata

Quano il nodo si riavvia seguire le istruzioni sullo schermo [8] per creare un utenza di sistema e sistemare l`ora.
Installazione di Fedora - Primo avvio
Figura 2.11. Installazione di Fedora - Primo avvio

Installazione di Fedora - Creazione utente non privilegiato
Installazione di Fedora: Nella creazione di un utente non privilegiato si prenda nota della password, presto servirà
Figura 2.12. Installazione di Fedora - Creazione utente non privilegiato

Nota

E' caldamente consigliato di abilitare NTP sui nodi del cluster, ci si assicurerà così che tutti i nodi siano settati sull'ora attuale e la lettura dei log sarà molto più semplice.
Installazione di Fedora - Data ed ora
Installazione di Fedora: Abilitare NTP per mantenere consistente l'ora su tutti i nodi
Figura 2.13. Installazione di Fedora - Data ed ora

Installazione di Fedora - Personalizzare la rete
Installazione di Fedora: Cliccare qui per configurare la rete
Figura 2.14. Installazione di Fedora - Personalizzare la rete

Importante

Non accettare i settaggi di default della rete. Le macchine cluster non devono MAI ottenere un indirizzo IP via DHCP. In questo caso verrà utilizzato gli indirizzi internal della rete clusterlab.org.
Installazione di Fedora - Specificare le preferenze di rete
Installazione di Fedora: Specificare le preferenze di rete per la propria macchina, non selezionare mai DHCP
Figura 2.15. Installazione di Fedora - Specificare le preferenze di rete

Installazione di Fedora - Attivare la rete
Installazione di Fedora: cliccare il grosso bottone verde per attivare le modifiche
Figura 2.16. Installazione di Fedora - Attivare la rete

Installazione di Fedora - Aprire il terminale
Installazione di Fedora: al lavoro, avviando la linea di comando
Figura 2.17. Installazione di Fedora - Aprire il terminale

Nota

That was the last screenshot, from here on in we’re going to be working from the terminal.

2.2. Installazione del software cluster

Attraverso la finestra terminale appena aperta diventare super utente ("root") attraverso il comando su. Verrà richiesta la password richiesta in fase di installazione.
[beekhof@pcmk-1 ~]$ su -
Password:
[root@pcmk-1 ~]#

Nota

Note that the username (the text before the @ symbol) now indicates we’re running as the super user “root”.
[root@pcmk-1 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:6f:e1:58 brd ff:ff:ff:ff:ff:ff
    inet 192.168.9.41/24 brd 192.168.9.255 scope global eth0
    inet6 ::20c:29ff:fe6f:e158/64 scope global dynamic 
       valid_lft 2591667sec preferred_lft 604467sec
    inet6 2002:57ae:43fc:0:20c:29ff:fe6f:e158/64 scope global dynamic 
       valid_lft 2591990sec preferred_lft 604790sec
    inet6 fe80::20c:29ff:fe6f:e158/64 scope link 
       valid_lft forever preferred_lft forever
[root@pcmk-1 ~]# ping -c 1 www.google.com
PING www.l.google.com (74.125.39.99) 56(84) bytes of data.
64 bytes from fx-in-f99.1e100.net (74.125.39.99): icmp_seq=1 ttl=56 time=16.7 ms

--- www.l.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 20ms
rtt min/avg/max/mdev = 16.713/16.713/16.713/0.000 ms
[root@pcmk-1 ~]# /sbin/chkconfig network on
[root@pcmk-1 ~]#

2.2.1. Considerazioni sulla sicurezza

To simplify this guide and focus on the aspects directly connected to clustering, we will now disable the machine’s firewall and SELinux installation. Both of these actions create significant security issues and should not be performed on machines that will be exposed to the outside world.

Importante

TODO: Creare un Appendice che valuti (almeno) la riabilitazione del firewall.
[root@pcmk-1 ~]# sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
[root@pcmk-1 ~]# /sbin/chkconfig --del iptables
[root@pcmk-1 ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]

Importante

Sarà necessario riavviare per rendere effettive le modifiche a SELinux. In alterniva qualcosa di simile a questo apparirà all'avvio di corosync:
May  4 19:30:54 pcmk-1 setroubleshoot: SELinux is preventing /usr/sbin/corosync "getattr" access on /. For complete SELinux messages. run sealert -l 6e0d4384-638e-4d55-9aaf-7dac011f29c1
May  4 19:30:54 pcmk-1 setroubleshoot: SELinux is preventing /usr/sbin/corosync "getattr" access on /. For complete SELinux messages. run sealert -l 6e0d4384-638e-4d55-9aaf-7dac011f29c1

2.2.2. Installazione del software cluster

Dalla versione 12, Fedora fornisce versioni recenti di tutto quanto si necessita, quindi avviando la shell lanciare:
[root@pcmk-1 ~]# sed -i.bak "s/enabled=0/enabled=1/g" /etc/yum.repos.d/fedora.repo
[root@pcmk-1 ~]# sed -i.bak "s/enabled=0/enabled=1/g" /etc/yum.repos.d/fedora-updates.repo
[root@pcmk-1 ~]# yum install -y pacemaker corosync
Loaded plugins: presto, refresh-packagekit
fedora/metalink                   	                           |  22 kB     00:00     
fedora-debuginfo/metalink         	                           |  16 kB     00:00     
fedora-debuginfo                  	                           | 3.2 kB     00:00     
fedora-debuginfo/primary_db       	                           | 1.4 MB     00:04     
fedora-source/metalink            	                           |  22 kB     00:00     
fedora-source                     	                           | 3.2 kB     00:00     
fedora-source/primary_db          	                           | 3.0 MB     00:05     
updates/metalink                  	                           |  26 kB     00:00     
updates                           	                           | 2.6 kB     00:00     
updates/primary_db                	                           | 1.1 kB     00:00     
updates-debuginfo/metalink        	                           |  18 kB     00:00     
updates-debuginfo                 	                           | 2.6 kB     00:00     
updates-debuginfo/primary_db      	                           | 1.1 kB     00:00     
updates-source/metalink           	                           |  25 kB     00:00     
updates-source                    	                           | 2.6 kB     00:00     
updates-source/primary_db         	                           | 1.1 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package corosync.x86_64 0:1.2.1-1.fc13 set to be updated
--> Processing Dependency: corosynclib = 1.2.1-1.fc13 for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libquorum.so.4(COROSYNC_QUORUM_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libvotequorum.so.4(COROSYNC_VOTEQUORUM_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcpg.so.4(COROSYNC_CPG_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libconfdb.so.4(COROSYNC_CONFDB_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcfg.so.4(COROSYNC_CFG_0.82)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libpload.so.4(COROSYNC_PLOAD_1.0)(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: liblogsys.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libconfdb.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcoroipcc.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcpg.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libquorum.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcoroipcs.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libvotequorum.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libcfg.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libtotem_pg.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
--> Processing Dependency: libpload.so.4()(64bit) for package: corosync-1.2.1-1.fc13.x86_64
---> Package pacemaker.x86_64 0:1.1.5-1.fc13 set to be updated
--> Processing Dependency: heartbeat >= 3.0.0 for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: net-snmp >= 5.4 for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: resource-agents for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: cluster-glue for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmp.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libcrmcluster.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpengine.so.3()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmpagent.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libesmtp.so.5()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libstonithd.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libhbclient.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpils.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpe_status.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmpmibs.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libnetsnmphelpers.so.20()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libcib.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libccmclient.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libstonith.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: liblrm.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libtransitioner.so.1()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libpe_rules.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libcrmcommon.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Processing Dependency: libplumb.so.2()(64bit) for package: pacemaker-1.1.5-1.fc13.x86_64
--> Running transaction check
---> Package cluster-glue.x86_64 0:1.0.2-1.fc13 set to be updated
--> Processing Dependency: perl-TimeDate for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libOpenIPMIutils.so.0()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libopenhpi.so.2()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
--> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: cluster-glue-1.0.2-1.fc13.x86_64
---> Package cluster-glue-libs.x86_64 0:1.0.2-1.fc13 set to be updated
---> Package corosynclib.x86_64 0:1.2.1-1.fc13 set to be updated
--> Processing Dependency: librdmacm.so.1(RDMACM_1.0)(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.0)(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.1)(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: libibverbs.so.1()(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
--> Processing Dependency: librdmacm.so.1()(64bit) for package: corosynclib-1.2.1-1.fc13.x86_64
---> Package heartbeat.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13 set to be updated
--> Processing Dependency: PyXML for package: heartbeat-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64
---> Package heartbeat-libs.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13 set to be updated
---> Package libesmtp.x86_64 0:1.0.4-12.fc12 set to be updated
---> Package net-snmp.x86_64 1:5.5-12.fc13 set to be updated
--> Processing Dependency: libsensors.so.4()(64bit) for package: 1:net-snmp-5.5-12.fc13.x86_64
---> Package net-snmp-libs.x86_64 1:5.5-12.fc13 set to be updated
---> Package pacemaker-libs.x86_64 0:1.1.5-1.fc13 set to be updated
---> Package resource-agents.x86_64 0:3.0.10-1.fc13 set to be updated
--> Processing Dependency: libnet.so.1()(64bit) for package: resource-agents-3.0.10-1.fc13.x86_64
--> Running transaction check
---> Package OpenIPMI-libs.x86_64 0:2.0.16-8.fc13 set to be updated
---> Package PyXML.x86_64 0:0.8.4-17.fc13 set to be updated
---> Package libibverbs.x86_64 0:1.1.3-4.fc13 set to be updated
--> Processing Dependency: libibverbs-driver for package: libibverbs-1.1.3-4.fc13.x86_64
---> Package libnet.x86_64 0:1.1.4-3.fc12 set to be updated
---> Package librdmacm.x86_64 0:1.0.10-2.fc13 set to be updated
---> Package lm_sensors-libs.x86_64 0:3.1.2-2.fc13 set to be updated
---> Package openhpi-libs.x86_64 0:2.14.1-3.fc13 set to be updated
---> Package perl-TimeDate.noarch 1:1.20-1.fc13 set to be updated
--> Running transaction check
---> Package libmlx4.x86_64 0:1.0.1-5.fc13 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved
==========================================================================================
 Package                Arch     Version                             Repository      Size
==========================================================================================
Installing:
 corosync               x86_64   1.2.1-1.fc13                        fedora         136 k
 pacemaker              x86_64   1.1.5-1.fc13                        fedora         543 k
Installing for dependencies:
 OpenIPMI-libs          x86_64   2.0.16-8.fc13                       fedora         474 k
 PyXML                  x86_64   0.8.4-17.fc13                       fedora         906 k
 cluster-glue           x86_64   1.0.2-1.fc13                        fedora         230 k
 cluster-glue-libs      x86_64   1.0.2-1.fc13                        fedora         116 k
 corosynclib            x86_64   1.2.1-1.fc13                        fedora         145 k
 heartbeat              x86_64   3.0.0-0.7.0daab7da36a8.hg.fc13      updates        172 k
 heartbeat-libs         x86_64   3.0.0-0.7.0daab7da36a8.hg.fc13      updates        265 k
 libesmtp               x86_64   1.0.4-12.fc12                       fedora          54 k
 libibverbs             x86_64   1.1.3-4.fc13                        fedora          42 k
 libmlx4                x86_64   1.0.1-5.fc13                        fedora          27 k
 libnet                 x86_64   1.1.4-3.fc12                        fedora          49 k
 librdmacm              x86_64   1.0.10-2.fc13                       fedora          22 k
 lm_sensors-libs        x86_64   3.1.2-2.fc13                        fedora          37 k
 net-snmp               x86_64   1:5.5-12.fc13                       fedora         295 k
 net-snmp-libs          x86_64   1:5.5-12.fc13                       fedora         1.5 M
 openhpi-libs           x86_64   2.14.1-3.fc13                       fedora         135 k
 pacemaker-libs         x86_64   1.1.5-1.fc13                        fedora         264 k
 perl-TimeDate          noarch   1:1.20-1.fc13                       fedora          42 k
 resource-agents        x86_64   3.0.10-1.fc13                       fedora         357 k

Transaction Summary
=========================================================================================
Install      21 Package(s)
Upgrade       0 Package(s)

Total download size: 5.7 M
Installed size: 20 M
Downloading Packages:
Setting up and reading Presto delta metadata
updates-testing/prestodelta                                           | 164 kB     00:00     
fedora/prestodelta                                                    |  150 B     00:00     
Processing delta metadata
Package(s) data still to download: 5.7 M
(1/21): OpenIPMI-libs-2.0.16-8.fc13.x86_64.rpm                        | 474 kB     00:00     
(2/21): PyXML-0.8.4-17.fc13.x86_64.rpm                                | 906 kB     00:01     
(3/21): cluster-glue-1.0.2-1.fc13.x86_64.rpm                          | 230 kB     00:00     
(4/21): cluster-glue-libs-1.0.2-1.fc13.x86_64.rpm                     | 116 kB     00:00     
(5/21): corosync-1.2.1-1.fc13.x86_64.rpm                              | 136 kB     00:00     
(6/21): corosynclib-1.2.1-1.fc13.x86_64.rpm                           | 145 kB     00:00     
(7/21): heartbeat-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64.rpm           | 172 kB     00:00     
(8/21): heartbeat-libs-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64.rpm      | 265 kB     00:00     
(9/21): libesmtp-1.0.4-12.fc12.x86_64.rpm                             |  54 kB     00:00     
(10/21): libibverbs-1.1.3-4.fc13.x86_64.rpm                           |  42 kB     00:00     
(11/21): libmlx4-1.0.1-5.fc13.x86_64.rpm                              |  27 kB     00:00     
(12/21): libnet-1.1.4-3.fc12.x86_64.rpm                               |  49 kB     00:00     
(13/21): librdmacm-1.0.10-2.fc13.x86_64.rpm                           |  22 kB     00:00     
(14/21): lm_sensors-libs-3.1.2-2.fc13.x86_64.rpm                      |  37 kB     00:00     
(15/21): net-snmp-5.5-12.fc13.x86_64.rpm                              | 295 kB     00:00     
(16/21): net-snmp-libs-5.5-12.fc13.x86_64.rpm                         | 1.5 MB     00:01     
(17/21): openhpi-libs-2.14.1-3.fc13.x86_64.rpm                        | 135 kB     00:00     
(18/21): pacemaker-1.1.5-1.fc13.x86_64.rpm                            | 543 kB     00:00     
(19/21): pacemaker-libs-1.1.5-1.fc13.x86_64.rpm                       | 264 kB     00:00     
(20/21): perl-TimeDate-1.20-1.fc13.noarch.rpm                         |  42 kB     00:00     
(21/21): resource-agents-3.0.10-1.fc13.x86_64.rpm                     | 357 kB     00:00     
----------------------------------------------------------------------------------------
Total                                                        539 kB/s | 5.7 MB     00:10     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID e8e40fde: NOKEY
fedora/gpgkey                                                         | 3.2 kB     00:00 ... 
Importing GPG key 0xE8E40FDE "Fedora (13) <fedora@fedoraproject.org%gt;" from /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : lm_sensors-libs-3.1.2-2.fc13.x86_64                            1/21 
  Installing     : 1:net-snmp-libs-5.5-12.fc13.x86_64                             2/21 
  Installing     : 1:net-snmp-5.5-12.fc13.x86_64                                  3/21 
  Installing     : openhpi-libs-2.14.1-3.fc13.x86_64                              4/21 
  Installing     : libibverbs-1.1.3-4.fc13.x86_64                                 5/21 
  Installing     : libmlx4-1.0.1-5.fc13.x86_64                                    6/21 
  Installing     : librdmacm-1.0.10-2.fc13.x86_64                                 7/21 
  Installing     : corosync-1.2.1-1.fc13.x86_64                                   8/21 
  Installing     : corosynclib-1.2.1-1.fc13.x86_64                                9/21 
  Installing     : libesmtp-1.0.4-12.fc12.x86_64                                 10/21 
  Installing     : OpenIPMI-libs-2.0.16-8.fc13.x86_64                            11/21 
  Installing     : PyXML-0.8.4-17.fc13.x86_64                                    12/21 
  Installing     : libnet-1.1.4-3.fc12.x86_64                                    13/21 
  Installing     : 1:perl-TimeDate-1.20-1.fc13.noarch                            14/21 
  Installing     : cluster-glue-1.0.2-1.fc13.x86_64                              15/21 
  Installing     : cluster-glue-libs-1.0.2-1.fc13.x86_64                         16/21 
  Installing     : resource-agents-3.0.10-1.fc13.x86_64                          17/21 
  Installing     : heartbeat-libs-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64          18/21 
  Installing     : heartbeat-3.0.0-0.7.0daab7da36a8.hg.fc13.x86_64               19/21 
  Installing     : pacemaker-1.1.5-1.fc13.x86_64                                 20/21 
  Installing     : pacemaker-libs-1.1.5-1.fc13.x86_64                            21/21 

Installed:
  corosync.x86_64 0:1.2.1-1.fc13                    pacemaker.x86_64 0:1.1.5-1.fc13                   

Dependency Installed:
  OpenIPMI-libs.x86_64 0:2.0.16-8.fc13                          
  PyXML.x86_64 0:0.8.4-17.fc13                                  
  cluster-glue.x86_64 0:1.0.2-1.fc13                            
  cluster-glue-libs.x86_64 0:1.0.2-1.fc13                       
  corosynclib.x86_64 0:1.2.1-1.fc13                             
  heartbeat.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13             
  heartbeat-libs.x86_64 0:3.0.0-0.7.0daab7da36a8.hg.fc13        
  libesmtp.x86_64 0:1.0.4-12.fc12                               
  libibverbs.x86_64 0:1.1.3-4.fc13                              
  libmlx4.x86_64 0:1.0.1-5.fc13                                 
  libnet.x86_64 0:1.1.4-3.fc12                                  
  librdmacm.x86_64 0:1.0.10-2.fc13                              
  lm_sensors-libs.x86_64 0:3.1.2-2.fc13                         
  net-snmp.x86_64 1:5.5-12.fc13                                 
  net-snmp-libs.x86_64 1:5.5-12.fc13                            
  openhpi-libs.x86_64 0:2.14.1-3.fc13                           
  pacemaker-libs.x86_64 0:1.1.5-1.fc13                          
  perl-TimeDate.noarch 1:1.20-1.fc13                            
  resource-agents.x86_64 0:3.0.10-1.fc13                        

Complete!
[root@pcmk-1 ~]#

2.3. Prima di continuare

Ripetere i passi dell'installazione così da avere due nodi Fedora con il software cluster installato.
Per rispettae gli obiettivi di questa documentazione il nodo aggiuntivo verrà chiamato pcmk-2 con indirizzo 192.168.122.42.

2.4. Setup

2.4.1. Definire la rete

Verificare la reciproca comunicazione dei due nodi:
	  ping -c 3 192.168.122.102
[root@pcmk-1 ~]# ping -c 3 192.168.122.102
PING 192.168.122.102 (192.168.122.102) 56(84) bytes of data.
64 bytes from 192.168.122.102: icmp_seq=1 ttl=64 time=0.343 ms
64 bytes from 192.168.122.102: icmp_seq=2 ttl=64 time=0.402 ms
64 bytes from 192.168.122.102: icmp_seq=3 ttl=64 time=0.558 ms

--- 192.168.122.102 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.343/0.434/0.558/0.092 ms
Figura 2.18. Verifica della connettività dall'indirizzo IP

Now we need to make sure we can communicate with the machines by their name. If you have a DNS server, add additional entries for the three machines. Otherwise, you’ll need to add the machines to /etc/hosts . Below are the entries for my cluster nodes:
	  grep pcmk /etc/hosts
[root@pcmk-1 ~]# grep pcmk /etc/hosts
192.168.122.101 pcmk-1.clusterlabs.org pcmk-1
192.168.122.102 pcmk-2.clusterlabs.org pcmk-2
Figura 2.19. Settaggio /etc/hosts

Ora è possibile verificare il setup usando nuovamente ping:
	  ping -c 3 pcmk-2
[root@pcmk-1 ~]# ping -c 3 pcmk-2
PING pcmk-2.clusterlabs.org (192.168.122.101) 56(84) bytes of data.
64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=1 ttl=64 time=0.164 ms
64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=2 ttl=64 time=0.475 ms
64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=3 ttl=64 time=0.186 ms

--- pcmk-2.clusterlabs.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.164/0.275/0.475/0.141 ms
Figura 2.20. Verifica della connettività attraverso l'hostname

2.4.2. Configuarazione di SSH

SSH is a convenient and secure way to copy files and perform commands remotely. For the purposes of this guide, we will create a key without a password (using the -N “” option) so that we can perform remote actions without being prompted.

Avvertimento

Chiavi SSH non protette, senza una password, non sono raccomandate per server esposti al mondo.
Creazione di una nuova chiave ed abilitazione al proprietario della chiave di effettuare login:
[root@pcmk-1 ~]# ssh-keygen -t dsa -f ~/.ssh/id_dsa -N ""
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
91:09:5c:82:5a:6a:50:08:4e:b2:0c:62:de:cc:74:44 root@pcmk-1.clusterlabs.org

The key's randomart image is:
+--[ DSA 1024]----+
|==.ooEo..        |
|X O + .o o       |
| * A    +        |
|  +      .       |
| .      S        |
|                 |
|                 |
|                 |
|                 |
+-----------------+
[root@pcmk-1 ~]# cp .ssh/id_dsa.pub .ssh/authorized_keys
[root@pcmk-1 ~]#
Figura 2.21. Creazione ed attivazione di una nuova chiave SSH

Installare la chiave sull'altro nodo e verificare come sia possibile lanciare comandi remotamente, senza ricevere prompt
[root@pcmk-1 ~]# scp -r .ssh pcmk-2:
The authenticity of host 'pcmk-2 (192.168.122.102)' can't be established.
RSA key fingerprint is b1:2b:55:93:f1:d9:52:2b:0f:f2:8a:4e:ae:c6:7c:9a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'pcmk-2,192.168.122.102' (RSA) to the list of known hosts.
root@pcmk-2's password: 
id_dsa.pub                           100%  616     0.6KB/s   00:00    
id_dsa                               100%  672     0.7KB/s   00:00    
known_hosts                          100%  400     0.4KB/s   00:00    
authorized_keys                      100%  616     0.6KB/s   00:00    
[root@pcmk-1 ~]# ssh pcmk-2 -- uname -n
pcmk-2
[root@pcmk-1 ~]#
Figura 2.22. Installare la chiave SSH su un altro host

2.4.3. Nomi di nodi abbreviati

During installation, we filled in the machine’s fully qualifier domain name (FQDN) which can be rather long when it appears in cluster logs and status output. See for yourself how the machine identifies itself:
[root@pcmk-1 ~]# uname -n
pcmk-1.clusterlabs.org
[root@pcmk-1 ~]# dnsdomainname 
clusterlabs.org
The output from the second command is fine, but we really don’t need the domain name included in the basic host details. To address this, we need to update /etc/sysconfig/network. This is what it should look like before we start.
[root@pcmk-1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=pcmk-1.clusterlabs.org
GATEWAY=192.168.122.1
L'unica cosa da fare sarà di rimuovere la parte relativa al nome del dominio, che rimarrà comunque registrata altrove.
[root@pcmk-1 ~]# sed -i.bak 's/\.[a-z].*//g' /etc/sysconfig/network
Per verificare l'efficacia dei cambiamenti apportati il contenuto del file dovrà essere simile a quanto riportato.
[root@pcmk-1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=pcmk-1
GATEWAY=192.168.122.1
However we’re not finished. The machine wont normally see the shortened host name until about it reboots, but we can force it to update.
[root@pcmk-1 ~]# source /etc/sysconfig/network
[root@pcmk-1 ~]# hostname $HOSTNAME
E' possibile quindi verificare che la macchina utilizzi il nome corretto
[root@pcmk-1 ~]# uname -n
pcmk-1
[root@pcmk-1 ~]# dnsdomainname 
clusterlabs.org
Le stesse operazioni andranno ripetute su pcmk-2

2.4.4. Configurare Corosync

Scegliere un numero di porta ed un indirizzo [9]multi-cast. [10]
Assicurarsi che i valori scelti non vadano in conflitto con qualsiasi altra configurazione cluster presente nella rete. Per consigli sulla scelta dell'indirizzo vedere http://www.29west.com/docs/THPM/multicast-address-assignment.html
Per questo progetto è stata scelta la porta 4000 e l'indirizzo multi-cast 226.94.1.1.

Importante

The instructions below only apply for a machine with a single NIC. If you have a more complicated setup, you should edit the configuration manually.
[root@pcmk-1 ~]# export ais_port=4000
[root@pcmk-1 ~]# export ais_mcast=226.94.1.1
A questo punto è possibile determinare automaticamente l'indirizzo degli host. Non utilizzando l'indirizzo completo la configurazione è copiabile sugli altri nodi.
[root@pcmk-1 ~]# export ais_addr=`ip addr | grep "inet " | tail -n 1 | awk '{print $4}' | sed s/255/0/`
Visualizzazione e verifica delle opzioni di configurazione
[root@pcmk-1 ~]# env | grep ais_
ais_mcast=226.94.1.1
ais_port=4000
ais_addr=192.168.122.0
Once you're happy with the chosen values, update the Corosync configuration
[root@pcmk-1 ~]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
[root@pcmk-1 ~]# sed -i.bak "s/.*mcastaddr:.*/mcastaddr:\ $ais_mcast/g" /etc/corosync/corosync.conf
[root@pcmk-1 ~]# sed -i.bak "s/.*mcastport:.*/mcastport:\ $ais_port/g" /etc/corosync/corosync.conf
[root@pcmk-1 ~]# sed -i.bak "s/.*bindnetaddr:.*/bindnetaddr:\ $ais_addr/g" /etc/corosync/corosync.conf
Finally, tell Corosync to load the Pacemaker plugin.
[root@pcmk-1 ~]# cat <<-END >>/etc/corosync/service.d/pcmk
service {
        # Load the Pacemaker Cluster Resource Manager
        name: pacemaker
        ver:  1
}
END
The final configuration should look something like the sample in Appendice B, Sample Corosync Configuration.

Importante

When run in version 1 mode, the plugin does not start the Pacemaker daemons. Instead it just sets up the quorum and messaging interfaces needed by the rest of the stack.
Starting the dameons occurs when the Pacemaker init script is invoked. This resolves two long standing issues:
  1. Forking inside a multi-threaded process like Corosync causes all sorts of pain. This has been problematic for Pacemaker as it needs a number of daemons to be spawned.
  2. Corosync was never designed for staggered shutdown - something previously needed in order to prevent the cluster from leaving before Pacemaker could stop all active resources.

2.4.5. Distribuire la configurazione

Ora è necessario copiare le modifiche effettuate sinora all'altro nodo:
[root@pcmk-1 ~]# for f in /etc/corosync/corosync.conf /etc/corosync/service.d/pcmk /etc/hosts; do scp $f pcmk-2:$f ; done
corosync.conf                            100% 1528     1.5KB/s   00:00
hosts                                    100%  281     0.3KB/s   00:00
[root@pcmk-1 ~]#

Capitolo 3. Verifica dell'installazione del cluster

3.1. Verifica dell'installazione di Corosync

Avvio di Corosync sul primo nodo
[root@pcmk-1 ~]# /etc/init.d/corosync start
Starting Corosync Cluster Engine (corosync): [ OK ]
Controllo del corretto avvio del cluster e che è stata formata la membership iniziale
[root@pcmk-1 ~]# grep -e "corosync.*network interface" -e "Corosync Cluster Engine" -e "Successfully read main configuration file" /var/log/messages
Aug 27 09:05:34 pcmk-1 corosync[1540]: [MAIN  ] Corosync Cluster Engine ('1.1.0'): started and ready to provide service.
Aug 27 09:05:34 pcmk-1 corosync[1540]: [MAIN  ] Successfully read main configuration file '/etc/corosync/corosync.conf'.
[root@pcmk-1 ~]# grep TOTEM /var/log/messages
Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transport (UDP/IP).
Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0).
Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] The network interface [192.168.122.101] is now up.
Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] A processor joined or left the membership and a new membership was formed.
Con un nodo funzionante è ora sicuro avviare Corosync anche sul secondo nodo.
[root@pcmk-1 ~]# ssh pcmk-2 -- /etc/init.d/corosync start
Starting Corosync Cluster Engine (corosync): [ OK ]
[root@pcmk-1 ~]#
Controllo della corretta formazione del cluster
[root@pcmk-1 ~]# grep TOTEM /var/log/messages
Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transport (UDP/IP).
Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0).
Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] The network interface [192.168.122.101] is now up.
Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] A processor joined or left the membership and a new membership was formed.
Aug 27 09:12:11 pcmk-1 corosync[1540]: [TOTEM ] A processor joined or left the membership and a new membership was formed.

3.2. Verifica dell'installazione di Pacemaker

Ora che è stato verificato come Corosync sia funzionante è quindi possibile controllare il resto dello stack.
[root@pcmk-1 ~]# grep pcmk_startup /var/log/messages
Aug 27 09:05:35 pcmk-1 corosync[1540]:   [pcmk  ] info: pcmk_startup: CRM: Initialized
Aug 27 09:05:35 pcmk-1 corosync[1540]:   [pcmk  ] Logging: Initialized pcmk_startup
Aug 27 09:05:35 pcmk-1 corosync[1540]:   [pcmk  ] info: pcmk_startup: Maximum core file size is: 18446744073709551615
Aug 27 09:05:35 pcmk-1 corosync[1540]:   [pcmk  ] info: pcmk_startup: Service: 9
Aug 27 09:05:35 pcmk-1 corosync[1540]:   [pcmk  ] info: pcmk_startup: Local hostname: pcmk-1
Now try starting Pacemaker and check the necessary processes have been started
[root@pcmk-1 ~]# /etc/init.d/pacemaker start
Starting Pacemaker Cluster Manager: [ OK ]
[root@pcmk-1 ~]# grep -e pacemakerd.*get_config_opt -e pacemakerd.*start_child -e "Starting Pacemaker" /var/log/messages
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'pacemaker' for option: name
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found '1' for option: ver
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Defaulting to 'no' for option: use_logd
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Defaulting to 'no' for option: use_mgmtd
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'on' for option: debug
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'yes' for option: to_logfile
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found '/var/log/corosync.log' for option: logfile
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'yes' for option: to_syslog
Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'daemon' for option: syslog_facility
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: main: Starting Pacemaker 1.1.5 (Build: 31f088949239+):  docbook-manpages publican ncurses trace-logging cman cs-quorum heartbeat corosync snmp libesmtp
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14022 for process stonith-ng
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14023 for process cib
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14024 for process lrmd
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14025 for process attrd
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14026 for process pengine
Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14027 for process crmd
[root@pcmk-1 ~]# ps axf
  PID TTY      STAT   TIME COMMAND
    2 ?        S<     0:00 [kthreadd]
    3 ?        S<     0:00  \_ [migration/0]
... lots of processes ...
 13990 ?    S       0:01 pacemakerd
 14022 ?    Sa      0:00  \_ /usr/lib64/heartbeat/stonithd
 14023 ?    Sa      0:00  \_ /usr/lib64/heartbeat/cib
 14024 ?    Sa      0:00  \_ /usr/lib64/heartbeat/lrmd
 14025 ?    Sa      0:00  \_ /usr/lib64/heartbeat/attrd
 14026 ?    Sa      0:00  \_ /usr/lib64/heartbeat/pengine
 14027 ?    Sa      0:00  \_ /usr/lib64/heartbeat/crmd
Next, check for any ERRORs during startup - there shouldn’t be any.
[root@pcmk-1 ~]# grep ERROR: /var/log/messages | grep -v unpack_resources
[root@pcmk-1 ~]#
Repeat on the other node and display the cluster's status.
[root@pcmk-1 ~]# ssh pcmk-2 -- /etc/init.d/pacemaker start
Starting Pacemaker Cluster Manager: [ OK ]
[root@pcmk-1 ~]# crm_mon
============
Last updated: Thu Aug 27 16:54:55 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
0 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

Capitolo 4. Utilizzare i tool di Pacemaker

Nell'oscuro passato configurare Pacemaer richiedeva all'amministratore di leggere e scrivere XML. In vero stile UNIX c'erano inoltre parecchi comandi differendi, specializzati in aspetti differenti di interrogazione ed aggiornamento del cluster.
Con Pacemaker 1.0 tutto questo è cambiato ed ora esiste una cluster shell integrata e scriptabile che nasconde tutta la confusionaria impalcatura XML. Essa permette di accodare i diversi cambiamente in una sola volta ed applicarli automaticamente.
Va dedicato del tempo a familiarizzare con le peculiarità della shell.
[root@pcmk-1 ~]# crm --help

usage:
    crm [-D display_type]
    crm [-D display_type] args
    crm [-D display_type] [-f file]

    Use crm without arguments for an interactive session.
    Supply one or more arguments for a "single-shot" use.
    Specify with -f a file which contains a script. Use '-' for
    standard input or use pipe/redirection.

    crm displays cli format configurations using a color scheme
    and/or in uppercase. Pick one of "color" or "uppercase", or
    use "-D color,uppercase" if you want colorful uppercase.
    Get plain output by "-D plain". The default may be set in
    user preferences (options).

Examples:

    # crm -f stopapp2.cli
    # crm < stopapp2.cli
    # crm resource stop global_www
    # crm status
Il principale tool per il monitoraggio dello stato è crm_mon (disponibile anche come crm status). Può essere lanciato in diverse modalità e con svariate tipologie di output. Per scoprire le funzionalità dei tool disponibili con Pacemaker è sufficiente invocarli con l'opzione --help oppure consultare le man page incluse. Entrambe i tipi di output sono creati dal tool e quindi saranno sempre sincronizzate l'una con l'altra, oltre che con il tool stesso.
La versione ed il cluster stack supportati di Pacemaker sono inoltre disponibili attraverso l'opzione --version.
[root@pcmk-1 ~]# crm_mon --version
Pacemaker 1.1.5
Written by Andrew Beekhof
[root@pcmk-1 ~]# crm_mon --help
crm_mon - Provides a summary of cluster's current state.

Outputs varying levels of detail in a number of different formats.

Usage: crm_mon mode [options]
Options:
 -?, --help                 This text
 -$, --version              Version information
 -V, --verbose              Increase debug output

Modes:
 -h, --as-html=value        Write cluster status to the named file
 -w, --web-cgi              Web mode with output suitable for cgi
 -s, --simple-status        Display the cluster status once as a simple one line output (suitable for nagios)
 -S, --snmp-traps=value     Send SNMP traps to this station
 -T, --mail-to=value        Send Mail alerts to this user.  See also --mail-from, --mail-host, --mail-prefix

Display Options:
 -n, --group-by-node        Group resources by node
 -r, --inactive             Display inactive resources
 -f, --failcounts           Display resource fail counts
 -o, --operations           Display resource operation history
 -t, --timing-details       Display resource operation history with timing details


Additional Options:
 -i, --interval=value           Update frequency in seconds
 -1, --one-shot                 Display the cluster status once on the console and exit
 -N, --disable-ncurses          Disable the use of ncurses
 -d, --daemonize                Run in the background as a daemon
 -p, --pid-file=value           (Advanced) Daemon pid file location
 -F, --mail-from=value          Mail alerts should come from the named user
 -H, --mail-host=value          Mail alerts should be sent via the named host
 -P, --mail-prefix=value        Subjects for mail alerts should start with this string
 -E, --external-agent=value     A program to run when resource operations take place.
 -e, --external-recipient=value A recipient for your program (assuming you want the program to send something to someone).

Examples:

Display the cluster´s status on the console with updates as they occur:
        # crm_mon

Display the cluster´s status on the console just once then exit:
        # crm_mon -1

Display your cluster´s status, group resources by node, and include inactive resources in the list:
        # crm_mon --group-by-node --inactive

Start crm_mon as a background daemon and have it write the cluster´s status to an HTML file:
        # crm_mon --daemonize --as-html /path/to/docroot/filename.html

Start crm_mon as a background daemon and have it send email alerts:
        # crm_mon --daemonize --mail-to user@example.com --mail-host mail.example.com

Start crm_mon as a background daemon and have it send SNMP alerts:
        # crm_mon --daemonize --snmp-traps snmptrapd.example.com

Report bugs to pacemaker@oss.clusterlabs.org

Nota

Se SNMP e/o le opzioni mail non sono listate allora Pacemaker non è stato compilato per supportare queste funzionalità. Potrebbe essere dovuto ad una scelta della distribuzione che si sta utilizzando oppure al fatto che le librerie necessarie non sono disponibili. In questo caso è bene contattare il fornitore dei pacchetti per avere maggiori dettagli.

Capitolo 5. Creare un cluster Active/Passive

5.1. Esplorare la configurazione esistente

Quando Pacemaker viene avviato automatica registra il numero ed i dettagli dei nodi nel cluster, così come lo stack è utilizzato e la versione di Pacemaker utilizzata.
Ecco come dovrebbe apparire la configurazione base.
[root@pcmk-2 ~]# crm configure show
node pcmk-1
node pcmk-2
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2"
For those that are not of afraid of XML, you can see the raw configuration by appending “xml” to the previous command.
[root@pcmk-2 ~]# crm configure show xml
<?xml version="1.0" ?>
<cib admin_epoch="0" crm_feature_set="3.0.1" dc-uuid="pcmk-1" epoch="13" have-quorum="1" num_updates="7" validate-with="pacemaker-1.0">
  <configuration>
    <crm_config>
      <cluster_property_set id="cib-bootstrap-options">
        <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f"/>
        <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="openais"/>
        <nvpair id="cib-bootstrap-options-expected-quorum-votes" name="expected-quorum-votes" value="2"/>
      </cluster_property_set>
    </crm_config>
    <rsc_defaults/>
    <op_defaults/>
    <nodes>
      <node id="pcmk-1" type="normal" uname="pcmk-1"/>
      <node id="pcmk-2" type="normal" uname="pcmk-2"/>
    </nodes>
    <resources/>
    <constraints/>
  </configuration>
</cib>
The last XML you’ll see in this document
Prima di effettuare qualsiasi cambiamento è buona norma controllare la validità della configurazione.
[root@pcmk-1 ~]# crm_verify -L
crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have been defined
crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option
crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
  -V may provide more details
[root@pcmk-1 ~]#
Come si può notare il tool ha trovato qualche errore.
In order to guarantee the safety of your data [11] , Pacemaker ships with STONITH [12] enabled. However it also knows when no STONITH configuration has been supplied and reports this as a problem (since the cluster would not be able to make progress if a situation requiring node fencing arose).
Per adesso la funzionalità verrà disabilitata e configurata in seguito nella sezione Configurare STONITH. E' importante notare che l'uso di STONITH è altamente consigliato, disabilitarlo indica al cluster di dare per scontato che i nodi falliti vengano spenti. Alcuni rivenditori potrebbero rifiutarsi di supportare cluster che hanno STONITH disabilitato.
Per disabilitare STONITH è necessario impostare l'opzione stonith-enabled a false.
crm configure property stonith-enabled=false
crm_verify -L
Con la nuova opzione impostata la configurazione del cluster è ora valida.

Avvertimento

The use of stonith-enabled=false is completely inappropriate for a production cluster. We use it here to defer the discussion of its configuration which can differ widely from one installation to the next. See Capitolo 9, Configurare STONITH for information on why STONITH is important and details on how to configure it.

5.2. Aggiungere una risorsa

La prima cosa da fare è configurare un indirizzo IP. Indipendentemente da dove i servizi cluster stanno funzionando è necessario un indirizzo per raggiungerli. Verrà scelto ed aggiunto 192.168.122.101 come indirizzo virtuale, con il nome di ClusterIP e verrà indicato al cluster di controllarlo ogni 30 secondi.

Importante

L'indirizzo scelto non dovrà essere già associato ad un nodo fisico
crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 \ 
        params ip=192.168.122.101 cidr_netmask=32 \ 
        op monitor interval=30s
L'altra informazione presentata qui è ocf:heartbeat:IPaddr2. Esso comunica a Pacemaker tre informazioni in merito alla risorsa che viene aggiunta. Il primo campo, ocf, indica lo standard a cui lo script della risorsa si conforma e dove trovarlo. Il secondo campo è specifico delle risorse OCF e indica al cluster in quale namespace trovare lo script, in questo caso heartbeat. L'ultimo campo indica il nome dello script della risorsa.
Per ottenere una lista delle classi di risorse disponibili, lanciare
[root@pcmk-1 ~]# crm ra classes
heartbeat
lsb
ocf / heartbeat pacemaker
stonith
Per poi trovare tutte i resource agent OCF disponibili con Pacemaker ed Heartbeat, lanciare
[root@pcmk-1 ~]# crm ra list ocf pacemaker
ClusterMon     Dummy          Stateful       SysInfo        SystemHealth   controld
ping           pingd          
[root@pcmk-1 ~]# crm ra list ocf heartbeat
AoEtarget              AudibleAlarm           ClusterMon             Delay
Dummy                  EvmsSCC                Evmsd                  Filesystem
ICP                    IPaddr                 IPaddr2                IPsrcaddr
LVM                    LinuxSCSI              MailTo                 ManageRAID
ManageVE               Pure-FTPd              Raid1                  Route
SAPDatabase            SAPInstance            SendArp                ServeRAID
SphinxSearchDaemon     Squid                  Stateful               SysInfo
VIPArip                VirtualDomain          WAS                    WAS6
WinPopup               Xen                    Xinetd                 anything
apache                 db2                    drbd                   eDir88
iSCSILogicalUnit       iSCSITarget            ids                    iscsi
ldirectord             mysql                  mysql-proxy            nfsserver
oracle                 oralsnr                pgsql                  pingd
portblock              rsyncd                 scsi2reservation       sfex
tomcat                 vmware                 
[root@pcmk-1 ~]#
Now verify that the IP resource has been added and display the cluster’s status to see that it is now active.
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive ClusterIP ocf:heartbeat:IPaddr2 \
 params ip="192.168.122.101" cidr_netmask="32" \
 op monitor interval="30s"
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 15:23:48 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
1 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]
ClusterIP (ocf::heartbeat:IPaddr): Started pcmk-1

5.3. Effettuare un Failover

Trattandosi di un cluster ad alta-affidabilità, è necessario testare il failover della nostra nuova risorsa prima di proseguire.
Per prima cosa va identificato da quale nodo l'indirizzo IP è erogato
[root@pcmk-1 ~]# crm resource status ClusterIP
resource ClusterIP is running on: pcmk-1
[root@pcmk-1 ~]#
Shut down Pacemaker and Corosync on that machine.
[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/pacemaker stop
Signaling Pacemaker Cluster Manager to terminate: [ OK ]
Waiting for cluster services to unload:. [ OK ]
[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/corosync stop
Stopping Corosync Cluster Engine (corosync): [ OK ]
Waiting for services to unload: [ OK ]
[root@pcmk-1 ~]#
Una volta che Corosync non sta più funzionando, è possibile verificare sull'altro nodo lo stato del cluster attraverso crm_mon.
[root@pcmk-2 ~]# crm_mon
============
Last updated: Fri Aug 28 15:27:35 2009
Stack: openais
Current DC: pcmk-2 - partition WITHOUT quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
1 Resources configured.
============

Online: [ pcmk-2 ]
OFFLINE: [ pcmk-1 ]
There are three things to notice about the cluster’s current state. The first is that, as expected, pcmk-1 is now offline. However we can also see that ClusterIP isn’t running anywhere!

5.3.1. Quorum e Cluster a due nodi

This is because the cluster no longer has quorum, as can be seen by the text “partition WITHOUT quorum” (emphasised green) in the output above. In order to reduce the possibility of data corruption, Pacemaker’s default behavior is to stop all resources if the cluster does not have quorum.
Un cluster viene definito con quorum quando più della metà dei nodi conosciuti o aspettati sono online o, attraverso la matematica, quando la seguente equazione è vera:
total_nodes - 1 < 2 * active_nodes
Pertanto, un cluster a due nodi ha quorum solo quando entrambi i nodi sono in esecuzione, e questo non è più il caso del cluster d'esempio. Questo normalmente renderebbe la creazione di cluster a due nodi inutile[13], ad ogni modo è possibile controllare come Pacemaker gestisce la perdita di quorum. In particolare è possibile indicare al cluster di ignorare semplicemente l'assenza di quorum.
[root@pcmk-1 ~]# crm configure property no-quorum-policy=ignore
[root@pcmk-1 ~]# crm configure show 
node pcmk-1
node pcmk-2
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
Dopo alcuni istanti il cluster avvierà l'indirizzo IP sui nodi rimanenti. E' da notare che il cluster non ha comunque il quorum.
[root@pcmk-2 ~]# crm_mon
============
Last updated: Fri Aug 28 15:30:18 2009
Stack: openais
Current DC: pcmk-2 - partition WITHOUT quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ pcmk-2 ]
OFFLINE: [ pcmk-1 ]

ClusterIP (ocf::heartbeat:IPaddr): Started pcmk-2
Now simulate node recovery by restarting the cluster stack on pcmk-1 and check the cluster’s status.
[root@pcmk-1 ~]# /etc/init.d/corosync start
Starting Corosync Cluster Engine (corosync): [ OK ]      
[root@pcmk-1 ~]# /etc/init.d/pacemaker start
Starting Pacemaker Cluster Manager: [ OK ]
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 15:32:13 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1
Qui appare qualcosa che potrebbe sembrare sorprendente: l'IP è tornato attivo sul nodo originale!

5.3.2. Evitare che le risorse si muovano dopo il recovery

In alcune circostanze è altamente desiderabile prevenire che risorse sane vengano mosse nel cluster. Lo spostamento delle risorse richiede in genere un periodo di downtime e per servizi complessi, come i database Oracle, tale periodo può essere piuttosto lungo.
To address this, Pacemaker has the concept of resource stickiness which controls how much a service prefers to stay running where it is. You may like to think of it as the “cost” of any downtime. By default, Pacemaker assumes there is zero cost associated with moving resources and will do so to achieve “optimal[14]” resource placement. We can specify a different stickiness for every resource, but it is often sufficient to change the default.
crm configure rsc_defaults resource-stickiness=100
[root@pcmk-2 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
 resource-stickiness="100"
Se ora si effettua nuovamente il test di failover si osserverà che come da pronostico ClusterIP verrà spostata su pcmk-2 quando pcmk-1 viene messo offline.
[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/pacemaker stop
Signaling Pacemaker Cluster Manager to terminate:          [  OK  ]
Waiting for cluster services to unload:.                   [  OK  ]
[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/corosync stop
Stopping Corosync Cluster Engine (corosync):               [  OK  ]
Waiting for services to unload:                            [  OK  ]
[root@pcmk-1 ~]# ssh pcmk-2 -- crm_mon -1
============
Last updated: Fri Aug 28 15:39:38 2009
Stack: openais
Current DC: pcmk-2 - partition WITHOUT quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
1 Resources configured.
============

Online: [ pcmk-2 ]
OFFLINE: [ pcmk-1 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
Quando però pcmk-1 torna online ClusterIP rimane su pcmk-2.
[root@pcmk-1 ~]# /etc/init.d/corosync start
Starting Corosync Cluster Engine (corosync): [ OK ]
[root@pcmk-1 ~]# /etc/init.d/pacemaker start
Starting Pacemaker Cluster Manager: [ OK ]
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 15:41:23 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
1 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2


[11] If the data is corrupt, there is little point in continuing to make it available

[12] A common node fencing mechanism. Used to ensure data integrity by powering off “bad” nodes.

[13] Attualmente molti potrebbero puntualizzare che i cluster a due nodi sono sempre inutili, ma questo è argomento di future discussioni.

[14] It should be noted that Pacemaker’s definition of optimal may not always agree with that of a human’s. The order in which Pacemaker processes lists of resources and nodes create implicit preferences (required in order to create a stabile solution) in situations where the administrator had not explicitly specified some.

Capitolo 6. Apache - Aggiungere ulteriori servizi

Nota

Now that we have a basic but functional active/passive two-node cluster, we’re ready to add some real services. We’re going to start with Apache because its a feature of many clusters and relatively simple to configure.

6.1. Installazione

Prima di cominciare è necessario assicurarsi che Apache sia installato su entrambi gli host.
[root@ppcmk-1 ~]# yum install -y httpd
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.13-2.fc12 set to be updated
--> Processing Dependency: httpd-tools = 2.2.13-2.fc12 for package: httpd-2.2.13-2.fc12.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.13-2.fc12.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.13-2.fc12.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.13-2.fc12.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.13-2.fc12.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-2.fc12 set to be updated
---> Package apr-util.x86_64 0:1.3.9-2.fc12 set to be updated
---> Package apr-util-ldap.x86_64 0:1.3.9-2.fc12 set to be updated
---> Package httpd-tools.x86_64 0:2.2.13-2.fc12 set to be updated
---> Package mailcap.noarch 0:2.1.30-1.fc12 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================
 Package               Arch             Version                Repository         Size
=======================================================================================
Installing:
 httpd               x86_64           2.2.13-2.fc12            rawhide           735 k
Installing for dependencies:
 apr                 x86_64           1.3.9-2.fc12             rawhide           117 k
 apr-util            x86_64           1.3.9-2.fc12             rawhide            84 k
 apr-util-ldap       x86_64           1.3.9-2.fc12             rawhide            15 k
 httpd-tools         x86_64           2.2.13-2.fc12            rawhide            63 k
 mailcap             noarch           2.1.30-1.fc12            rawhide            25 k

Transaction Summary
=======================================================================================
Install       6 Package(s)
Upgrade       0 Package(s)

Total download size: 1.0 M
Downloading Packages:
(1/6): apr-1.3.9-2.fc12.x86_64.rpm                                   | 117 kB     00:00     
(2/6): apr-util-1.3.9-2.fc12.x86_64.rpm                              |  84 kB     00:00     
(3/6): apr-util-ldap-1.3.9-2.fc12.x86_64.rpm                         |  15 kB     00:00     
(4/6): httpd-2.2.13-2.fc12.x86_64.rpm                                | 735 kB     00:00     
(5/6): httpd-tools-2.2.13-2.fc12.x86_64.rpm                          |  63 kB     00:00     
(6/6): mailcap-2.1.30-1.fc12.noarch.rpm                              |  25 kB     00:00     
----------------------------------------------------------------------------------------
Total                                                       875 kB/s | 1.0 MB     00:01     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : apr-1.3.9-2.fc12.x86_64                                          1/6 
  Installing     : apr-util-1.3.9-2.fc12.x86_64                                     2/6 
  Installing     : apr-util-ldap-1.3.9-2.fc12.x86_64                                3/6 
  Installing     : httpd-tools-2.2.13-2.fc12.x86_64                                 4/6 
  Installing     : mailcap-2.1.30-1.fc12.noarch                                     5/6 
  Installing     : httpd-2.2.13-2.fc12.x86_64                                       6/6 

Installed:
  httpd.x86_64 0:2.2.13-2.fc12                                                          

Dependency Installed:
  apr.x86_64 0:1.3.9-2.fc12            apr-util.x86_64 0:1.3.9-2.fc12
  apr-util-ldap.x86_64 0:1.3.9-2.fc12  httpd-tools.x86_64 0:2.2.13-2.fc12
  mailcap.noarch 0:2.1.30-1.fc12  

Complete!
[root@pcmk-1 ~]#
Inoltre il cluster necessita del tool wget per assicurarsi la capacità di controllare lo stato del server Apache.
[root@pcmk-1 ~]# yum install -y wget
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.11.4-5.fc12 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================
 Package        Arch             Version                      Repository               Size
===========================================================================================
Installing:
 wget          x86_64          1.11.4-5.fc12                   rawhide                393 k

Transaction Summary
===========================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 393 k
Downloading Packages:
wget-1.11.4-5.fc12.x86_64.rpm                                            | 393 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : wget-1.11.4-5.fc12.x86_64                                            1/1 

Installed:
  wget.x86_64 0:1.11.4-5.fc12

Complete!
[root@pcmk-1 ~]#

6.2. Preparazione

First we need to create a page for Apache to serve up. On Fedora the default Apache docroot is /var/www/html, so we’ll create an index file there.
[root@pcmk-1 ~]# cat <<-END >/var/www/html/index.html
 <html>
 <body>My Test Site - pcmk-1</body>
 </html>
 END
[root@pcmk-1 ~]#
Per il momento l'architettura verrà semplificata in modo da servire unicamente un sito statico e sincronizzare manualmente i dati tra i due nodi. Quindi lo stesso comando andrà lanciato su pcmk-2.
[root@pcmk-2 ~]# cat <<-END >/var/www/html/index.html
 <html>
 <body>My Test Site - pcmk-2</body>
 </html>
 END
[root@pcmk-2 ~]#

6.3. Enable the Apache status URL

In order to monitor the health of your Apache instance, and recover it if it fails, the resource agent used by Pacemaker assumes the server-status URL is available. Look for the following in /etc/httpd/conf/httpd.conf and make sure it is not disabled or commented out:
<Location /server-status>
   SetHandler server-status
   Order deny,allow
   Deny from all
   Allow from 127.0.0.1
</Location>

6.4. Aggiornare la configurazione

At this point, Apache is ready to go, all that needs to be done is to add it to the cluster. Lets call the resource WebSite. We need to use an OCF script called apache in the heartbeat namespace [15] , the only required parameter is the path to the main Apache configuration file and we’ll tell the cluster to check once a minute that apache is still running.
[root@pcmk-1 ~]# crm configure primitive WebSite ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebSite ocf:heartbeat:apache \
 params configfile="/etc/httpd/conf/httpd.conf" \
 op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness="100"
Dopo una breve attesa il cluster dovrbbe avviare apache
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 16:12:49 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
2 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
WebSite        (ocf::heartbeat:apache):        Started pcmk-1
Wait a moment, the WebSite resource isn’t running on the same host as our IP address!

6.5. Assicurarsi che le risorse funzionino sullo stesso host

Per ridurre il carico su ogni macchina, Pacemaker generalmente tende a distribuire le risorse configurate sui nodi. E' possibile comunicare al cluster che due risorse sono relazionate e necessitano di funzionare sullo stesso host (oppure no). A questo punto il cluster verrà istruito in merito al fatto che WebSite può solamente funzionare sull'host che eroga ClusterIP. Se ClusterIP non è attiva in nessun nodo, a WebSite non verrà permesso di funzionare ovunque.
[root@pcmk-1 ~]# crm configure colocation website-with-ip INFINITY: WebSite ClusterIP
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
colocation website-with-ip inf: WebSite ClusterIP
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness="100"
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 16:14:34 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
2 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
WebSite        (ocf::heartbeat:apache):        Started pcmk-2

6.6. Controllare l'ordinamento di start e stop di una risorsa

When Apache starts, it binds to the available IP addresses. It doesn’t know about any addresses we add afterwards, so not only do they need to run on the same node, but we need to make sure ClusterIP is already active before we start WebSite. We do this by adding an ordering constraint. We need to give it a name (chose something descriptive like apache-after-ip), indicate that its mandatory (so that any recovery for ClusterIP will also trigger recovery of WebSite) and list the two resources in the order we need them to start.
[root@pcmk-1 ~]# crm configure order apache-after-ip mandatory: ClusterIP WebSite
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
colocation website-with-ip inf: WebSite ClusterIP
order apache-after-ip inf: ClusterIP WebSite
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness="100"

6.7. Specificare una Location preferita

Pacemaker does not rely on any sort of hardware symmetry between nodes, so it may well be that one machine is more powerful than the other. In such cases it makes sense to host the resources there if it is available. To do this we create a location constraint. Again we give it a descriptive name (prefer-pcmk-1), specify the resource we want to run there (WebSite), how badly we’d like it to run there (we’ll use 50 for now, but in a two-node situation almost any value above 0 will do) and the host’s name.
[root@pcmk-1 ~]# crm configure location prefer-pcmk-1 WebSite 50: pcmk-1
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation website-with-ip inf: WebSite ClusterIP
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness="100"
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 16:17:35 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
2 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
WebSite        (ocf::heartbeat:apache):        Started pcmk-2
Attenzione però, le risorse sono comunque su pcmk-2!
Anche se al momento viene preferito pcmk-1 a pcmk-2, questa preferenza è (intenzionalmente) minore dello stickiness della risorsa (quanto è stato preferito non avere un downtime superfluo).
Per osservare gli attuali punteggi di piazzamento è possibile usare un tool denominato ptest
ptest -sL

Nota

Output incluso
Esiste un modo per spostare forzatamente le risorse...

6.8. Spostamento manuale delle risorse all'interno del cluster

There are always times when an administrator needs to override the cluster and force resources to move to a specific location. Underneath we use location constraints like the one we created above, happily you don’t need to care. Just provide the name of the resource and the intended location, we’ll do the rest.
[root@pcmk-1 ~]# crm resource move WebSite pcmk-1
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 16:19:24 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
2 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1
WebSite        (ocf::heartbeat:apache):        Started pcmk-1
Notice how the colocation rule we created has ensured that ClusterIP was also moved to pcmk-1.
For the curious, we can see the effect of this command by examining the configuration
crm configure show
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
location cli-prefer-WebSite WebSite \
 rule $id="cli-prefer-rule-WebSite" inf: #uname eq pcmk-1
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation website-with-ip inf: WebSite ClusterIP
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness="100"
Viene evidenziata la constraint automatizzata utilizzata per spostare la risorsa in pcmk-1

6.8.1. Restituire il controllo nuovamente al cluster

Once we’ve finished whatever activity that required us to move the resources to pcmk-1, in our case nothing, we can then allow the cluster to resume normal operation with the unmove command. Since we previously configured a default stickiness, the resources will remain on pcmk-1.
[root@pcmk-1 ~]# crm resource unmove WebSite
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation website-with-ip inf: WebSite ClusterIP
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="2" \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness="100"
E' da notare come la constraint automatizzata non esiste più. Se viene controllato lo stato del cluster è possibile osservare che, così come aspettato, le risorse sono ancora attiva su pcmk-1.
[root@pcmk-1 ~]# crm_mon
============
Last updated: Fri Aug 28 16:20:53 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
2 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

 ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1
 WebSite        (ocf::heartbeat:apache):        Started pcmk-1


[15] Compare the key used here ocf:heartbeat:apache with the one we used earlier for the IP address: ocf:heartbeat:IPaddr2

Capitolo 7. Storage replicato con DRBD

Even if you’re serving up static websites, having to manually synchronize the contents of that website to all the machines in the cluster is not ideal. For dynamic websites, such as a wiki, its not even an option. Not everyone care afford network-attached storage but somehow the data needs to be kept in sync. Enter DRBD which can be thought of as network based RAID-1. See http://www.drbd.org/ for more details.

7.1. Installare i pacchetti DRBD

Dalla sua inclusione dalla versione 2.6.33 del kernel, quanto necessario per utilizzare DRBD è fornito da Fedora 13. Tutto ciò che va fatto è installare i pacchetti:
[root@pcmk-1 ~]# yum install -y drbd-pacemaker
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package drbd-pacemaker.x86_64 0:8.3.7-2.fc13 set to be updated
--> Processing Dependency: drbd-utils = 8.3.7-2.fc13 for package: drbd-pacemaker-8.3.7-2.fc13.x86_64
--> Running transaction check
---> Package drbd-utils.x86_64 0:8.3.7-2.fc13 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================
 Package                Arch           Version              Repository      Size
=================================================================================
Installing:
 drbd-pacemaker         x86_64         8.3.7-2.fc13         fedora          19 k
Installing for dependencies:
 drbd-utils             x86_64         8.3.7-2.fc13         fedora         165 k

Transaction Summary
=================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)

Total download size: 184 k
Installed size: 427 k
Downloading Packages:
Setting up and reading Presto delta metadata
fedora/prestodelta                                        | 1.7 kB     00:00     
Processing delta metadata
Package(s) data still to download: 184 k
(1/2): drbd-pacemaker-8.3.7-2.fc13.x86_64.rpm             |  19 kB     00:01     
(2/2): drbd-utils-8.3.7-2.fc13.x86_64.rpm                 | 165 kB     00:02     
---------------------------------------------------------------------------------
Total                                             45 kB/s | 184 kB     00:04     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : drbd-utils-8.3.7-2.fc13.x86_64                            1/2 
  Installing     : drbd-pacemaker-8.3.7-2.fc13.x86_64                        2/2 

Installed:
  drbd-pacemaker.x86_64 0:8.3.7-2.fc13                                           

Dependency Installed:
  drbd-utils.x86_64 0:8.3.7-2.fc13                                               

Complete!
[root@pcmk-1 ~]#

7.2. Configurare DRBD

Prima di configurare DRBD è necessario definire a parte lo spazio che questo dovrà utilizzare.

7.2.1. Creare una partizione per DRBD

Se si dispone di più di 1Gb liberi è bene servirsene. Negli scopi di questa guida 1Gb è fin troppo spazio per un file html e sufficiente per ospitare più avanti i metadata di GFS2.
[root@pcmk-1 ~]# lvcreate -n drbd-demo -L 1G VolGroup
  Logical volume "drbd-demo" created
[root@pcmk-1 ~]# lvs
  LV        VG       Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  drbd-demo VolGroup -wi-a- 1.00G                                      
  lv_root   VolGroup -wi-ao   7.30G                                      
  lv_swap   VolGroup -wi-ao 500.00M
La medesima operazione va ripetuta sul secondo nodo, avendo cura di utilizzare la stessa grandezza per la partizione.
[root@pcmk-2 ~]# lvs
  LV      VG       Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_root VolGroup -wi-ao   7.30G                                      
  lv_swap VolGroup -wi-ao 500.00M                                      
[root@pcmk-2 ~]# lvcreate -n drbd-demo -L 1G VolGroup
  Logical volume "drbd-demo" created
[root@pcmk-2 ~]# lvs
  LV        VG       Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  drbd-demo VolGroup -wi-a- 1.00G                                      
  lv_root   VolGroup -wi-ao   7.30G                                      
  lv_swap   VolGroup -wi-ao 500.00M

7.2.2. Scrivere la configurazione DRBD

Non esiste una serie di comandi per costruire una configurazione per DRBD, quindi è sufficiente la configurazione sottostante in /etc/drbd.conf
Informazioni dettagliate sulle direttive utilizzate in questa configurazione (e le alternative disponibili) è disponibile presso http://www.drbd.org/users-guide/ch-configure.html

Avvertimento

Accertarsi di usare i nomi e gli indirizzi dei propri nodi se questi differiscono da quelli utilizzati in questa guida.
global { 
  usage-count yes; 
}
common {
  protocol C;
}
resource wwwdata {
  meta-disk internal;
  device    /dev/drbd1;
  syncer {
    verify-alg sha1;
  }
  net { 
    allow-two-primaries; 
  }
  on pcmk-1 {
    disk      /dev/mapper/VolGroup-drbd--demo;
    address   192.168.122.101:7789; 
  }
  on 
pcmk-2 {
    disk      /dev/mapper/VolGroup-drbd--demo;
    address   192.168.122.102:7789;      
  }
}

Nota

TODO: Spiegare la ragione dell'opzione allow-two-primaries

7.2.3. Inizializzare e caricare DRBD

Sistemata la configurazione, è possibile inizializzare DRBD
[root@pcmk-1 ~]# drbdadm create-md wwwdata
md_offset 12578816
al_offset 12546048
bm_offset 12541952

Found some data 
 ==> This might destroy existing data! <==

Do you want to proceed?
[need to type 'yes' to confirm] yes

Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
Caricando il modulo DRBD del kernel e verificando che tutto sia a posto
[root@pcmk-1 ~]# modprobe drbd
[root@pcmk-1 ~]# drbdadm up wwwdata
[root@pcmk-1 ~]# cat /proc/drbd
version: 8.3.6 (api:88/proto:86-90)
GIT-hash: f3606c47cc6fcf6b3f086e425cb34af8b7a81bbf build by root@pcmk-1, 2009-12-08 11:22:57

 1: cs:WFConnection ro:Secondary/Unknown ds:Inconsistent/DUnknown C r----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:12248
[root@pcmk-1 ~]# 

Repeat on the second node
drbdadm --force create-md wwwdata 
modprobe drbd
drbdadm up wwwdata
cat /proc/drbd
[root@pcmk-2 ~]# drbdadm --force create-md wwwdata
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
[root@pcmk-2 ~]# modprobe drbd
WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.
[root@pcmk-2 ~]# drbdadm up wwwdata
[root@pcmk-2 ~]# cat /proc/drbd
version: 8.3.6 (api:88/proto:86-90)
GIT-hash: f3606c47cc6fcf6b3f086e425cb34af8b7a81bbf build by root@pcmk-1, 2009-12-08 11:22:57

 1: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:12248
Ora va indicato a DRBD quale set di dati utilizzare. Dal momento che entrambe le parti contengono dati non necessari è possibile lanciare il seguente comando su pcmk-1:
[root@pcmk-1 ~]# drbdadm -- --overwrite-data-of-peer primary wwwdata
[root@pcmk-1 ~]# cat /proc/drbd
version: 8.3.6 (api:88/proto:86-90)
GIT-hash: f3606c47cc6fcf6b3f086e425cb34af8b7a81bbf build by root@pcmk-1, 2009-12-08 11:22:57
 1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r----
    ns:2184 nr:0 dw:0 dr:2472 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:10064
        [=====>..............] sync'ed: 33.4% (10064/12248)K
        finish: 0:00:37 speed: 240 (240) K/sec
[root@pcmk-1 ~]# cat /proc/drbd
version: 8.3.6 (api:88/proto:86-90)
GIT-hash: f3606c47cc6fcf6b3f086e425cb34af8b7a81bbf build by root@pcmk-1, 2009-12-08 11:22:57
 1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----
    ns:12248 nr:0 dw:0 dr:12536 al:0 bm:1 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
pcmk-1 è quindi in stato Primary, cioè scrivibile. Questo significa che è possibile crearvi un filesystem e popolarlo con dati da servire via la risorsa WebSite.

7.2.4. Popolare DRBD con i dati

[root@pcmk-1 ~]# mkfs.ext4 /dev/drbd1
mke2fs 1.41.4 (27-Jan-2009)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
3072 inodes, 12248 blocks
612 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=12582912
2 block groups
8192 blocks per group, 8192 fragments per group
1536 inodes per group
Superblock backups stored on blocks: 
        8193

Writing inode tables: done                            
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Now mount the newly created filesystem so we can create our index file
mount /dev/drbd1 /mnt/
cat <<-END >/mnt/index.html
<html>
<body>My Test Site - drbd</body>
</html>
END
umount /dev/drbd1
[root@pcmk-1 ~]# mount /dev/drbd1 /mnt/
[root@pcmk-1 ~]# cat <<-END >/mnt/index.html
> <html>
> <body>My Test Site - drbd</body>
> </html>
> END
[root@pcmk-1 ~]# umount /dev/drbd1

7.3. Configurare il cluster per DRBD

Un comoda funzione della shell crm è quella di rendere interattivi comandi per effettuare diversi cambiamenti automatici.
First we launch the shell. The prompt will change to indicate you’re in interactive mode.
[root@pcmk-1 ~]# crm
cib crm(live)#
Next we must create a working copy or the current configuration. This is where all our changes will go. The cluster will not see any of them until we say its ok. Notice again how the prompt changes, this time to indicate that we’re no longer looking at the live cluster.
cib crm(live)# cib new drbd
INFO: drbd shadow CIB created
crm(drbd)#
Ora è possibile creare il clone DRBD e visualizzare la configurazione revisionata.
crm(drbd)# configure primitive WebData ocf:linbit:drbd params drbd_resource=wwwdata \
 op monitor interval=60s
crm(drbd)# configure ms WebDataClone WebData meta master-max=1 master-node-max=1 \
 clone-max=2 clone-node-max=1 notify=true
crm(drbd)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
 params drbd_resource="wwwdata" \
 op monitor interval="60s"
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
ms WebDataClone WebData \
 meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation website-with-ip inf: WebSite ClusterIP
order apache-after-ip inf: ClusterIP WebSite
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”
Once we’re happy with the changes, we can tell the cluster to start using them and use crm_mon to check everything is functioning.
crm(drbd)# cib commit drbd
INFO: commited 'drbd' shadow CIB to the cluster
crm(drbd)# quit
bye
[root@pcmk-1 ~]# crm_mon
============
Last updated: Tue Sep  1 09:37:13 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
3 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1
WebSite (ocf::heartbeat:apache):        Started pcmk-1
Master/Slave Set: WebDataClone
 Masters: [ pcmk-2 ]
 Slaves: [ pcmk-1 ]

Nota

Dettagli su come aggiungere una seconda risorsa DRBD
Now that DRBD is functioning we can configure a Filesystem resource to use it. In addition to the filesystem’s definition, we also need to tell the cluster where it can be located (only on the DRBD Primary) and when it is allowed to start (after the Primary was promoted).
Once again we’ll use the shell’s interactive mode
[root@pcmk-1 ~]# crm
crm(live)# cib new fs
INFO: fs shadow CIB created
crm(fs)# configure primitive WebFS ocf:heartbeat:Filesystem \
 params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype="ext4"
crm(fs)# configure colocation fs_on_drbd inf: WebFS WebDataClone:Master
crm(fs)# configure order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
Vi è inoltre la necessità di indicare al cluster che Apache necessità di funzionare sullo stessa macchina del filesystem e che questo debba essere attivato prima che Apache venga avviato.
crm(fs)# configure colocation WebSite-with-WebFS inf: WebSite WebFS
crm(fs)# configure order WebSite-after-WebFS inf: WebFS WebSite
E' tempo di revisionare la configurazione aggiornata:
[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype="ext4"
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
ms WebDataClone WebData \
        meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation WebSite-with-WebFS inf: WebSite WebFS
colocation fs_on_drbd inf: WebFS WebDataClone:Master
colocation website-with-ip inf: WebSite ClusterIP
order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
order WebSite-after-WebFS inf: WebFS WebSite
order apache-after-ip inf: ClusterIP WebSite
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”
Dopo la revisione della nuova configurazione questa va caricata e si potrà osservarla in azione all'interno del cluster.
crm(fs)# cib commit fs
INFO: commited 'fs' shadow CIB to the cluster
crm(fs)# quit
bye
[root@pcmk-1 ~]# crm_mon
============
Last updated: Tue Sep  1 10:08:44 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
4 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1
WebSite (ocf::heartbeat:apache): Started pcmk-1
Master/Slave Set: WebDataClone
        Masters: [ pcmk-1 ]
        Slaves: [ pcmk-2 ]
WebFS (ocf::heartbeat:Filesystem): Started pcmk-1

7.3.1. Testare la migrazione

We could shut down the active node again, but another way to safely simulate recovery is to put the node into what is called “standby mode”. Nodes in this state tell the cluster that they are not allowed to run resources. Any resources found active there will be moved elsewhere. This feature can be particularly useful when updating the resources’ packages.
Put the local node into standby mode and observe the cluster move all the resources to the other node. Note also that the node’s status will change to indicate that it can no longer host resources.
[root@pcmk-1 ~]# crm node standby
[root@pcmk-1 ~]# crm_mon
============
Last updated: Tue Sep  1 10:09:57 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
4 Resources configured.
============

Node pcmk-1: standby
Online: [ pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
WebSite (ocf::heartbeat:apache):        Started pcmk-2
Master/Slave Set: WebDataClone
        Masters: [ pcmk-2 ]
        Stopped: [ WebData:1 ]
WebFS   (ocf::heartbeat:Filesystem):    Started pcmk-2
Once we’ve done everything we needed to on pcmk-1 (in this case nothing, we just wanted to see the resources move), we can allow the node to be a full cluster member again.
[root@pcmk-1 ~]# crm node online
[root@pcmk-1 ~]# crm_mon
============
Last updated: Tue Sep  1 10:13:25 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
4 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
WebSite (ocf::heartbeat:apache):        Started pcmk-2
Master/Slave Set: WebDataClone
        Masters: [ pcmk-2 ]
        Slaves: [ pcmk-1 ]
WebFS   (ocf::heartbeat:Filesystem):    Started pcmk-2
Notare come ora l'impostazione di stickiness delle risorse prevenga la migrazione dei servizi nuovamente verso pcmk-1.

Capitolo 8. Conversione in Active/Active

8.1. Requisiti

Il requisito primario di un cluster Active/Active è che i dati richiesti dai servizi siano disponibili, simultaneamente, su entrambe le macchine. Pacemaker non impone requisiti su come questa funzionalità venga gestita, è possibile utilizzare una SAN (Storage Area Network) se ne si possiede una, ad ogni modo è possibile utilizzare anche DRBD, visto che supporta configurazioni multi-Primary.
L'unico inconveniente sta nel fatto di dover utilizzare un filesystem cluster-aware (e quello usato in precedenza, ext4, non è uno di questi). Sia OCFS2 che GFS2 sono supportati, la scelta cadrà su GFS2, disponibile con Fedora 13 .

8.2. Installare un cluster filesystem - GFS2

La prima cosa da fare è quella di installare il pacchetto gfs2-utils su ciascuna macchina.
[root@pcmk-1 ~]# yum install -y gfs2-utils gfs-pcmk
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gfs-pcmk.x86_64 0:3.0.5-2.fc12 set to be updated
--> Processing Dependency: libSaCkpt.so.3(OPENAIS_CKPT_B.01.01)(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64
--> Processing Dependency: dlm-pcmk for package: gfs-pcmk-3.0.5-2.fc12.x86_64
--> Processing Dependency: libccs.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64
--> Processing Dependency: libdlmcontrol.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64
--> Processing Dependency: liblogthread.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64
--> Processing Dependency: libSaCkpt.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64
---> Package gfs2-utils.x86_64 0:3.0.5-2.fc12 set to be updated
--> Running transaction check
---> Package clusterlib.x86_64 0:3.0.5-2.fc12 set to be updated
---> Package dlm-pcmk.x86_64 0:3.0.5-2.fc12 set to be updated
---> Package openaislib.x86_64 0:1.1.0-1.fc12 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================
 Package                Arch               Version                   Repository        Size
===========================================================================================
Installing:
 gfs-pcmk               x86_64             3.0.5-2.fc12              custom           101 k
 gfs2-utils             x86_64             3.0.5-2.fc12              custom           208 k
Installing for dependencies:
 clusterlib             x86_64             3.0.5-2.fc12              custom            65 k
 dlm-pcmk               x86_64             3.0.5-2.fc12              custom            93 k
 openaislib             x86_64             1.1.0-1.fc12              fedora            76 k

Transaction Summary
===========================================================================================
Install       5 Package(s)
Upgrade       0 Package(s)

Total download size: 541 k
Downloading Packages:
(1/5): clusterlib-3.0.5-2.fc12.x86_64.rpm                                |  65 kB     00:00
(2/5): dlm-pcmk-3.0.5-2.fc12.x86_64.rpm                                  |  93 kB     00:00
(3/5): gfs-pcmk-3.0.5-2.fc12.x86_64.rpm                                  | 101 kB     00:00
(4/5): gfs2-utils-3.0.5-2.fc12.x86_64.rpm                                | 208 kB     00:00
(5/5): openaislib-1.1.0-1.fc12.x86_64.rpm                                |  76 kB     00:00
-------------------------------------------------------------------------------------------
Total                                                           992 kB/s | 541 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : clusterlib-3.0.5-2.fc12.x86_64                                       1/5 
  Installing     : openaislib-1.1.0-1.fc12.x86_64                                       2/5 
  Installing     : dlm-pcmk-3.0.5-2.fc12.x86_64                                         3/5 
  Installing     : gfs-pcmk-3.0.5-2.fc12.x86_64                                         4/5 
  Installing     : gfs2-utils-3.0.5-2.fc12.x86_64                                       5/5 

Installed:
  gfs-pcmk.x86_64 0:3.0.5-2.fc12                    gfs2-utils.x86_64 0:3.0.5-2.fc12

Dependency Installed:
  clusterlib.x86_64 0:3.0.5-2.fc12   dlm-pcmk.x86_64 0:3.0.5-2.fc12 
  openaislib.x86_64 0:1.1.0-1.fc12  

Complete!
[root@pcmk-1 x86_64]#

Avvertimento

If this step fails, it is likely that your version/distribution does not ship the "Pacemaker" versions of dlm_controld and/or gfs_controld. Normally these files would be called dlm_controld.pcmk and gfs_controld.pcmk and live in the /usr/sbin directory.
If you cannot locate an installation source for these files, you will need to install a package called cman and reconfigure Corosync to use it as outlined in Appendice C, Using CMAN for Cluster Membership and Quorum.
When using CMAN, you can skip Sezione 8.3, «Configurare l'integrazione fra Pacemaker e GFS2» where dlm-clone and gfs-clone are created, and proceed directly to Sezione 8.4, «Creazione un Filesystem GFS2».

8.3. Configurare l'integrazione fra Pacemaker e GFS2

GFS2 needs two services to be running, the first is the user-space interface to the kernel’s distributed lock manager (DLM). The DLM is used to co-ordinate which node(s) can access a given file (and when) and integrates with Pacemaker to obtain node membership [16] information and fencing capabilities.
The second service is GFS2’s own control daemon which also integrates with Pacemaker to obtain node membership data.

8.3.1. Aggiunta del servizio DLM

Il demone di controllo DLM deve funzionare su tutti i nodi attivi del cluster, quindi verrà utilizzata la modalità interattiva della shell per creare una risorsa clonata.
[root@pcmk-1 ~]# crm
crm(live)# cib new stack-glue
INFO: stack-glue shadow CIB created
crm(stack-glue)# configure primitive dlm ocf:pacemaker:controld op monitor interval=120s
crm(stack-glue)# configure clone dlm-clone dlm meta interleave=true
crm(stack-glue)# configure show xml
crm(stack-glue)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype="ext4"
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
 op monitor interval="120s"
ms WebDataClone WebData \
        meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone dlm-clone dlm \
 meta interleave="true"
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation WebSite-with-WebFS inf: WebSite WebFS
colocation fs_on_drbd inf: WebFS WebDataClone:Master
colocation website-with-ip inf: WebSite ClusterIP
order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
order WebSite-after-WebFS inf: WebFS WebSite
order apache-after-ip inf: ClusterIP WebSite
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”

Nota

TODO: Spiegare il significato dell'opzione interleave
Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response
crm(stack-glue)# cib commit stack-glue
INFO: commited 'stack-glue' shadow CIB to the cluster
crm(stack-glue)# quit
bye
[root@pcmk-1 ~]# crm_mon
============
Last updated: Thu Sep  3 20:49:54 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
5 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

WebSite (ocf::heartbeat:apache):        Started pcmk-2
Master/Slave Set: WebDataClone
        Masters: [ pcmk-1 ]
        Slaves: [ pcmk-2 ]
ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
Clone Set: dlm-clone
 Started: [ pcmk-2 pcmk-1 ]
WebFS   (ocf::heartbeat:Filesystem):    Started pcmk-2

8.3.2. Aggiunta del servizio GFS2

Una volta che il DLM è attivo, è possibile aggiungere il demone di controllo GFS2.
La risorsa gfs-control viene creata utilizzando la shell crm:
[root@pcmk-1 ~]# crm
crm(live)# cib new gfs-glue --force
INFO: gfs-glue shadow CIB created
crm(gfs-glue)# configure primitive gfs-control ocf:pacemaker:controld params daemon=gfs_controld.pcmk args="-g 0" op monitor interval=120s
crm(gfs-glue)# configure clone gfs-clone gfs-control meta interleave=true
A questo punto bisogna assicurarsi che Pacemaker avvii il servizio gfs-control sui nodi che erogano una copia del servizio dlm (creato in precedenza) funzionante.
crm(gfs-glue)# configure colocation gfs-with-dlm INFINITY: gfs-clone dlm-clone
crm(gfs-glue)# configure order start-gfs-after-dlm mandatory: dlm-clone gfs-clone
Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response
crm(gfs-glue)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype="ext4"
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
primitive gfs-control ocf:pacemaker:controld \
 params daemon=”gfs_controld.pcmk” args=”-g 0” \
 op monitor interval="120s"
ms WebDataClone WebData \
        meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone dlm-clone dlm \
        meta interleave="true"
clone gfs-clone gfs-control \
 meta interleave="true"
location prefer-pcmk-1 WebSite 50: pcmk-1
colocation WebSite-with-WebFS inf: WebSite WebFS
colocation fs_on_drbd inf: WebFS WebDataClone:Master
colocation gfs-with-dlm inf: gfs-clone dlm-clone
colocation website-with-ip inf: WebSite ClusterIP
order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
order WebSite-after-WebFS inf: WebFS WebSite
order apache-after-ip inf: ClusterIP WebSite
order start-gfs-after-dlm inf: dlm-clone gfs-clone
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”
crm(gfs-glue)# cib commit gfs-glue
INFO: commited 'gfs-glue' shadow CIB to the cluster
crm(gfs-glue)# quit
bye
[root@pcmk-1 ~]# crm_mon
============
Last updated: Thu Sep  3 20:49:54 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
6 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

WebSite (ocf::heartbeat:apache):        Started pcmk-2
Master/Slave Set: WebDataClone
        Masters: [ pcmk-1 ]
        Slaves: [ pcmk-2 ]
ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
Clone Set: dlm-clone
        Started: [ pcmk-2 pcmk-1 ]
Clone Set: gfs-clone
 Started: [ pcmk-2 pcmk-1 ]
WebFS   (ocf::heartbeat:Filesystem):    Started pcmk-1

8.4. Creazione un Filesystem GFS2

8.4.1. Preparazione

Prima di fare qualsiasi operazione sulla partizione esistente bisogna accertarsi che questa sia smontata. Ciò è possibile indicando al cluster di fermare la risorsa WebFS. Questo garantirà che altre risorse (nel nostro caso, Apache) che utilizzano WebFS non sono solamente fermate, ma sono state fermate nell'ordine corretto.
[root@pcmk-1 ~]# crm_resource --resource WebFS --set-parameter target-role --meta --parameter-value Stopped
[root@pcmk-1 ~]# crm_mon
============
Last updated: Thu Sep  3 15:18:06 2009
Stack: openais
Current DC: pcmk-1 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
6 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

Master/Slave Set: WebDataClone
        Masters: [ pcmk-1 ]
        Slaves: [ pcmk-2 ]
ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1
Clone Set: dlm-clone
        Started: [ pcmk-2 pcmk-1 ]
Clone Set: gfs-clone
        Started: [ pcmk-2 pcmk-1 ]

Nota

Notare come sia Apache che WebFS sono stati fermati.

8.4.2. Creazione e popolamento della partizione GFS2

Ora che il cluster e le sue parti stanno funzionando senza problemi, è possibile creare la partizione GFS2.

Avvertimento

Questa operazione cancellerà qualsiasi contenuto sul device DRBD. Assicurarsi quindi di avere una copia di qualsiasi dato cruciale.
Nella creazione di una partizione GFS2 è necessario specificare diversi parametri aggiuntivi.
First we must use the -p option to specify that we want to use the the Kernel’s DLM. Next we use -j to indicate that it should reserve enough space for two journals (one per node accessing the filesystem).
Lastly, we use -t to specify the lock table name. The format for this field is clustername:fsname. For the fsname, we just need to pick something unique and descriptive and since we haven’t specified a clustername yet, we will use the default (pcmk).
To specify an alternate name for the cluster, locate the service section containing “name: pacemaker” in corosync.conf and insert the following line anywhere inside the block:
clustername: myname
Questa operazione andrà eseguita in ciascun nodo, accertandosi di effettuare un restart dello stesso prima di continuare.
mkfs.gfs2 -p lock_dlm -j 2 -t pcmk:web /dev/drbd1
[root@pcmk-1 ~]# mkfs.gfs2 -t pcmk:web -p lock_dlm -j 2 /dev/vdb 
This will destroy any data on /dev/vdb.
It appears to contain: data

Are you sure you want to proceed? [y/n] y

Device:                    /dev/vdb
Blocksize:                 4096
Device Size                1.00 GB (131072 blocks)
Filesystem Size:           1.00 GB (131070 blocks)
Journals:                  2
Resource Groups:           2
Locking Protocol:          "lock_dlm"
Lock Table:                "pcmk:web"
UUID:                      6B776F46-177B-BAF8-2C2B-292C0E078613

[root@pcmk-1 ~]#
Then (re)populate the new filesystem with data (web pages). For now we’ll create another variation on our home page.
[root@pcmk-1 ~]# mount /dev/drbd1 /mnt/
[root@pcmk-1 ~]# cat <<-END >/mnt/index.html
<html>
<body>My Test Site - GFS2</body>
</html>
END
[root@pcmk-1 ~]# umount /dev/drbd1
[root@pcmk-1 ~]# drbdadm verify wwwdata
[root@pcmk-1 ~]#

8.5. Riconfigurare il cluster per GFS2

[root@pcmk-1 ~]# crm
crm(live)# cib new GFS2
INFO: GFS2 shadow CIB created
crm(GFS2)# configure delete WebFS
crm(GFS2)# configure primitive WebFS ocf:heartbeat:Filesystem params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
Now that we’ve recreated the resource, we also need to recreate all the constraints that used it. This is because the shell will automatically remove any constraints that referenced WebFS.
crm(GFS2)# configure colocation WebSite-with-WebFS inf: WebSite WebFS
crm(GFS2)# configure colocation fs_on_drbd inf: WebFS WebDataClone:Master
crm(GFS2)# configure order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
crm(GFS2)# configure order WebSite-after-WebFS inf: WebFS WebSite
crm(GFS2)# configure colocation WebFS-with-gfs-control INFINITY: WebFS gfs-clone
crm(GFS2)# configure order start-WebFS-after-gfs-control mandatory: gfs-clone WebFS
crm(GFS2)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
 params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip="192.168.122.101" cidr_netmask="32" \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
primitive gfs-control ocf:pacemaker:controld \
   params daemon=”gfs_controld.pcmk” args=”-g 0” \
        op monitor interval="120s"
ms WebDataClone WebData \
        meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone dlm-clone dlm \
        meta interleave="true"
clone gfs-clone gfs-control \
        meta interleave="true"
colocation WebFS-with-gfs-control inf: WebFS gfs-clone
colocation WebSite-with-WebFS inf: WebSite WebFS
colocation fs_on_drbd inf: WebFS WebDataClone:Master
colocation gfs-with-dlm inf: gfs-clone dlm-clone
colocation website-with-ip inf: WebSite ClusterIP
order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
order WebSite-after-WebFS inf: WebFS WebSite
order apache-after-ip inf: ClusterIP WebSite
order start-WebFS-after-gfs-control inf: gfs-clone WebFS
order start-gfs-after-dlm inf: dlm-clone gfs-clone
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”
Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response
crm(GFS2)# cib commit GFS2
INFO: commited 'GFS2' shadow CIB to the cluster
crm(GFS2)# quit
bye
[root@pcmk-1 ~]# crm_mon
============
Last updated: Thu Sep  3 20:49:54 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
6 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

WebSite (ocf::heartbeat:apache):        Started pcmk-2
Master/Slave Set: WebDataClone
        Masters: [ pcmk-1 ]
        Slaves: [ pcmk-2 ]
ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
Clone Set: dlm-clone
        Started: [ pcmk-2 pcmk-1 ]
Clone Set: gfs-clone
        Started: [ pcmk-2 pcmk-1 ]
WebFS (ocf::heartbeat:Filesystem): Started pcmk-1

8.6. Riconfigurare Pacemaker per l'Active/Active

Almost everything is in place. Recent versions of DRBD are capable of operating in Primary/Primary mode and the filesystem we’re using is cluster aware. All we need to do now is reconfigure the cluster to take advantage of this.
This will involve a number of changes, so we’ll again use interactive mode.
[root@pcmk-1 ~]# crm
[root@pcmk-1 ~]# cib new active
There’s no point making the services active on both locations if we can’t reach them, so lets first clone the IP address. Cloned IPaddr2 resources use an iptables rule to ensure that each request only processed by one of the two clone instances. The additional meta options tell the cluster how many instances of the clone we want (one “request bucket” for each node) and that if all other nodes fail, then the remaining node should hold all of them. Otherwise the requests would be simply discarded.
[root@pcmk-1 ~]# configure clone WebIP ClusterIP \
 meta globally-unique=”true” clone-max=”2” clone-node-max=”2”
Ora bisogna indicare a ClusterIP come decidere quali richieste sono processate e da quali host. Per fare ciò è necessario definire il parametro clusterip_hash.
Aprire la risorsa ClusterIP
[root@pcmk-1 ~]# configure edit ClusterIP
ed aggiungere il seguente testo alla linea dei parametri
clusterip_hash="sourceip"
In modo che la definizione completa sia simile alla seguente:
primitive ClusterIP ocf:heartbeat:IPaddr2 \ 
        params ip="192.168.122.101" cidr_netmask="32" clusterip_hash="sourceip" \
        op monitor interval="30s"
Questa è la trascrizione completa
[root@pcmk-1 ~]# crm 
crm(live)# cib new active
INFO: active shadow CIB created
crm(active)# configure clone WebIP ClusterIP \
        meta globally-unique=”true” clone-max=”2” clone-node-max=”2”
crm(active)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
primitive gfs-control ocf:pacemaker:controld \
   params daemon=”gfs_controld.pcmk” args=”-g 0” \
        op monitor interval="120s"
ms WebDataClone WebData \
        meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone WebIP ClusterIP \
 meta globally-unique=”true” clone-max=”2” clone-node-max=”2”
clone dlm-clone dlm \
        meta interleave="true"
clone gfs-clone gfs-control \
        meta interleave="true"
colocation WebFS-with-gfs-control inf: WebFS gfs-clone
colocation WebSite-with-WebFS inf: WebSite WebFS
colocation fs_on_drbd inf: WebFS WebDataClone:Master
colocation gfs-with-dlm inf: gfs-clone dlm-clone
colocation website-with-ip inf: WebSite WebIP
order WebFS-after-WebData inf: WebDataClone:promote WebFS:start
order WebSite-after-WebFS inf: WebFS WebSite
order apache-after-ip inf: WebIP WebSite
order start-WebFS-after-gfs-control inf: gfs-clone WebFS
order start-gfs-after-dlm inf: dlm-clone gfs-clone
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”
Notare come qualsiasi constraint riferita a ClusterIP sia stata aggiornata per utilizzare invece WebIP. Questo è un vantaggio aggiuntivo nell'utilizzo della shell crm.
A questo punto è necessario convertire le risorse filesystem ed Apache in cloni. Di nuovo, la shell aggiornerà automaticamente ogni constraint interessata.
crm(active)# configure clone WebFSClone WebFS
crm(active)# configure clone WebSiteClone WebSite
L'ultimo passo è quello di comunicare al cluster che ora è consentito promuovere entrambe le istanze a PRimary (o Master).
crm(active)# configure edit WebDataClone
Cambiare master-max a 2
crm(active)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
primitive gfs-control ocf:pacemaker:controld \
   params daemon=”gfs_controld.pcmk” args=”-g 0” \
        op monitor interval="120s"
ms WebDataClone WebData \
        meta master-max="2" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone WebFSClone WebFS
clone WebIP ClusterIP  \
        meta globally-unique=”true” clone-max=”2” clone-node-max=”2”
clone WebSiteClone WebSite
clone dlm-clone dlm \
        meta interleave="true"
clone gfs-clone gfs-control \
        meta interleave="true"
colocation WebFS-with-gfs-control inf: WebFSClone gfs-clone
colocation WebSite-with-WebFS inf: WebSiteClone WebFSClone
colocation fs_on_drbd inf: WebFSClone WebDataClone:Master
colocation gfs-with-dlm inf: gfs-clone dlm-clone
colocation website-with-ip inf: WebSiteClone WebIP
order WebFS-after-WebData inf: WebDataClone:promote WebFSClone:start
order WebSite-after-WebFS inf: WebFSClone WebSiteClone
order apache-after-ip inf: WebIP WebSiteClone
order start-WebFS-after-gfs-control inf: gfs-clone WebFSClone
order start-gfs-after-dlm inf: dlm-clone gfs-clone
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="false" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”
Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response
crm(active)# cib commit active
INFO: commited 'active' shadow CIB to the cluster
crm(active)# quit
bye
[root@pcmk-1 ~]# crm_mon
============
Last updated: Thu Sep  3 21:37:27 2009
Stack: openais
Current DC: pcmk-2 - partition with quorum
Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f
2 Nodes configured, 2 expected votes
6 Resources configured.
============

Online: [ pcmk-1 pcmk-2 ]

Master/Slave Set: WebDataClone
        Masters: [ pcmk-1 pcmk-2 ]
Clone Set: dlm-clone
        Started: [ pcmk-2 pcmk-1 ]
Clone Set: gfs-clone
        Started: [ pcmk-2 pcmk-1 ]
Clone Set: WebIP
 Started: [ pcmk-1 pcmk-2 ]
Clone Set: WebFSClone
 Started: [ pcmk-1 pcmk-2 ]
Clone Set: WebSiteClone
 Started: [ pcmk-1 pcmk-2 ]

8.6.1. Testare il recovery

Nota

TODO: mettere un nodo in standby per dimostrare il failover


[16] The list of nodes the cluster considers to be available

Capitolo 9. Configurare STONITH

9.1. Perché STONITH è necessario

STONITH è l'acronimo di Shoot-The-Other-Node-In-The-Head e protegge i dati dalla corruzione derivante da accessi concorrenti incontrollati.
Just because a node is unresponsive, this doesn’t mean it isn’t accessing your data. The only way to be 100% sure that your data is safe, is to use STONITH so we can be certain that the node is truly offline, before allowing the data to be accessed from another node.
STONITH gioca un ruolo importante anche nel caso in cui un servizio clusterizzato non può essere stoppato. In questo caso il cluster utilizza STONITH per forzare l'intero nodo offline, rendendo di fatto sicuro l'avvio del servizio altrove.

9.2. Quale device STONITH andrebbe utilizzato

E' cruciale che il device STONITH sia in grado di differenziare un guasto del nodo da un guasto di rete.
L'errore più grande commesso nello scegliere un device STONITH è di utilizzare un "remote power switch" (come molti IMPI onboard controller) che condivide l'alimentazione con il nodo che controlla. In questi casi, il cluster non può essere sicuro che il nodo sia realmente offline o attivo ma staccato dalla rete.
Likewise, any device that relies on the machine being active (such as SSH-based “devices” used during testing) are inappropriate.

9.3. Configurare STONITH

  1. Individuare il driver corretto: stonith -L
  2. Dal momento che ogni device è diverso dagli altri, i parametri necessari a configurarlo saranno vari. Per individuare i parametri richiesti dal device: stonith -t {type} -n
Fortunatamente gli sviluppatori hanno scelto nomi che hanno senso, altrimenti è possibile ricavare informazioni aggiuntive recandosi su un nodo attivo del cluster e lanciando:
lrmadmin -M stonith {type} pacemaker
L'output dovrebbe essere testo formattato in XML contenente parametri descrittori aggiuntivi
  1. Creare un file chiamato stonith.xml contenente una risorsa primitiva di classe stonith, un tipo {type} ed un parametro per ciascuno dei valori ricavati nello step 2
  2. Creare un clone dalla risorsa primitiva se il device può sparare a più di un singolo nodo e supporta connessioni simultanee multiple.
  3. Caricare il file nel CIB utilizzando cibadmin: cibadmin -C -o resources --xml-file stonith.xml

9.3.1. Esempio

Assumendo di possedere un IBM BladeCenter contenente i due nodi e che l'interfaccia di gestione sia attiva su 192.168.122.31, verrà quindi scelto il driver external/ibmrsa, ottenendo la seguente lista di parametri
stonith -t external/ibmrsa -n
[root@pcmk-1 ~]# stonith -t external/ibmrsa -n
hostname  ipaddr  userid  passwd  type
Assumendo di conoscere lo username e la password per l'interfaccia di gestione, verrà creata una risorsa STONITH con la shell
[root@pcmk-1 ~]# crm 
crm(live)# cib new stonith
INFO: stonith shadow CIB created
crm(stonith)# configure primitive rsa-fencing stonith::external/ibmrsa \
 params hostname=”pcmk-1 pcmk-2" ipaddr=192.168.122.31 userid=mgmt passwd=abc123 type=ibm \
 op monitor interval="60s"
crm(stonith)# configure clone Fencing rsa-fencing
Ed infine, visto che era stato disabilitato in precedenza, è necessario riabilitare STONITH
crm(stonith)# configure property stonith-enabled="true"
crm(stonith)# configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
primitive gfs-control ocf:pacemaker:controld \
   params daemon=”gfs_controld.pcmk” args=”-g 0” \
        op monitor interval="120s"
primitive rsa-fencing stonith::external/ibmrsa \
 params hostname=”pcmk-1 pcmk-2" ipaddr=192.168.122.31 userid=mgmt passwd=abc123 type=ibm \
 op monitor interval="60s"
ms WebDataClone WebData \
        meta master-max="2" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone Fencing rsa-fencing 
clone WebFSClone WebFS
clone WebIP ClusterIP  \
        meta globally-unique=”true” clone-max=”2” clone-node-max=”2”
clone WebSiteClone WebSite
clone dlm-clone dlm \
        meta interleave="true"
clone gfs-clone gfs-control \
        meta interleave="true"
colocation WebFS-with-gfs-control inf: WebFSClone gfs-clone
colocation WebSite-with-WebFS inf: WebSiteClone WebFSClone
colocation fs_on_drbd inf: WebFSClone WebDataClone:Master
colocation gfs-with-dlm inf: gfs-clone dlm-clone
colocation website-with-ip inf: WebSiteClone WebIP
order WebFS-after-WebData inf: WebDataClone:promote WebFSClone:start
order WebSite-after-WebFS inf: WebFSClone WebSiteClone
order apache-after-ip inf: WebIP WebSiteClone
order start-WebFS-after-gfs-control inf: gfs-clone WebFSClone
order start-gfs-after-dlm inf: dlm-clone gfs-clone
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled="true" \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”

Riepilogo delle configurazioni

A.1. Configurazione finale del cluster

[root@pcmk-1 ~]# crm configure show
node pcmk-1
node pcmk-2
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \
        op monitor interval="30s"
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
primitive gfs-control ocf:pacemaker:controld \
   params daemon=”gfs_controld.pcmk” args=”-g 0” \
        op monitor interval="120s"
primitive rsa-fencing stonith::external/ibmrsa \
        params hostname=”pcmk-1 pcmk-2" ipaddr=192.168.122.31 userid=mgmt passwd=abc123 type=ibm \
        op monitor interval="60s"
ms WebDataClone WebData \
        meta master-max="2" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
clone Fencing rsa-fencing 
clone WebFSClone WebFS
clone WebIP ClusterIP  \
        meta globally-unique=”true” clone-max=”2” clone-node-max=”2”
clone WebSiteClone WebSite
clone dlm-clone dlm \
        meta interleave="true"
clone gfs-clone gfs-control \
        meta interleave="true"
colocation WebFS-with-gfs-control inf: WebFSClone gfs-clone
colocation WebSite-with-WebFS inf: WebSiteClone WebFSClone
colocation fs_on_drbd inf: WebFSClone WebDataClone:Master
colocation gfs-with-dlm inf: gfs-clone dlm-clone
colocation website-with-ip inf: WebSiteClone WebIP
order WebFS-after-WebData inf: WebDataClone:promote WebFSClone:start
order WebSite-after-WebFS inf: WebFSClone WebSiteClone
order apache-after-ip inf: WebIP WebSiteClone
order start-WebFS-after-gfs-control inf: gfs-clone WebFSClone
order start-gfs-after-dlm inf: dlm-clone gfs-clone
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled=”true” \
        no-quorum-policy="ignore"
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”

A.2. Lista nodi

La lista dei nodi è popolata automaticamente dal cluster.
node pcmk-1
node pcmk-2

A.3. Opzioni del cluster

Qui è dove il cluster registra automaticamente alcune informazioni in merito al cluster
  1. dc-version - la versione (incluso l'hash del codice sorgente originale) di Pacemaker usata nel DC
  2. cluster-infrastructure - l'infrastruttura cluster utilizzata (heartbeat or openais)
  3. expected-quorum-votes - il numero massimo di nodi che ci si aspetta facciano parte del cluster
e dove l'amministratore può assegnare valori alle opzioni che controllano il modo in cui il cluster opera
  1. stonith-enabled=true - Fai uso di STONITH
  2. no-quorum-policy=ignore - Ignora la perdita di quorum e continua ad ospitare le risorse.
property $id="cib-bootstrap-options" \
        dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \
        cluster-infrastructure="openais" \
        expected-quorum-votes=”2” \
        stonith-enabled=”true” \
        no-quorum-policy="ignore"

A.4. Risorse

A.4.1. Opzioni di default

Qui vengono configurate le opzioni del cluster che vanno applicati a tutte le risorse
  1. resource-stickiness - Specifica l'impossibilità o meno di muovere risorse ad altre macchine
rsc_defaults $id="rsc-options" \
        resource-stickiness=”100”

A.4.2. Fencing

Nota

TODO: Aggiungi il testo qui
primitive rsa-fencing stonith::external/ibmrsa \
        params hostname=”pcmk-1 pcmk-2" ipaddr=192.168.122.31 userid=mgmt passwd=abc123 type=ibm \
        op monitor interval="60s"
clone Fencing rsa-fencing

A.4.3. Servizio Address

Users of the services provided by the cluster require an unchanging address with which to access it. Additionally, we cloned the address so it will be active on both nodes. An iptables rule (created as part of the resource agent) is used to ensure that each request only processed by one of the two clone instances. The additional meta options tell the cluster that we want two instances of the clone (one “request bucket” for each node) and that if one node fails, then the remaining node should hold both.
primitive ClusterIP ocf:heartbeat:IPaddr2 \
        params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \
        op monitor interval="30s"
clone WebIP ClusterIP  
        meta globally-unique=”true” clone-max=”2” clone-node-max=”2”

Nota

TODO: Il RA quando clonato dovrebbe controllare l'opzione globally-unique=true

A.4.4. Distributed lock manager

I filesystem cluster come GFS2 richiedono un lock manager. Questo servizio avvia il demone che fornisce applicazioni user-spacc (come il demone GFS2) con accesso al lock manager interno al kernel. Dato che si necessita di averlo attivo su tutti nodi del cluste, questo viene clonato.
primitive dlm ocf:pacemaker:controld \
        op monitor interval="120s"
clone dlm-clone dlm \
        meta interleave="true

Nota

TODO: La conferma del parametro interleave non è più necessaria

A.4.5. Demone di controllo di GFS

GFS2 inoltre necessita di un ponte user-space/kernel eseguito su ogni nodo. Così qui è presente un altro clone, sebbene questa volta va scpecificato che può girare su macchine che tanno eseguendo anche il DLM (colocation constraint) e che questo può solamente essere avviato dopo che il DLM viene a sua volta avviato (order constraint). Inoltre, il clone gfs-control deve preoccuparsi unicamente dell'istanza DLM a cui è associato, così non è necessario valorizzare l'opzione interleave.
primitive gfs-control ocf:pacemaker:controld \
   params daemon=”gfs_controld.pcmk” args=”-g 0” \
        op monitor interval="120s"
clone gfs-clone gfs-control \
        meta interleave="true"
colocation gfs-with-dlm inf: gfs-clone dlm-clone
order start-gfs-after-dlm inf: dlm-clone gfs-clone

A.4.6. DRBD - Storage condiviso

Here we define the DRBD service and specify which DRBD resource (from drbd.conf) it should manage. We make it a master/slave resource and, in order to have an active/active setup, allow both instances to be promoted by specifying master-max=2. We also set the notify option so that the cluster will tell DRBD agent when it’s peer changes state.
primitive WebData ocf:linbit:drbd \
        params drbd_resource="wwwdata" \
        op monitor interval="60s"
ms WebDataClone WebData \
        meta master-max="2" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"

A.4.7. Cluster Filesystem

Il Cluster Filesystem si assicura che i file vengano letti e scritti nella maniera corretta. E' necessario specificare il block device (fornito da DRBD), dove si vuole effettuare l'operazione di mount e che viene utilizzato GFS2. Di nuovo questo è un clone, perché è inteso essere attivo su entrambi i nodi. La constraint aggiuntiva assicura che la risorsa possa essere avviata su nodi con gfs-control attivo e istanze drbd.
primitive WebFS ocf:heartbeat:Filesystem \
        params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2”
clone WebFSClone WebFS
colocation WebFS-with-gfs-control inf: WebFSClone gfs-clone
colocation fs_on_drbd inf: WebFSClone WebDataClone:Master
order WebFS-after-WebData inf: WebDataClone:promote WebFSClone:start
order start-WebFS-after-gfs-control inf: gfs-clone WebFSClone

A.4.8. Apache

Lastly we have the actual service, Apache. We need only tell the cluster where to find it’s main configuration file and restrict it to running on nodes that have the required filesystem mounted and the IP address active.
primitive WebSite ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op monitor interval="1min"
clone WebSiteClone WebSite
colocation WebSite-with-WebFS inf: WebSiteClone WebFSClone
colocation website-with-ip inf: WebSiteClone WebIP
order apache-after-ip inf: WebIP WebSiteClone
order WebSite-after-WebFS inf: WebFSClone WebSiteClone

Sample Corosync Configuration

	
# Please read the Corosync.conf.5 manual page
compatibility: whitetank

totem {
        version: 2

        # How long before declaring a token lost (ms)
        token:          5000

        # How many token retransmits before forming a new configuration
        token_retransmits_before_loss_const: 10

        # How long to wait for join messages in the membership protocol (ms)
        join:           1000

        # How long to wait for consensus to be achieved before starting a new
        # round of membership configuration (ms)
        consensus:      6000

        # Turn off the virtual synchrony filter
        vsftype:        none

        # Number of messages that may be sent by one processor on receipt of the token
        max_messages:   20

        # Stagger sending the node join messages by 1..send_join ms
        send_join: 45

        # Limit generated nodeids to 31-bits (positive signed integers)
        clear_node_high_bit: yes

        # Disable encryption
        secauth:        off

        # How many threads to use for encryption/decryption
        threads:           0

        # Optionally assign a fixed node id (integer)
        # nodeid:         1234

        interface {
                ringnumber: 0

                # The following values need to be set based on your environment
                bindnetaddr: 192.168.122.0
                mcastaddr: 226.94.1.1
                mcastport: 4000
        }
}

logging {
        debug: off
        fileline: off
        to_syslog: yes
        to_stderr: off
        syslog_facility: daemon
        timestamp: on
}

amf {
        mode: disabled
}
Esempio B.1. Sample Corosync.conf for a two-node cluster

Using CMAN for Cluster Membership and Quorum

C.1. Background

CMAN v3 is a Corsync plugin that monitors the names and number of active cluster nodes in order to deliver membership and quorum information to clients (such as the Pacemaker daemons).
In a traditional Corosync-Pacemaker cluster, a Pacemaker plugin is loaded to provide membership and quorum information. The motivation for wanting to use CMAN for this instead, is to ensure all elements of the cluster stack are making decisions based on the same membership and quorum data. [17]
CMAN has been around longer than Pacemaker and is part of the Red Hat cluster stack, so it is available and supported by many distributions and other pieces of software (such as OCFS2 and GFS2). For this reason it makes sense to support it.

C.2. Adding CMAN Support

Avvertimento

Be sure to disable the Pacemaker plugin before continuing with this section. In most cases, this can be achieved by removing /etc/corosync/service.d/pcmk and stopping Corosync.

C.2.1. Adding CMAN Support - cluster.conf

The preferred approach for enabling CMAN is to configure cluster.conf and use the /etc/init.d/cman script to start Corosync. Its far easier to maintain and start automatically starts the necessary pieces for using GFS2.
You can find some documentation on Installing CMAN and Creating a Basic Cluster Configuration File at the Red Hat website. However please ignore the parts about Fencing, Failover Domains, or HA Services and anything to do with rgmanager and fenced. All these continue to be handled by Pacemaker in the normal manner.
	
<?xml version="1.0"?>
<cluster config_version="1" name="beekhof">
  <fence_daemon clean_start="0" post_fail_delay="0" post_join_delay="3"/>
  <clusternodes>
    <clusternode name="pcmk-1" nodeid="1">
      <fence/>
    </clusternode>
    <clusternode name="pcmk-2" nodeid="2">
      <fence/>
    </clusternode>
  </clusternodes>
  <cman/>
  <fencedevices/>
  <rm/>
</cluster>
Esempio C.1. Sample cluster.conf for a two-node cluster

C.2.2. Adding CMAN Support - corosync.conf

The alternative is to add the necessary cman configuration elements to corosync.conf. We recommend you place these directives in /etc/corosync/service.d/cman as they will differ between machines.
If you choose this approach, you would continue to start and stop Corosync with it's init script as previously described in this document.
[root@pcmk-1 ~]# cat <<-END >>/etc/corosync/service.d/cman
cluster {
    name: beekhof

    clusternodes {
            clusternode {
                    votes: 1
                    nodeid: 1
                    name: pcmk-1
            }
            clusternode {
                    votes: 1
                    nodeid: 2
                    name: pcmk-2
            }
    }
    cman {
            expected_votes: 2
            cluster_id: 123
            nodename: `uname -n`
            two_node: 1
            max_queued: 10
    }
}

service {
    name: corosync_cman
    ver: 0
}

quorum {
    provider: quorum_cman
}
END
Esempio C.2. Sample corosync.conf extensions for a two-node cluster

Avvertimento

Verify that nodename was set appropriately on each host.


[17] A failure to do this can lead to what is called internal split-brain - a situation where different parts of the stack disagree about whether some nodes are alive or dead - which quickly leads to unnecssary down-time and/or data corruption.

Approfondimenti

Sito del progetto
Comandi cluster
Una guida generale è stata redatta da Novell e si trova qui:
Corosync

Revision History

Diario delle Revisioni
Revisione 1Mon May 17 2010Andrew Beekhof
Import from Pages.app

Indice analitico

F

feedback
contact information for this manual, Inviateci i vostri commenti!