ALL SYSTEMS OPERATIONALUPTIME 99.97%FLEET 18/18IN-MUM · US-LAX · EU-FSN EST. 2003 · +91 11 4998 4038

CONOCIDOS · SERVICIOS DEDICAADOS " VPS

Gestión del software de Linux RAID (Part I)

Última actualización 2019-02-03

Gestión del software de Linux RAID (Part I)

Redundant Array of Independent Disks (RAID) is a storage and virtualization technology that first gained traction in the late 1980s. It combines multiple physical disk drives into one logical virtual unit to improve performance and facilitate redundancy. Data is distributed across the drives depending on the Nivel de RAID. Aunque no sea un sustituto de las copias de seguridad, los niveles de RAID pueden ayudar a mantener su sistema funcionando frente a problemas de hardware comunes como la pérdida de datos de fallos de disco o errores de lectura (sector).

RAID puede ser implementado y gestionado usando "ldquo;block limitadordquo; dispositivos, que pueden ser Software RAID (por ejemplo, Linux Software RAID cosecharsquo;s mdadm), Hardware RAID (es decir, tarjeta de hardware dedicada), o FakeRAID (también llamado BIOS o A bordo de RAID). Este artículo se centrará en el cómo-tos de Linux Software RAID y su herramienta de gestión, mdadm.
 
Linux Software RAID is a block device that can work on most other devices—SATA, USB, IDE, SCSI, or a combination of these. Note that the La capa RAID no toca la capa del sistema de archivos at all. Puede colocar un sistema de archivos en un dispositivo RAID, al igual que en cualquier otro dispositivo de bloque.

 

Cómo funcionan los dispositivos RAID de software

Los dispositivos RAID de software deben ser vistos como discos ordinarios o particiones de disco. Pueden ser "construidos" de varios otros dispositivos de bloque.

En una implementación de RAID, hay discos de repuesto o repuestos calientes que no participan en el set de RAID hasta que uno de los discos activos falla. Una vez detectado un fallo del dispositivo, ese dispositivo se marca como ‘faulty implicarsquo; y el set comienza la reconstrucción inmediatamente en el primer repuesto caliente disponible. Su sistema puede funcionar por algún tiempo incluso con un disco defectuoso ya que la repuesto tiene su lugar. Si no hay disco de repuesto disponible, entonces el array se ejecuta en modo 'degradado'.

Tenga en cuenta que los discos defectuosos todavía aparecen y se comportan como miembros del array. La capa RAID sólo evita leerlos/escribirlos. Además, si un dispositivo necesita ser eliminado del array, recuerde marcarlo primero como ‘faulty implicarsquo; antes de eliminarlo.

 

Creación de un dispositivo RAID basado en la unidad SATA

You can use full drives as parts of a RAID array but this should be avoided if you want to make the drives bootable. What you need to do is create a partition in the drives (using fdisk or Parted) with partition type set to ‘fd, Pulsquo; el software de Linux RAID auto-detecto.

Después de crear una partición en cada unidad relevante (sda1, sdb1), ahora puede crear el array:

mdadm --create /dev/md0 -n 2 --level=1 /dev/sda1 /dev/sdb1

                Where:

    • /dev/md0 - your new array device path
    • -n 2  - the total number of drives, which can be classified as spare, active, or missing; a ‘missing’ drive requires the additional option -f to work
    • --nivel=trabajo- puede contener cualquiera de los siguientes:
      • uno de los lineales
      • raid0  OR 0
      • stripe
      • raid1  OR 1
      • espejo
      • raid4 OR 4
      • raid5 OR 5 
      • raid6 OR 6
      • raid10 OR 10
      • multipath OR mp
      • Fallo
      • contenedor
    • /dev/sda1, /dev/sdb1 - each component device's path

NOTA IMPORTANTE: Si quieres arrancar desde un dispositivo RAID, coloca elcargador de arranque code at the start of the physical drive that will be used as the underlying component of the RAID device. This means that if you are using/dev/sda1 as a member of the array /dev/md0 and your primary HDD/SSD is set as Opción de arranque BIOS, you must choose /dev/sda for the cargador de arranque code. One way to do this is by running grub-install /dev/sda.

Después de crear un dispositivo RAID, puede utilizarlo como lo haría una unidad local regular. Por ejemplo, puede utilizarlo como un volumen físico para el kernel de Linux, el administrador lógico del volumen (LVM) o poner un sistema de archivos en él.

While RAID metadata is stored in each component drive, you should still save your RAID configuration for future use. This will help you monitor and correct md-device naming, otherwise you will get device names like md126 and md127. You can save your configuration file by running the following command: 


mdadm --detail --scan >> /etc/mdadm.conf

Para Ubuntu:
/etc/mdadm/mdadm.conf

 

Monitorear un dispositivo RAID

You can proactively monitor the health of a RAID device using -monitor in the mdadm tool. If mdadm detects an array health issue, it can do a host of actions you specify in the command line. It can send an email, run a specified program, or send a message to the system log to name a few. Read the manual in hombre mdadm (Monitor section) to see a list of options.

Most Linux distributions provide wrappers for the mdadm –monitor. CentOS / RHEL for example, provides an mdmonitor service, which you can set to start automatically with the system by running chkconfig mdmonitor en.

Another way to check device health is to look into the /proc/mdstat text file para ver qué arrays reconoce y ve su kernel para ver sus respectivos estados.

 

Reemplazando la unidad de componente de un dispositivo RAID

Para reemplazar una unidad (por ejemplo (/dev/sdb1) in an active RAID array, it first needs to marked as ‘faulty’ by the kernel—marked as (F) in the /proc/mdstat. If it is not yet marked as faulty, you must do the tagging yourself prior to removal. To do this, run mdadm /dev/md0 -f /dev/sdb1.

After the drive is removed, you can add another drive as replacement using mdadm /dev/md0 -a /dev/sdc1. Note that you can perform multiple operations with this one command—e.g. mdadm /dev/md0 -f /dev/sdb1 -r /dev/sdb1 -a /dev/sdc1.

Check the contents of the /proc/mdstat file después para ver si todo fue como se esperaba. La operación fue como debería si mdadm no producira ningún error de salida durante el reemplazo.

 

Destruir un dispositivo RAID

Puede haber un tiempo cuando necesite destruir completamente un dispositivo RAID para hacer que los dispositivos subyacentes sean utilizables para el sistema. Una situación en la que esto es plausible es si tienes un HDD de repuesto con metadatos RAID preconfigurados y tu kernel reconoce el array. En este caso, sólo hay un miembro en el array y no es posible simplemente quitar el único disco.

To destroy the RAID device, you first need to stop the array with mdadm -S /dev/md0. The next step is to remove the metadata from the sda1 partition by issuing the command mdadm --zero-superblock /dev/sda1. Recuerde traer los metadatos/dev/sda1 (not /dev/sda) a cero (0) si es parte de un array.

 

Referencias:

← Todos los artículos de base de conocimientos

Díganos qué tiene que estar levantado.

A short conversation with an engineer. No quote-bot, no callback queue. We'll tell you honestly if we're not the right fit.