Archives pour la catégorie ‘HA’

Pacemaker : configuration d’une ressource de type clone

Une ressource de type clone permet l’exécution simultanée d’une même ressource sur un ou plusieurs nodes composant le cluster.

Dans le cas présenté ici, il m’est nécesaire de lancer autofs sur les deux nodes composant le cluster, avec une instance par node. Les paramètres de configuration de la ressource clone sont donc clone max = 2 et clone node max = 1. De plus, il faut impérativement désactiver la colocation sur celle-ci.

heartbeat-clone_resource

Pacemaker : supprimer un node en doublon

root@node0 ~ # crm configure show
node $id="87979dd9-bb33-42ad-acb5-31d6023e0079" node0
node $id="8a34568b-d09f-457c-8cf0-22675d243342" node1
node $id="fabb197c-87f9-46d9-bb9e-27517a9717a4" node1
root@node0 ~ # cibadmin --query --local
    <nodes>
      <node id="87979dd9-bb33-42ad-acb5-31d6023e0079" uname="node0" type="normal"/>
      <node id="fabb197c-87f9-46d9-bb9e-27517a9717a4" uname="node1" type="normal"/>
      <node id="8a34568b-d09f-457c-8cf0-22675d243342" uname="node1" type="normal"/>
    </nodes>
root@node0 ~ # crm_node -i
87979dd9-bb33-42ad-acb5-31d6023e0079
root@node1 ~ # crm_node -i
8a34568b-d09f-457c-8cf0-22675d243342
root@node0 ~ # /etc/init.d/pacemaker stop
root@node1 ~ # /etc/init.d/pacemaker stop
root@node0 ~ # crm_node --force -R fabb197c-87f9-46d9-bb9e-27517a9717a4
root@node0 ~ # cibadmin --delete --obj_type nodes --crm_xml '<node id="fabb197c-87f9-46d9-bb9e-27517a9717a4" uname="node1" type="normal"/>'
root@node0 ~ # /etc/init.d/pacemaker start
root@node1 ~ # /etc/init.d/pacemaker start

Corosync : wrapper pour exécution conditionnelle en crontab

Ce script est utile pour lancer un script en crontab uniquement sur un node déclaré actif par Corosync / Heartbeat. Bref, une exécution conditionnelle «safe».

root@cluster-www1:~# nano /usr/local/bin/cronrun.pl
#!/usr/bin/perl
#
# This script is a wrapper for executing a cron only if a node is active.
#
# Boris HUISGEN <boris.huisgen@################>
#

use Sys::Hostname;

my $resource="res_Filesystem_1";        # resource name to check if active

#
# script
#

my $hostname = hostname();

if ($#ARGV+1 < 2) {
   print "Usage: cronrun.pl <CMD> [<ARG1> ...]\n";
   exit;
}

my $check = `crm_mon -1 | grep -q -e '$resource.*$hostname'`;
if ($? == 0) {
   my @cmd = @ARGV;

   open(CMD, "@cmd |") || die "Error: failed to execute command.";
   while (<CMD>) {
      print $_;
   }
}

Reste donc à modifier la crontab pour exécuter les scripts au travers de ce wrapper, comme par exemple :

0 3 * * * /usr/local/bin/cronrun.pl /bin/bash script.sh -arg1 -arg2

FreeBSD : stockage ZFS haute disponibilité avec HAST

Objectif : rendre hautement disponible un pool ZFS en le répliquant sur un second serveur grâce à HAST.

Configuration de node1

node1# cat /etc/rc.conf
hostname="node1"
keymap="fr.iso.acc"
zfs_enable="YES"

network_interfaces="lo0 em0 em1"
defaultrouter="192.168.0.254"
ifconfig_em0="inet 192.168.0.101 netmask 255.255.255.0 polling"
ifconfig_em1="inet 192.168.1.101 netmask 255.255.255.0 polling"

sshd_enable="YES"
hastd_enable="YES"
node1# cat /etc/hast.conf
resource disk1 {
	on node1 {
		local /dev/ada2
		remote 192.168.1.102
	}

	on node2 {
		local /dev/ada2
		remote 192.168.1.101
	}
}

resource disk2 {
	on node1 {
		local /dev/ada3
		remote 192.168.1.102
	}

	on node2 {
		local /dev/ada3
		remote 192.168.1.101
	}
}

Configuration de node2

node1# cat /etc/rc.conf
hostname="node2"
keymap="fr.iso.acc"
zfs_enable="YES"

network_interfaces="lo0 em0 em1"
defaultrouter="192.168.0.254"
ifconfig_em0="inet 192.168.0.102 netmask 255.255.255.0 polling"
ifconfig_em1="inet 192.168.1.102 netmask 255.255.255.0 polling"

sshd_enable="YES"
hastd_enable="YES"
node2# scp node1:/etc/hast.conf /etc/

Lancement de HAST

node1# hastctl init disk1
node1# hastctl init disk2
node1# hastctl create disk1
node1# hastctl create disk2
node1# hastctl role primary disk1
node1# hastctl role primary disk2
node2# hastctl init disk1
node2# hastctl init disk2
node2# hastctl create disk1
node2# hastctl create disk2
node2# hastctl role secondary disk1
node2# hastctl role secondary disk2
node1# hastctl status
disk1:
 role: primary
 provname: disk1
 localpath: /dev/ada2
 extentsize: 2097152 (2.0MB)
 keepdirty: 64
 remoteaddr: 192.168.1.102
 replication: fullsync
 status: degraded
 dirty: 0 (0B)
 statistics:
 reads: 19
 writes: 0
 deletes: 0
 flushes: 0
 activemap updates: 0
disk2:
 role: primary
 provname: disk2
 localpath: /dev/ada3
 extentsize: 2097152 (2.0MB)
 keepdirty: 64
 remoteaddr: 192.168.1.102
 replication: fullsync
 status: degraded
 dirty: 0 (0B)
 statistics:
 reads: 19
 writes: 0
 deletes: 0
 flushes: 0
 activemap updates: 0
node1# ls -l /dev/hast/
total 0
crw-r-----  1 root  operator    0, 106 Nov  1 17:20 disk1
crw-r-----  1 root  operator    0, 108 Nov  1 17:20 disk2
node1# zpool create data mirror /dev/hast/disk1 /dev/hast/disk2
node1# zpool status data
node1# zpool status data
  pool: data
 state: ONLINE
 scan: none requested
config:

	NAME            STATE     READ WRITE CKSUM
	data            ONLINE       0     0     0
	  mirror-0      ONLINE       0     0     0
	    hast/disk1  ONLINE       0     0     0
	    hast/disk2  ONLINE       0     0     0

errors: No known data errors

Bascule sur node2

node1# zpool export data
node1# hastctl role secondary disk1
node1# hastctl role secondary disk2
node2# hastctl role primary disk1
node2# hastctl role primary disk2
node2# zpool import data

FreeBSD : IPv6 avec CARP et VLAN

node1# more /etc/rc.conf
[...]
ipv6_enable="YES"
ipv6_gateway_enable="YES"
ipv6_network_interfaces="lo0 igb0 em0 vlan1 vlan101 vlan102 carp0 carp1 carp2"
ipv6_defaultrouter="::1"

ipv6_ifconfig_igb0="fdcb:9921:3552:afd6::2 prefixlen 64"
ipv6_ifconfig_em0="fdcb:9921:3552:afff::2 prefixlen 64"
ipv6_ifconfig_vlan1="fdcb:9921:3552:afd7::2 prefixlen 64"
ipv6_ifconfig_vlan101="fdcb:9921:3552:afd8::2 prefixlen 64"
ipv6_ifconfig_vlan102="fdcb:9921:3552:afd9::2 prefixlen 64"
ipv6_ifconfig_carp0="fdcb:9921:3552:afd6::1 prefixlen 64"
ipv6_ifconfig_carp1="fdcb:9921:3552:afd8::1 prefixlen 64"
ipv6_ifconfig_carp2="fdcb:9921:3552:afd9::1 prefixlen 64"
[...]
pf_enable="YES"
pf_flags=""
pf_rules="/etc/fw.conf"
pfsync_enable="YES"
pfsync_syncdev="em0"
[...]

Pour la configuration IPv4, c’est par ici.

FreeBSD : redondance réseau CARP et VLAN

Serveur primaire

node1# more /etc/rc.conf
gateway_enable="YES"

network_interfaces="lo0 igb0 igb1 em0"
ifconfig_igb0="up"
ifconfig_igb1="inet 172.16.2.251 netmask 255.255.255.0"
ifconfig_em0="192.168.254.251 netmask 255.255.255.0"
defaultrouter="172.16.2.254"

cloned_interfaces="vlan1 vlan101 vlan102 carp0 carp1 carp2 carp3"
ifconfig_vlan1="inet 192.168.0.251 netmask 255.255.255.0 vlan 1 vlandev igb0"
ifconfig_vlan101="inet 192.168.1.251 netmask 255.255.255.0 vlan 101 vlandev igb0"
ifconfig_vlan102="inet 192.168.2.251 netmask 255.255.255.0 vlan 102 vlandev igb0"
ifconfig_carp0="vhid 1 pass my$ecret 192.168.0.254 netmask 255.255.255.0 advbase 1 advskew 0"
ifconfig_carp1="vhid 2 pass my$ecret 192.168.1.254 netmask 255.255.255.0 advbase 1 advskew 0"
ifconfig_carp2="vhid 3 pass my$ecret 192.168.2.254 netmask 255.255.255.0 advbase 1 advskew 0"
ifconfig_carp3="vhid 4 pass my$ecret 172.16.2.253 netmask 255.255.255.0 advbase 1 advskew 0"

pf_enable="YES"
pf_flags=""
pf_rules="/etc/fw.conf"
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pfsync_enable="YES"
pfsync_syncdev="em0"
pfsync_syncpeer="192.168.254.252"
node1# echo net.inet.carp.preempt=1 > /etc/sysctl.conf
node1# sysctl net.inet.carp.preempt=1
node1# ee pf.conf
pass quick on em0 inet proto pfsync from any to any
pass quick on { vlan1 vlan101 vlan102 igb1 } inet proto carp from any to any

Serveur secondaire

node2# more /etc/rc.conf
gateway_enable="YES"

network_interfaces="lo0 igb0 igb1 em0"
ifconfig_igb0="up"
ifconfig_igb1="inet 172.16.2.252 netmask 255.255.255.0"
ifconfig_em0="192.168.254.252 netmask 255.255.255.0"
defaultrouter="172.16.2.254"

cloned_interfaces="vlan1 vlan101 vlan102 carp0 carp1 carp2 carp3"
ifconfig_vlan1="inet 192.168.0.252 netmask 255.255.255.0 vlan 1 vlandev igb0"
ifconfig_vlan101="inet 192.168.1.252 netmask 255.255.255.0 vlan 101 vlandev igb0"
ifconfig_vlan102="inet 192.168.2.252 netmask 255.255.255.0 vlan 102 vlandev igb0"
ifconfig_carp0="vhid 1 pass my$ecret 192.168.0.254 netmask 255.255.255.0 advbase 1 advskew 100"
ifconfig_carp1="vhid 2 pass my$ecret 192.168.1.254 netmask 255.255.255.0 advbase 1 advskew 100"
ifconfig_carp2="vhid 3 pass my$ecret 192.168.2.254 netmask 255.255.255.0 advbase 1 advskew 100"
ifconfig_carp3="vhid 4 pass my$ecret 172.16.2.253 netmask 255.255.255.0 advbase 1 advskew 100"

pf_enable="YES"
pf_flags=""
pf_rules="/etc/fw.conf"
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pfsync_enable="YES"
pfsync_syncdev="em0"
pfsync_syncpeer="192.168.254.251"
node2# echo net.inet.carp.preempt=1 > /etc/sysctl.conf
node2# sysctl net.inet.carp.preempt=1
node2# ee pf.conf
pass quick on em0 inet proto pfsync from any to any
pass quick on { vlan1 vlan101 vlan102 igb1 } inet proto carp from any to any
Haut de page