LVM sostituire disco guasto

Discussioni relative a Debian e Linux
Rispondi
sirio81
Hero Member
Hero Member
Messaggi: 1104
Iscritto il: 13/02/2006, 5:04
Contatta:

LVM sostituire disco guasto

Messaggio da sirio81 »

Sto sperimentando la gestione della ridondanza direttamente con lvm (con una macchina virtuale debian jessie).
Creo un raid 5 con 3 dischi da 512M e ci credo sopra un filesystem ext4.
Poi spengo la macchina e la faccio ripartire senza un disco.
Riesco a rimuovere il disco "fallito" con successo.
(Questo per simulare un guasto hardware ad un disco).
Spengo nuovamente la macchina e aggiungo un nuovo disco di pari dimensioni.
Lo aggiungo nel volume group...ma noto che il disco virtuale non aumenta e che quindi non sta sincronizzando i dati.
Quello che non riesco a trovare è:
  • Un comando che mi faccia capire se un volume logico è ridondato o meno
    (da lvdisplay non vedo questa informazione)
  • Un comando per far partire la sincronizzazione
    (lvchange --raidsyncaction check|repair non sembra avere effetto)
  • Un comando per monitorare la sincronizzazione
    (lvs mostra sempre 100%)

Codice: Seleziona tutto

(lato guest)
pvcreate /dev/vd[bcd]
vgcreate vg00 /dev/vd[bcd]
lvcreate -n test --type raid5 --stripes 2 -l 100%FREE vg00
mkfs.ext4 /dev/vg00/test
mount /dev/vg00/test /mnt/test
dd if=/dev/zero of=/mnt/test/c bs=1M count=100

(Lato host)
ls -lh jessie_lvm*
-rw-r--r-- 1 root    root     67M ott 17 19:27 jessie_lvm1.qcow2
-rw-r--r-- 1 root    root     67M ott 17 18:57 jessie_lvm2.qcow2
-rw-r--r-- 1 root    root     67M ott 17 19:27 jessie_lvm3.qcow2
-rw-r--r-- 1 valerio valerio 4,0G ott 17 19:30 jessie_lvm.raw

(lato guest)
lvdisplay 
  --- Logical volume ---
  LV Path                /dev/vg00/test
  LV Name                test
  VG Name                vg00
  LV UUID                d0hWRd-Ovif-i0lq-alei-HsIF-1ytn-N8pirW
  LV Write Access        read/write
  LV Creation host, time debian, 2016-10-17 18:49:23 +0200
  LV Status              available
  # open                 0
  LV Size                1008,00 MiB
  Current LE             252
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     768
  Block device           253:8

(lato host)
faccio partire la vm senza il secondo disco

(lato guest)
pvscan 
  Couldn't find device with uuid UOvuJv-VlhL-1jdb-Jv19-cMpc-13M3-AqMU7w.
  PV /dev/vdb         VG vg00   lvm2 [508,00 MiB / 0    free]
  PV unknown device   VG vg00   lvm2 [508,00 MiB / 0    free]
  PV /dev/vdc         VG vg00   lvm2 [508,00 MiB / 0    free]
  Total: 3 [1,49 GiB] / in use: 3 [1,49 GiB] / in no VG: 0 [0   ]
lvs
  Couldn't find device with uuid UOvuJv-VlhL-1jdb-Jv19-cMpc-13M3-AqMU7w.
  LV   VG   Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  test vg00 rwi-a-r-p- 1008,00m                                    100,00

vgreduce --removemissing vg00 --force

(lato host)
creo un nuovo disco virtuale jessie_lvm4.qcow2 e lo aggiungo alla vm

(lato guest)
pvcreate /dev/vdd
  Physical volume "/dev/vdd" successfully created

vgextend vg00 /dev/vdd
  Volume group "vg00" successfully extended

pvscan 
  PV /dev/vdb   VG vg00   lvm2 [508,00 MiB / 0    free]
  PV /dev/vdc   VG vg00   lvm2 [508,00 MiB / 0    free]
  PV /dev/vdd   VG vg00   lvm2 [508,00 MiB / 508,00 MiB free]
  Total: 3 [1,49 GiB] / in use: 3 [1,49 GiB] / in no VG: 0 [0   ]

(Lato host)
ls -lh jessie_lvm*
-rw-r--r-- 1 root    root     67M ott 17 19:27 jessie_lvm1.qcow2
-rw-r--r-- 1 root    root     67M ott 17 18:57 jessie_lvm2.qcow2
-rw-r--r-- 1 root    root     67M ott 17 19:27 jessie_lvm3.qcow2
-rw-r--r-- 1 root    root    384K ott 17 19:15 jessie_lvm4.qcow2
-rw-r--r-- 1 valerio valerio 4,0G ott 17 19:30 jessie_lvm.raw
Come controprova ho provato a far partire la mv senza il primo disco e si ferma nel processo di boot perchè non riesce a creare il device.
sirio81
Hero Member
Hero Member
Messaggi: 1104
Iscritto il: 13/02/2006, 5:04
Contatta:

Re: LVM sostituire disco guasto

Messaggio da sirio81 »

Ho trovato informazioni utili, principalmente sulla guida di red-hat.

Con questo comando riesco a sapere se il volume logico è ridondato

Codice: Seleziona tutto

lvs -o +segtype vg00
  LV   VG   Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Type 
  test vg00 rwi-a-r--- 1008,00m                                    100,00           raid5
Posso avere più dettagli sui componenti del raid

Codice: Seleziona tutto

  lvs -a -o segtype,name,copy_percent,devices vg00
  Type   LV              Cpy%Sync Devices                                           
  raid5  test            100,00   test_rimage_0(0),test_rimage_1(0),test_rimage_2(0)
  linear [test_rimage_0]          /dev/vdb(1)                                       
  linear [test_rimage_1]          /dev/vdc(1)                                       
  linear [test_rimage_2]          /dev/vdd(1)                                       
  linear [test_rmeta_0]           /dev/vdb(0)                                       
  linear [test_rmeta_1]           /dev/vdc(0)                                       
  linear [test_rmeta_2]           /dev/vdd(0)
Se un device dovesse fallire, viene usato automaticamente un libero (spare) nel vg.
Va comunque rimosso dal vg con vgreduce --remove missing.

Posso sostitire un pv (mentre sta ancora funzionando) con un altro (aggiunto in precedenza al vg).

Codice: Seleziona tutto

lvconvert --replace dev_to_remove vg/lv.
Il replace però non funziona se il device è mancante.

Io mi trovo in questa situazione:

Codice: Seleziona tutto

lvs -a -o segtype,name,copy_percent,devices vg00
  Couldn't find device with uuid YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA.
  Type   LV              Cpy%Sync Devices                                           
  raid5  test            100,00   test_rimage_0(0),test_rimage_1(0),test_rimage_2(0)
  linear [test_rimage_0]          /dev/vdb(1)                                       
  linear [test_rimage_1]          /dev/vdd(1)                                       
  linear [test_rimage_2]          unknown device(1)                                 
  linear [test_rmeta_0]           /dev/vdb(0)                                       
  linear [test_rmeta_1]           /dev/vdd(0)                                       
  linear [test_rmeta_2]           unknown device(0) 

vgextend vg00 /dev/vdc
  Couldn't find device with uuid YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA.
  Physical volume "/dev/vdc" successfully created
  Volume group "vg00" successfully extended

lvconvert --replace uuid=YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA vg00/test
  Couldn't find device with uuid YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA.
  Cannot change VG vg00 while PVs are missing.
  Consider vgreduce --removemissing.

vgreduce --removemissing --force vg00
  Couldn't find device with uuid YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA.
  Wrote out consistent volume group vg00

lvconvert --replace uuid=YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA vg00/test
  Physical Volume "uuid=YAlE4W-jVBo-20R5-jpz9-TjeK-0pSu-fv3EEA" not found in Volume Group "vg00"

lvchange --refresh vg00/test

lvchange --raidsyncaction repair vg00/test

lvs -a -o segtype,name,copy_percent,devices vg00
  Type   LV              Cpy%Sync Devices                                           
  raid5  test            100,00   test_rimage_0(0),test_rimage_1(0),test_rimage_2(0)
  linear [test_rimage_0]          /dev/vdb(1)                                       
  linear [test_rimage_1]          /dev/vdd(1)                                       
  error  [test_rimage_2]                                                            
  linear [test_rmeta_0]           /dev/vdb(0)                                       
  linear [test_rmeta_1]           /dev/vdd(0)                                       
  error  [test_rmeta_2] 
Rispondi