Projet

Général

Profil

Demande #5638

Demande #5605: Décommissionnement de virola et calamus

Reconstruction de virola2

Ajouté par Quentin Gibeaux il y a plus de 2 ans. Mis à jour il y a plus de 2 ans.

Statut:
Fermé
Priorité:
Normale
Assigné à:
Catégorie:
-
Version cible:
Début:
29/10/2021
Echéance:
% réalisé:

0%

Temps estimé:
Difficulté:
2 Facile

Description

Restauration du backup de virola sur virola2
- création du FS
- restauration du backup
- synchro drbd en slave


Demandes liées

Copié vers Admins - Demande #5639: Reconstruction de calamus2Fermé29/10/2021

Actions

Historique

#1

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

  • Tâche parente mis à #5605
#2

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

#3

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

  • Version cible changé de Backlog à Novembre 2021
#4

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Export des tables de partition depuis virola :

sfdisk -d /dev/sda > virola_sda.part
sfdisk -d /dev/sdb > virola_sdb.part
scp virola_sd*.part root@23.88.68.224:

Import des tables de partition depuis virola2 :

sfdisk /dev/sda < virola_sda.part 
sfdisk /dev/sdb < virola_sdb.part 

#5

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Configuration du raid sur virola :

(April) root@virola:~# mdadm -v --detail --scan /dev/md0
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=0.90 UUID=3ed83f38:2f77c02f:848f0d91:5dd9f907
   devices=/dev/sda1,/dev/sdb1

Création du raid sur virola2 :

root@rescue ~ # mdadm --examine /dev/sda /dev/sdb
/dev/sda:
   MBR Magic : aa55
Partition[0] :   3907019969 sectors at         4096 (type fd)
/dev/sdb:
   MBR Magic : aa55
Partition[0] :   3907019969 sectors at         4096 (type fd)
root@rescue ~ # mdadm --examine /dev/sda1 /dev/sdb1
mdadm: No md superblock detected on /dev/sda1.
mdadm: No md superblock detected on /dev/sdb1.
root@rescue ~ # mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
#6

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

conf lvm sur virola :

(April) root@virola:~# pvdisplay 
  /dev/drbd1: open failed: Wrong medium type
  --- Physical volume ---
  PV Name               /dev/md0
  VG Name               vg_virola
  PV Size               <1.79 TiB / not usable <4.38 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              468900
  Free PE               73380
  Allocated PE          395520
  PV UUID               447Azl-42A5-kln7-QS6X-3rWe-hRWm-u9SVMv

Création sur virola2 :

root@rescue ~ # pvcreate /dev/md0
  Physical volume "/dev/md0" successfully created.
root@rescue ~ # vgcreate vg_virola /dev/md0
  Volume group "vg_virola" successfully created
root@rescue ~ # pvdisplay 
  --- Physical volume ---
  PV Name               /dev/md0
  VG Name               vg_virola
  PV Size               <1.82 TiB / not usable 3.56 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              476898
  Free PE               476898
  Allocated PE          0
  PV UUID               APQjqb-mtAM-Aehw-RxHE-y6Bs-QSMT-z1Qq18

#7

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

logical volumes sur virola :

(April) root@virola:~# lvs
  /dev/drbd1: open failed: Wrong medium type
  LV      VG        Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  calamus vg_virola -wi-ao---- 1000.00g
  libvirt vg_virola -wi-ao----   20.00g
  root    vg_virola -wi-ao----    4.00g
  swap    vg_virola -wi-ao----    6.00g
  tmp     vg_virola -wi-ao----    1.00g
  var     vg_virola -wi-ao----    4.00g
  virola  vg_virola -wi-ao----  510.00g

Création sur virola2 :

lvcreate -L 1000G -n calamus vg_virola
lvcreate -L 20G -n libvirt vg_virola
lvcreate -L 4G -n root vg_virola
lvcreate -L 6G -n swap vg_virola
lvcreate -L 1G -n tmp vg_virola
lvcreate -L 4G -n var vg_virola
lvcreate -L 510G -n virola vg_virola

résultat :
root@rescue ~ # lvs
  LV      VG        Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  calamus vg_virola -wi-a----- 1000.00g
  libvirt vg_virola -wi-a-----   20.00g
  root    vg_virola -wi-a-----    4.00g
  swap    vg_virola -wi-a-----    6.00g
  tmp     vg_virola -wi-a-----    1.00g
  var     vg_virola -wi-a-----    4.00g
  virola  vg_virola -wi-a-----  510.00g
#8

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Partitionnement sur virola :

(April) root@virola:~# for lv in `lvs 2>/dev/null| grep '\-\-\-' | awk '{print $1}'`; do mount | grep /dev/mapper/vg_virola-$lv; done
/dev/mapper/vg_virola-libvirt on /var/lib/libvirt type ext4 (rw,relatime)
/dev/mapper/vg_virola-root on / type ext4 (rw,relatime,errors=remount-ro)
/dev/mapper/vg_virola-tmp on /tmp type ext4 (rw,relatime)
/dev/mapper/vg_virola-var on /var type ext4 (rw,relatime)

Copie sur virola2 :

mkfs.ext4 /dev/mapper/vg_virola-libvirt 
mkfs.ext4 /dev/mapper/vg_virola-root
mkfs.ext4 /dev/mapper/vg_virola-tmp
mkfs.ext4 /dev/mapper/vg_virola-var
#9

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Montage des partitions sur virola2 :

mkdir /mnt/target
mount /dev/mapper/vg_virola-root /mnt/target
mkdir /mnt/target/tmp
mkdir /mnt/target/var
mount /dev/mapper/vg_virola-tmp /mnt/target/tmp/
mount /dev/mapper/vg_virola-var /mnt/target/var
mkdir -p /mnt/target/var/lib/libvirt
mount /dev/mapper/vg_virola-libvirt /mnt/target/var/lib/libvirt

Initialisation du rootfs :

cd /mnt
wget http://ftp.us.debian.org/debian/pool/main/b/base-files/base-files_10.3+deb10u11_amd64.deb
ar vx base-files_10.3+deb10u11_amd64.deb
cp data.tar.xz target
cd target
tar xvfJ data.tar.xz .
rm data.tar.xz
#10

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Se connecter sur backuppc.april.org, regarder le numéro du dernier backup complet (ici 2004).

Se connecter sur galanga :

(April) root@galanga:~# cd /var/lib/backuppc/
(April) root@galanga:/var/lib/backuppc# sudo -u backuppc /usr/share/backuppc/bin/BackupPC_tarCreate -h virola -n 2004 -t -s / bin  boot  etc  home  initrd.img  initrd.img.old  lib  lib64  lost+found  media  mnt  opt  root  run  sbin  srv  tmp  usr  var  vmlinuz  vmlinuz.old > virola_2004_restore.tar
(…) environ 5-10min
(April) root@galanga:/var/lib/backuppc# scp virola_2004_restore.tar root@23.88.68.224:

Restauration sur virola2 :

cd /mnt/target/
tar xvf ~/virola_2004_restore.tar .
#11

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Passage en chroot :

root@rescue /mnt/target # mount -o bind /dev/ /mnt/target/dev
root@rescue /mnt/target # mount -o bind /proc/ /mnt/target/proc
root@rescue /mnt/target # mount -o bind /sys/ /mnt/target/sys
root@rescue /mnt/target # mount -o bind /run/ /mnt/target/run
root@rescue /mnt/target # chroot /mnt/target/

Adaptation de la configuration comme suit :

(April) root@rescue:~# cat /etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

23.88.68.225  calamus2.april.org
23.88.68.224   virola2.april.org

10.0.0.1        virola2
10.0.0.2        calamus2
(April) root@rescue:~# cat /etc/resolv.conf
#nameserver 172.16.0.3
#nameserver 62.210.16.6
#nameserver 62.210.16.7

nameserver 80.67.169.12
nameserver 80.67.169.40
(April) root@rescue:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto br0
iface br0 inet static
        address 23.88.68.224
        netmask 255.255.255.192
        gateway 23.88.68.193
        bridge_ports eth0
        bridge_maxwait 0
        bridge_stp off
        bridge_fd 0
#       up ip addr add 195.154.56.24/32 dev br0
#       up ip addr add 212.83.135.186/32 dev br0

auto eth1
iface eth1 inet static 
        address 10.0.0.1
        netmask 255.255.255.0
        up ip ro add 10.0.0.2/24 dev eth1

#auto vxlan10
#iface vxlan10 inet manual
#        pre-up ip link add vxlan10 type vxlan id 10 remote 10.91.70.30 ttl 20 dev eth1
#        #pre-up ip link add vxlan10 type vxlan id 10 remote 62.210.101.106 port 4789 4889 dstport 4789 ttl 20 dev br0
#        post-down ip link del vxlan10
#       mtu 1500

auto br1
iface br1 inet static  
        address 172.16.0.251
        netmask 255.255.255.0
        bridge_ports vxlan10
        bridge_maxwait 0
        bridge_stp off 
        bridge_fd 0
        up ip addr add 172.16.0.250/24 dev br1
        post-up route add -net 192.168.3.0/24 gw 172.16.0.253

Adaptation du firewall avec les nouvelles IP :

(April) root@virola2:/srv/common/etc/init.d[buster* u=]# git diff firewall
diff --git a/etc/init.d/firewall b/etc/init.d/firewall
index 3d358cc..b15329b 100755
--- a/etc/init.d/firewall
+++ b/etc/init.d/firewall
@@ -12,14 +12,14 @@ PATH=/bin:/sbin:/usr/sbin:/usr/bin

 #--- QUELQUES VARIABLES

-VIROLA=62.210.101.52
-VIROLA_RPN=10.91.69.206
-CALAMUS=62.210.101.106
-CALAMUS_RPN=10.91.70.30
+VIROLA=23.88.68.224
+VIROLA_RPN=10.0.0.1
+CALAMUS=23.88.68.225
+CALAMUS_RPN=10.0.0.2
 IPVIP=195.154.56.24
 IPVIP2=212.83.135.186

-if [ "$(  hostname -f )" == "virola.april.org" ]
+if [ "$(  hostname -f )" == "virola2.april.org" ]
 then
        IPEXT=$VIROLA
        MY_REMOTE=$CALAMUS

Mettre à jour les adresses mac dans /etc/udev/rules.d/70-persistent-net.rules :

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="6c:b3:11:0f:61:a5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" 
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="7c:10:c9:a2:82:4e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" 

Commenter le cron libvirt :

(April) root@rescue:/etc/cron.d# cat libvirt
#*/10 * * * * root cd /etc/libvirt/qemu && git remote update > /dev/null

Paramétrer grub comme suit :

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" 

Reconfiguration de grub :

dpkg-reconfigure grub-pc
update-initramfs -u -t
update-grub
grub-install /dev/sda
grub-install /dev/sdb
#12

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Synchro DRBD depuis virola

Se connecter à calamus, déconnecter virola :

drbdadm disconnect virola

Remplacer la conf drbd (/etc/drbd.d/virola.res) du volume "virola" sur virola et virola2 pour changer calamus en virola2 (hostname et IP)
Passer en protocol drbd asynchrone : protocol A au lieu de C
  • ajouter "protocol A;" dans le bloc net de virola.res sur les deux machines
  • reload

sur virola2 :

drbdadm create-md virola
drbdadm up virola
drbdadm disconnect virola
drbdadm detach virola

adapter le parefeu sur virola pour autoriser la communication avec virola2 sur le port 7788
adapter le parefeu sur virola2 pour passer MY_REMOTE sur 62.210.101.52

drbdadm detach virola
drbdadm connect virola
drbdadm attach virola
drbdadm status virola

drbd-overview

Patienter pendant la synchro…

#13

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

Ça sync…

#14

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

  • Statut changé de Nouveau à Résolu
  • Assigné à mis à Quentin Gibeaux

sync accéléré en arrêtant toutes les VM de virola pendant 5h la nuit, ça a fonctionné.

#15

Mis à jour par Quentin Gibeaux il y a plus de 2 ans

  • Statut changé de Résolu à Fermé

Formats disponibles : Atom PDF