informatica:linux:raid
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:linux:raid [2013/03/19 14:37] – javi | informatica:linux:raid [2020/11/15 13:11] (current) – jose | ||
---|---|---|---|
Line 71: | Line 71: | ||
For the record, here's how I do the MBR replication: | For the record, here's how I do the MBR replication: | ||
- | # grub --no-floppy | + | |
- | + | < | |
- | device (hd0) / | + | device (hd0) /dev/sda |
- | root (hd0, | + | root (hd0,0) |
setup (hd0) | setup (hd0) | ||
- | device (hd0) / | + | device (hd0) /dev/sdb |
- | root (hd0, | + | root (hd0,0) |
setup (hd0) | setup (hd0) | ||
- | device (hd0) / | + | device (hd0) /dev/sdc |
- | root (hd0, | + | root (hd0,0) |
setup (hd0) | setup (hd0) | ||
Line 93: | Line 93: | ||
* take great care that the raid1 is in sync, to insure that all the required files are in their final position on disk | * take great care that the raid1 is in sync, to insure that all the required files are in their final position on disk | ||
* thanks to grub's architecture, | * thanks to grub's architecture, | ||
+ | </ | ||
==== Cambiar un disco ==== | ==== Cambiar un disco ==== | ||
Line 99: | Line 100: | ||
Mostramos los discos que hay | Mostramos los discos que hay | ||
- | # clear;cat / | + | |
+ | < | ||
Personalities : [raid1] [raid6] [raid5] [raid4] | Personalities : [raid1] [raid6] [raid5] [raid4] | ||
md1 : active raid5 sda2[0] sdc2[2] sdb2[1] | md1 : active raid5 sda2[0] sdc2[2] sdb2[1] | ||
957232896 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU] | 957232896 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU] | ||
+ | </ | ||
- | + | | |
- | # mdadm - - detail /dev/md1 | + | < |
/dev/md1: | /dev/md1: | ||
Version : 00.90.03 | Version : 00.90.03 | ||
Line 134: | Line 137: | ||
| | ||
| | ||
+ | </ | ||
Los 3 discos del RAID 5 están funcionando correctamente. | Los 3 discos del RAID 5 están funcionando correctamente. | ||
- | Forzamos el fallo en un disco:\\ | + | Forzamos el fallo en un disco: |
- | # mdadm --manage --set-faulty /dev/md1 /dev/sdb2 | + | |
+ | | ||
+ | < | ||
mdadm: set /dev/sdb2 faulty in /dev/md1 | mdadm: set /dev/sdb2 faulty in /dev/md1 | ||
+ | </ | ||
- | # cat / | + | |
+ | < | ||
Personalities : [raid1] [raid6] [raid5] [raid4] | Personalities : [raid1] [raid6] [raid5] [raid4] | ||
md1 : active raid5 sda2[0] sdc2[2] sdb2[3](F) | md1 : active raid5 sda2[0] sdc2[2] sdb2[3](F) | ||
957232896 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U] | 957232896 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U] | ||
+ | </ | ||
- | # clear;mdadm --detail /dev/md1\\ | + | |
+ | < | ||
/dev/md1: | /dev/md1: | ||
Version : 00.90.03 | Version : 00.90.03 | ||
Line 178: | Line 187: | ||
| | ||
+ | </ | ||
- | + | En / | |
- | En / | + | < |
Oct 26 12:04:03 servidor kernel: | Oct 26 12:04:03 servidor kernel: | ||
Oct 26 12:04:03 servidor kernel: | Oct 26 12:04:03 servidor kernel: | ||
Line 190: | Line 200: | ||
Oct 26 12:04:03 servidor kernel: | Oct 26 12:04:03 servidor kernel: | ||
Oct 26 12:04:03 servidor mdadm: Fail event detected on md device /dev/md1, component device /dev/sdb2 | Oct 26 12:04:03 servidor mdadm: Fail event detected on md device /dev/md1, component device /dev/sdb2 | ||
+ | </ | ||
- | Sacamos el disco del RAID5. Se saca en caliente si no está activo en el RAID: \\ | + | Sacamos el disco del RAID5. Se saca en caliente si no está activo en el RAID: |
- | # mdadm /dev/md1 --remove /dev/sdb2 | + | |
+ | | ||
+ | < | ||
mdadm: hot removed /dev/sdb2 | mdadm: hot removed /dev/sdb2 | ||
+ | </ | ||
+ | |||
+ | Aparece quitado: | ||
- | Aparece quitado: | + | |
- | # mdadm --detail /dev/md1 | + | < |
/dev/md1: | /dev/md1: | ||
Version : 00.90.03 | Version : 00.90.03 | ||
Line 225: | Line 241: | ||
| | ||
| | ||
+ | </ | ||
+ | Lo volvemos a añadir: | ||
- | Lo volvemos a añadir: \\ | + | |
- | # mdadm /dev/md1 -a /dev/sdb2 | + | < |
mdadm: re-added /dev/sdb2 | mdadm: re-added /dev/sdb2 | ||
+ | </ | ||
- | + | | |
- | # clear;mdadm --detail /dev/md1 | + | < |
/dev/md1: | /dev/md1: | ||
Version : 00.90.03 | Version : 00.90.03 | ||
Line 263: | Line 282: | ||
| | ||
| | ||
+ | </ | ||
- | Si volvemos a lanzar el comando:\\ | + | Si volvemos a lanzar el comando: |
+ | < | ||
Rebuild Status : 18% complete | Rebuild Status : 18% complete | ||
+ | </ | ||
+ | Vemos como se está reconstruyendo el disco: | ||
- | Vemos como se está reconstruyendo el disco:\\ | + | |
- | # cat / | + | < |
Personalities : [raid1] [raid6] [raid5] [raid4] | Personalities : [raid1] [raid6] [raid5] [raid4] | ||
md1 : active raid5 sdb2[3] sda2[0] sdc2[2] | md1 : active raid5 sdb2[3] sda2[0] sdc2[2] | ||
957232896 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U] | 957232896 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U] | ||
[> | [> | ||
- | + | </ | |
==== Configuracion ==== | ==== Configuracion ==== | ||
Line 299: | Line 321: | ||
9767424 blocks [3/3] [UUU] | 9767424 blocks [3/3] [UUU] | ||
- | #mdadm --detail / | + | |
- | / | + | |
- | Version : 00.90.03 | + | < |
- | Creation Time : Thu Oct 25 21:15:28 2007 \\ | + | /dev/md0: |
- | Raid Level : raid1 \\ | + | Version : 00.90.03 |
- | Array Size : 9767424 (9.31 GiB 10.00 GB) \\ | + | Creation Time : Thu Oct 25 21:15:28 2007 |
- | Device Size : 9767424 (9.31 GiB 10.00 GB) \\ | + | Raid Level : raid1 |
- | Raid Devices : 3 \\ | + | Array Size : 9767424 (9.31 GiB 10.00 GB) |
- | Total Devices : 3 \\ | + | Device Size : 9767424 (9.31 GiB 10.00 GB) |
- | | + | Raid Devices : 3 |
- | Persistence : Superblock is persistent | + | Total Devices : 3 |
+ | | ||
+ | Persistence : Superblock is persistent | ||
- | Update Time : Sat Nov 3 15:07:36 2007 \\ | + | Update Time : Sat Nov 3 15:07:36 2007 |
- | State : clean \\ | + | State : clean |
- | | + | |
- | | + | |
- | | + | |
- | Spare Devices : 0 \\ | + | Spare Devices : 0 |
- | UUID : a912d356: | + | UUID : a912d356: |
| | ||
- | Number | + | Number |
- | | + | |
- | | + | |
| | ||
+ | </ | ||
+ | Añadimos el disco: | ||
- | Añadimos el disco: \\ | + | |
- | #mdadm /dev/md0 -a / | + | mdadm: added /dev/sdb1 |
- | mdadm: added /dev/sdb1 | + | |
- | Ahora el disco aparecerà en reserva: | + | Ahora el disco aparecerà en reserva: |
servidor:~# mdadm --detail /dev/md0 | servidor:~# mdadm --detail /dev/md0 | ||
+ | < | ||
/dev/md0: | /dev/md0: | ||
Version : 00.90.03 | Version : 00.90.03 | ||
Line 360: | Line 386: | ||
| | ||
+ | </ | ||
Aumentamos el tamaño del RAID para que lo coja: | Aumentamos el tamaño del RAID para que lo coja: | ||
#mdadm --grow /dev/md0 --raid-devices=4 | #mdadm --grow /dev/md0 --raid-devices=4 | ||
+ | < | ||
md0 : active raid1 sdb1[4] sda1[0] sdd1[2] sdc1[1] | md0 : active raid1 sdb1[4] sda1[0] sdd1[2] sdc1[1] | ||
9767424 blocks [4/3] [UUU_] | 9767424 blocks [4/3] [UUU_] | ||
Line 373: | Line 399: | ||
[> | [> | ||
+ | </ | ||
Para que coja todo el tamaño del disco: \\ | Para que coja todo el tamaño del disco: \\ | ||
#mdadm --grow /dev/md1 --size=max | #mdadm --grow /dev/md1 --size=max | ||
Line 378: | Line 405: | ||
Todavía no ha cogido el filesystem todo el tamaño: | Todavía no ha cogido el filesystem todo el tamaño: | ||
#pvdisplay | #pvdisplay | ||
+ | < | ||
--- Physical volume --- | --- Physical volume --- | ||
PV Name / | PV Name / | ||
Line 388: | Line 416: | ||
Allocated PE 233699 | Allocated PE 233699 | ||
PV UUID | PV UUID | ||
+ | </ | ||
Le decimos que lo coja todo:\\ | Le decimos que lo coja todo:\\ | ||
# pvresize /dev/md1 | # pvresize /dev/md1 | ||
Line 395: | Line 423: | ||
servidor:~# pvdisplay\\ | servidor:~# pvdisplay\\ | ||
+ | < | ||
--- Physical volume --- | --- Physical volume --- | ||
PV Name / | PV Name / | ||
Line 405: | Line 434: | ||
Allocated PE 233699 | Allocated PE 233699 | ||
PV UUID | PV UUID | ||
+ | </ | ||
Primero hacemos un test: | Primero hacemos un test: | ||
#lvresize -v -d -t -L +457G / | #lvresize -v -d -t -L +457G / | ||
Nos la jugamos:\\ | Nos la jugamos:\\ | ||
- | #lvresize -v -d -L +457G / | + | |
+ | |||
+ | < | ||
Found volume group " | Found volume group " | ||
Loading servidor-servidor_home table | Loading servidor-servidor_home table | ||
Line 417: | Line 448: | ||
Resuming servidor-servidor_home (253:3) | Resuming servidor-servidor_home (253:3) | ||
Logical volume servidor_home successfully resized | Logical volume servidor_home successfully resized | ||
+ | </ | ||
Una vez añadido incrementamos el tamaño online. Necesitamos el paquete ext2resize: | Una vez añadido incrementamos el tamaño online. Necesitamos el paquete ext2resize: | ||
Line 423: | Line 454: | ||
http:// | http:// | ||
+ | |||
+ | ===== Cambiar disco en frio (apagando server) ===== | ||
+ | |||
+ | 1. Apagar servidor | ||
+ | |||
+ | 2. Desconectar disco que creemos que falla | ||
+ | |||
+ | 3. Arrancar servidor | ||
+ | |||
+ | 4. Entrar en la BIOS | ||
+ | |||
+ | supr | ||
+ | |||
+ | 5. Comprobar que el unico disco conectado es master. En mi caso en la BIOS Asus: | ||
+ | |||
+ | SATA6G_1 | ||
+ | |||
+ | 6. (Opcional) si el disco no estaba como master apagar servidor y conectar el disco como master cambiando cables y encender de nuevo | ||
+ | |||
+ | 7. Arrancar servidor | ||
+ | |||
+ | 8. Tocar flecha arriba/ | ||
+ | |||
+ | 9. Arrancar en modo recovery | ||
+ | |||
+ | 10. Decir que se quiere arrancar el RAID degradado | ||
+ | |||
+ | y | ||
+ | Enter | ||
+ | |||
+ | 11. Arrancar normal | ||
+ | |||
+ | TODO: provide menu label | ||
+ | Enter | ||
+ | |||
+ | 12. Ver las pariciones del disco bueno, en mi caso /dev/sda | ||
+ | |||
+ | sudo fdisk /dev/sda | ||
+ | < | ||
+ | The device presents a logical sector size that is smaller than | ||
+ | the physical sector size. Aligning to a physical sector (or optimal | ||
+ | I/O) size boundary is recommended, | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | p | ||
+ | < | ||
+ | Disk /dev/sda: 1000.2 GB, 1000204886016 bytes | ||
+ | 255 heads, 63 sectors/ | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk identifier: 0x000ab48f | ||
+ | |||
+ | | ||
+ | / | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | q | ||
+ | |||
+ | 13. Copiar el mismo particionado: | ||
+ | |||
+ | 13.1. Crear particion | ||
+ | |||
+ | sudo fdisk /dev/sdb | ||
+ | < | ||
+ | The device presents a logical sector size that is smaller than | ||
+ | the physical sector size. Aligning to a physical sector (or optimal | ||
+ | I/O) size boundary is recommended, | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | p | ||
+ | < | ||
+ | Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes | ||
+ | 255 heads, 63 sectors/ | ||
+ | Units = sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/ | ||
+ | I/O size (minimum/ | ||
+ | Disk identifier: 0x4d1b267d | ||
+ | |||
+ | | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | n | ||
+ | < | ||
+ | Partition type: | ||
+ | | ||
+ | | ||
+ | Select (default p): | ||
+ | </ | ||
+ | |||
+ | Enter | ||
+ | < | ||
+ | Using default response p | ||
+ | Partition number (1-4, default 1): | ||
+ | </ | ||
+ | |||
+ | Enter | ||
+ | < | ||
+ | Using default value 1 | ||
+ | First sector (2048-1953525167, | ||
+ | </ | ||
+ | |||
+ | Enter | ||
+ | < | ||
+ | Using default value 2048 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | </ | ||
+ | |||
+ | Enter | ||
+ | < | ||
+ | Using default value 1953525167 | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | w | ||
+ | < | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | </ | ||
+ | |||
+ | 13.2. Cambiar label | ||
+ | |||
+ | sudo fdisk /dev/sdb | ||
+ | < | ||
+ | The device presents a logical sector size that is smaller than | ||
+ | the physical sector size. Aligning to a physical sector (or optimal | ||
+ | I/O) size boundary is recommended, | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | t | ||
+ | < | ||
+ | Selected partition 1 | ||
+ | Hex code (type L to list codes): | ||
+ | </ | ||
+ | |||
+ | fd | ||
+ | < | ||
+ | Changed system type of partition 1 to fd (Linux RAID autodetect) | ||
+ | |||
+ | Command (m for help): | ||
+ | </ | ||
+ | |||
+ | w | ||
+ | < | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | </ | ||
+ | |||
+ | 14. Ver estado del raid: | ||
+ | |||
+ | cat / | ||
+ | < | ||
+ | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] | ||
+ | md0 : active raid1 sda1[1] | ||
+ | 976629568 blocks super 1.2 [2/1] [_U] | ||
+ | | ||
+ | unused devices: < | ||
+ | </ | ||
+ | |||
+ | 15. Anyadir particion (en mi caso /dev/sdb1) al RAID (en mi caso md0) | ||
+ | |||
+ | sudo mdadm -a /dev/md0 /dev/sdb1 | ||
+ | < | ||
+ | mdadm: added /dev/sdb1 | ||
+ | </ | ||
+ | |||
+ | 16. Ver progreso | ||
+ | |||
+ | cat / | ||
+ | < | ||
+ | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] | ||
+ | md0 : active raid1 sdb1[2] sda1[1] | ||
+ | 976629568 blocks super 1.2 [2/1] [_U] | ||
+ | [> | ||
+ | | ||
+ | unused devices: < | ||
+ | </ | ||
+ | |||
+ | 17. Install grub on the MBR of new hard disk | ||
+ | |||
+ | sudo grub-install /dev/sdb | ||
+ | < | ||
+ | / | ||
+ | Installation finished. No error reported. | ||
+ | </ | ||
+ | |||
+ | **TODO**: quiza esperar a que termine el rebuild | ||
+ | |||
+ | ===== Errores ===== | ||
+ | |||
+ | ====== incrementally starting raid arrays ====== | ||
+ | |||
+ | A mi me paso cuando casco 1 de los 2 discos de un RAID 0 e intente arrancar con uno de los discos. | ||
+ | |||
+ | Entra en un loop infinito y no llega a arrancar: | ||
+ | |||
+ | < | ||
+ | incrementally starting raid arrays | ||
+ | mdadm: Create user root not found | ||
+ | mdadm: create group disk not found | ||
+ | incrementally started raid arrays | ||
+ | </ | ||
+ | |||
+ | **Causa**: intercanvie de lugar en la placa base el disco. Es decir, antes era el disco maestro, y lo puse conectado a los cables que lo hacian esclavo | ||
+ | |||
+ | **Solucion** | ||
+ | |||
+ | http:// | ||
+ | |||
+ | 1. Volver a colocar el disco en la " | ||
+ | |||
+ | 2. Una vez haya arrancado: | ||
+ | |||
+ | < | ||
+ | sudo su | ||
+ | echo mpt2sas >>/ | ||
+ | </ | ||
+ | |||
+ | 3. Apagar el servidor. Ya se puede colocar el disco en cualquier posicion que arrancara | ||
+ | |||
+ | |||
+ | ====== Recuperar RAID ====== | ||
+ | # mdadm --detail --scan | ||
+ | |||
+ | ARRAY /dev/md/0 metadata=1.2 name=proxmox01: | ||
+ | ARRAY /dev/md/2 metadata=1.2 name=proxmox01: | ||
+ | ARRAY /dev/md/1 metadata=1.2 name=proxmox01: | ||
informatica/linux/raid.1363703831.txt.gz · Last modified: 2015/04/13 20:19 (external edit)