Sostituzione di un disco con uno più grande in un pool Zfs
Jump to navigation
Jump to search
Espansione di un POOL con aggiunta di dischi
Se si ha un pool compost da uan serie di dischi in mirror:
zpool status
pool: BACKUP-001
state: ONLINE
scan: scrub repaired 0B in 12h11m with 0 errors on Sun Mar 8 12:35:43 2020
config:
NAME STATE READ WRITE CKSUM
BACKUP-001 ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
pci-0000:18:00.0-scsi-0:0:0:0 ONLINE 0 0 0
pci-0000:18:00.0-scsi-0:0:1:0 ONLINE 0 0 0
zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT BACKUP-001 4.53T 3.41T 1.12T - 38% 75% 1.00x ONLINE -
- Aggiungere i due nuovi dischi in mirror al pool:
pool add BACKUP-001 mirror /dev/disk/by-path/pci-0000\:18\:00.0-scsi-0\:0\:2\:0 /dev/disk/by-path/pci-0000\:18\:00.0-scsi-0\:0\:3\:0
- La nuova situazione sarà:
zpool status
pool: BACKUP-001
state: ONLINE
scan: scrub repaired 0B in 12h11m with 0 errors on Sun Mar 8 12:35:43 2020
config:
NAME STATE READ WRITE CKSUM
BACKUP-001 ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
pci-0000:18:00.0-scsi-0:0:0:0 ONLINE 0 0 0
pci-0000:18:00.0-scsi-0:0:1:0 ONLINE 0 0 0
mirror-1 ONLINE 0 0 0
pci-0000:18:00.0-scsi-0:0:2:0 ONLINE 0 0 0
pci-0000:18:00.0-scsi-0:0:3:0 ONLINE 0 0 0
zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT BACKUP-001 8.53T 3.41T 1.12T - 38% 55% 1.00x ONLINE -
POOL con disco Singolo
Stato iniziale
- Abbiamo un pool ZFS composto da un solo disco da 1TB, e vogliamo sostituire questo disco con uno da 2TB, utilizzando tutto lo spazio
- Ecco lo stato del pool iniziale
zpool status
pool: myfirstpool state: ONLINE config:
NAME STATE READ WRITE CKSUM
myfirstpool ONLINE 0 0 0
sda ONLINE 0 0 0
errors: No known data errors
- Ecco lo spazio occupato:
# df -h
Filesystem Size Used Avail Use% Mounted on myfirstpool 976G 277G 700G 29% /myfirstpool
Espansione manuale
- Aggiungiamo il secondo disco al pool, come mirror (specificare il disco esistente, e quello nuovo):
zpool attach myfirstpool /dev/sda /dev/sdb
- Se l'attach fallisce con un errore del tipo
cannot attach /dev/sdd3 to /dev/sdc3: can only attach to mirrors and top-level disks
- Verificare la proprietà del pool (se è specificata, bene, altrimenti, indovinarla se è 0):
zpool get ashift VM
NAME PROPERTY VALUE SOURCE VM ashift 0 default
- Provare aggiungendo al comando di attach:
-o ashift=9
- Lo stato ora sarà:
zpool status
pool: myfirstpool
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Wed Mar 15 05:20:06 2016
19.4G scanned out of 276G at 59.6M/s, 17h55m to go
19.4G resilvered, 0.52% done
config:
NAME STATE READ WRITE CKSUM
DISKB ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sda ONLINE 0 0 0
sdb ONLINE 0 0 0 (resilvering)
errors: No known data errors
- Al termine della ricostruzione:
zpool status
pool: myfirstpool
state: ONLINE
scan: resilvered 276G in 10h0m with 0 errors on Tue Mar 15 09:51:05 2016
config:
NAME STATE READ WRITE CKSUM
myfirstpool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sda ONLINE 0 0 0
sdb ONLINE 0 0 0
errors: No known data errors
- Lo spazio, sempre lo stesso:
# df -h
Filesystem Size Used Avail Use% Mounted on myfirstpool 976G 277G 700G 29% /myfirstpool
- Ora rimuoviamo il vecchio disco:
zpool detach myfirstpool /dev/sda
- Ecco l'effetto della rimozione:
zpool status
pool: myfirstpool state: ONLINE config:
NAME STATE READ WRITE CKSUM
myfirstpool ONLINE 0 0 0
sdb ONLINE 0 0 0
errors: No known data errors
- Lo spazio, sempre lo stesso:
# df -h
Filesystem Size Used Avail Use% Mounted on myfirstpool 976G 277G 700G 29% /myfirstpool
- Per utilizzarlo, è necessario espandere il pool sul nuovo disco:
zpool online -e myfirstpool /dev/sdb
- Ora lo spazio è utilizzato:
df -h
Filesystem Size Used Avail Use% Mounted on myfirstpool 2.0T 277G 1.7T 15% /myfirstpool
Riferimenti
Espansione automatica
- Dovrebbe essere possibile l'auto espansione, prima di aggiungere il device, impostando la proprietà:
zpool get autoexpand myfirstpool
NAME PROPERTY VALUE SOURCE myfirstpool autoexpand off default
- Impostarla e verificare:
zpool set autoexpand=on myfirstpool
zpool get autoexpand myfirstpool
NAME PROPERTY VALUE SOURCE myfirstpool autoexpand on local
- Se ora si effettua l'aggiunta del nuovo disco, dopo il detach del vecchio, lo spazio sarà espanso automaticamente
- Se non funziona, verificare perchè:
zpool get expandsize myfirstpool
NAME PROPERTY VALUE SOURCE storage expandsize 2.27T -
Divisione di un mirror
- Se invece si vuole conservare la copia del vecchio disco, è possibile spezzare il mirror, lasciando il contenuto su entrambi i dischi, ed esportando il vecchio idsco in un nuovo poll
- Specificare l'operazione split, indicando
- nome del pool originale che conserverà il nuovo disco: myfirstpool
- nome del nuovo pool, che accoglierà il vecchio disco: mysecondpol
- nome del disco che verrà accolto nel nuovo pool (il vecchio disco): sda
zpool split myfirstpool mysecondpool /dev/sda
- Ora il pool originale è composto solo dal nuovo disco:
zpool status
pool: myfirstpool state: ONLINE config:
NAME STATE READ WRITE CKSUM
myfirstpool ONLINE 0 0 0
sdb ONLINE 0 0 0
errors: No known data errors
- Il pool splittato sarà importabile:
zpool import
pool: mysecondpool
id: 3595499847024087738
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
mysecondpool ONLINE
sda ONLINE
- Fare attenzione ad eventuali mountpoint specificati manualmente, ed importare il nuovo pool
zpool import mysecondpool
- Ecco entrambi i polls:
zpool status
pool: myfirstpool state: ONLINE config:
NAME STATE READ WRITE CKSUM
myfirstpool ONLINE 0 0 0
sdb ONLINE 0 0 0
errors: No known data errors
pool: mysecondpool state: ONLINE config:
NAME STATE READ WRITE CKSUM
myfirstpool ONLINE 0 0 0
sda ONLINE 0 0 0
errors: No known data errors
- Vedere i mountpoint impostati:
zfs list
NAME USED AVAIL REFER MOUNTPOINT mysecondpool 900M 890G 96K /mysecondpool myfirstpool 900M 1.8T 96K /myfirstpool
- Vedere i mountpoint ATTIVI:
zfs mount
myfirstpool /myfirstpool mysecondpool /mysecondpool
- Nel caso cambiare i mountpoint con
zfs set mountpoint=/whatever /mysecondpool/mydataset
Riferimenti
- Adding a mirror to a device in a ZFS pool
- Oracle Solaris ZFS Administration Guide - Attaching and Detaching Devices in a Storage Pool
- Growing ZFS pool | Tomasz Korwel
- How to Break the ZFS mirror on Solaris ? - UnixArena
- Oracle Solaris ZFS Administration Guide - Creating a New Pool By Splitting a Mirrored ZFS Storage Pool
POOL con mirror
- Se possibile, aggiungere il nuovo disco e poi rimuovere il vecchio
- Altrimenti, togliere il disco vecchio ed inserire il nuovo.
- Il pool dirà che manca un VDEV
zpool status
# zpool status
pool: DATA
state: DEGRADED
status: One or more devices could not be used because the label is missing or
invalid. Sufficient replicas exist for the pool to continue
functioning in a degraded state.
action: Replace the device using 'zpool replace'.
see: http://zfsonlinux.org/msg/ZFS-8000-4J
scan: scrub repaired 0 in 37h57m with 0 errors on Mon Nov 11 14:21:39 2019
config:
NAME STATE READ WRITE CKSUM
DATA DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
12129770681428527516 UNAVAIL 0 0 0 was /dev/sda1
ata-ST3000DM001-1ER166_W5013Y0H ONLINE 0 0 0
errors: No known data errors
- Sostituirlo col nuovo:
zpool replace DATA /dev/sda1 /dev/disk/by-path/pci-0000\:00\:1f.2-ata-1
zpool status
pool: DATA
state: DEGRADED
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Fri Nov 29 16:23:45 2019
1.47G scanned out of 5.24T at 11.3M/s, 135h1m to go
759M resilvered, 0.03% done
config:
NAME STATE READ WRITE CKSUM
DATA DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
replacing-0 UNAVAIL 0 0 0
12129770681428527516 UNAVAIL 0 0 0 was /dev/sda1
pci-0000:00:1f.2-ata-1 ONLINE 0 0 0 (resilvering)
ata-ST3000DM001-1ER166_W5013Y0H ONLINE 0 0 0
errors: No known data errors
- Al termine del resilver, il vecchio vdev sparirà.
- A questo punto, riptere l'operazione per l'altro disco
- Espandere il pool