http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID
RAID són les inicials de: Redundant Array of Independent Disks (matriu redundant de discs independents).
TODO
TODO:
With RAID 1, data is cloned on a duplicate disk. This RAID method is therefore frequently called disk mirroring. Think of telling two people the same story so that if one forgets some of the details you can ask the other one to remind you.
When one of the disks in the RAID set fails, the other one continues to function. When the failed disk is replaced, the data is automatically cloned to the new disk from the surviving disk. RAID 1 also offers the possibility of using a hot standby spare disk that will be automatically cloned in the event of a disk failure on any of the primary RAID devices.
RAID 1 offers data redundancy, without the speed advantages of RAID 0. A disadvantage of software-based RAID 1 is that the server has to send data twice to be written to each of the mirror disks. This can saturate data busses and CPU use. With a hardware-based solution, the server CPU sends the data to the RAID disk controller once, and the disk controller then duplicates the data to the mirror disks. This makes RAID-capable disk controllers the preferred solution when implementing RAID 1.
A limitation of RAID 1 is that the total RAID size in gigabytes is equal to that of the smallest disk in the RAID set. Unlike RAID 0, the extra space on the larger device isn't used.
RAID 1 is supported by Fedora Linux. Figure 26.1 illustrates the data allocation process in RAID 1.
Si parlem de RAID per hardware podeu executar:
$ lspci -nn | grep RAID
Un exemple:
$ lspci -nn | grep RAID 14:08.0 RAID bus controller [0104]: Hewlett-Packard Company Smart Array E200i (SAS Controller) [103c:3238]
Els drivers per programari suporten els següents tipus de RAID:
RAID-1:
RAID-4
RAID-5
http://usefulubuntu.blogspot.com/2009/03/raid-1-and-ubuntu-server-810.html
Instal·lació:
$ sudo apt-get install mdadm
Permet gestionar un raid de programari en Linux. Per disposar d'aquesta comanda cal tenir instal·lat:
$ whereis mdadm mdadm: /sbin/mdadm /etc/mdadm.conf /usr/share/man/man8/mdadm.8.gz $ dpkg -S /sbin/mdadm
També es pot buscar amb:
$ apt-cache search mdadm mdadm - tool to administer Linux MD arrays (software RAID)
Per instal·lar:
$ sudo apt-get install mdadm
A Ubuntu s'instal·la conjuntament amb Postfix ja que utilitza el correu electrònic per informar de possibles alertes.
Recursos
$ sudo apt-get install dmsetup mdadm
$ dpkg -L mdadm /. /sbin /sbin/mdadm /etc /etc/mdadm /etc/init.d /etc/init.d/mdadm /etc/cron.d /etc/cron.d/mdadm /etc/logcheck /etc/logcheck/ignore.d.server /etc/logcheck/ignore.d.server/mdadm /etc/logcheck/violations.d /etc/logcheck/violations.d/mdadm /usr /usr/share /usr/share/mdadm /usr/share/mdadm/mkconf /usr/share/mdadm/checkarray /usr/share/apport /usr/share/apport/package-hooks /usr/share/apport/package-hooks/source_mdadm.py /usr/share/initramfs-tools /usr/share/initramfs-tools/hooks /usr/share/initramfs-tools/hooks/mdadm /usr/share/initramfs-tools/scripts /usr/share/initramfs-tools/scripts/init-premount /usr/share/initramfs-tools/scripts/init-premount/mdadm /usr/share/bug /usr/share/bug/mdadm /usr/share/bug/mdadm/script /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/mdadm /usr/share/doc /usr/share/doc/mdadm /usr/share/doc/mdadm/FAQ.gz /usr/share/doc/mdadm/md.txt.gz /usr/share/doc/mdadm/README.checkarray /usr/share/doc/mdadm/README.Debian.gz /usr/share/doc/mdadm/rootraiddoc.97.html /usr/share/doc/mdadm/changelog.Debian.gz /usr/share/doc/mdadm/NEWS.Debian.gz /usr/share/doc/mdadm/TODO.Debian /usr/share/doc/mdadm/copyright /usr/share/doc/mdadm/examples /usr/share/doc/mdadm/examples/mdadm.conf-example /usr/share/doc/mdadm/examples/syslog-events /usr/share/doc/mdadm/examples/newdisk.gz /usr/share/doc/mdadm/changelog.gz /usr/share/doc/mdadm/TODO.gz /usr/share/doc/mdadm/README.recipes.gz /usr/share/doc/mdadm/RAID5_versus_RAID10.txt.gz /usr/share/doc-base /usr/share/doc-base/mdadm /usr/share/man /usr/share/man/man8 /usr/share/man/man8/mdadm.8.gz /usr/share/man/man4 /usr/share/man/man4/md.4.gz /usr/share/man/man5 /usr/share/man/man5/mdadm.conf.5.gz /var /var/lib /var/lib/mdadm /lib /lib/udev /lib/udev/rules.d /lib/udev/rules.d/85-mdadm.rules /lib/udev/rules.d/65-mdadm.vol_id.rules
Es poden consultar amb:
$ dpkg -L mdadm | grep etc /etc /etc/mdadm /etc/init.d /etc/init.d/mdadm /etc/cron.d /etc/cron.d/mdadm /etc/logcheck /etc/logcheck/ignore.d.server /etc/logcheck/ignore.d.server/mdadm /etc/logcheck/violations.d /etc/logcheck/violations.d/mdadm
El fitxer principal de configuració sol ser:
/etc/mdadm/mdadm.conf
NOTA: En alguns sistemes com OpenSuse el fitxer pot estar a /etc/mdadm.conf
NOTA: A alguns sistemes com OpenSuse és /etc/mdadm
Un exemple de fitxers do configuració:
# cat /etc/mdadm.conf DEVICE partitions ARRAY /dev/md0 level=unknown UUID=d0f8d39e:a64a8338:2a05684f:df56ff87 ARRAY /dev/md1 level=unknown UUID=f0fe6ee9:43a07b92:3cd54359:562c2dd1 ARRAY /dev/md2 level=raid0 UUID=24509369:d61a5db8:f831da14:3f59ae88
On:
DEVICE partitions --> DEVICE permet indicar quins dispositius de bloc es tenen en compte per a l'array. Els dispositius que no apareguin aquí no són utilitzats per mdadm Per defecte s'indica totes les particions (fins i tot si no apareix aquesta línia). Les particions s'obtenen de /proc/partitions
El fitxer principal de configuració és mdadm.conf
El format del fitxer és pot obtenir amb l'ordre:
$ sudo mdadm --detail --scan --verbose ARRAY /dev/md0 level=raid5 num-devices=4 UUID=77b695c4:32e5dd46:63dd7d16:17696e09 devices=/dev/hde1,/dev/hdf2,/dev/hdg1
El fitxer de configuració es pot crear amb la següent ordre:
$ sudo bash -c "mdadm --detail --scan --verbose > /etc/mdadm.conf"
$ mdadm --help mdadm is used for building, managing, and monitoring Linux md devices (aka RAID arrays) Usage: mdadm --create device options... Create a new array from unused devices. mdadm --assemble device options... Assemble a previously created array. mdadm --build device options... Create or assemble an array without metadata. mdadm --manage device options... make changes to an existing array. mdadm --misc options... devices report on or modify various md related devices. mdadm --grow options device resize/reshape an active array mdadm --incremental device add a device to an array as appropriate mdadm --monitor options... Monitor one or more array for significant changes. mdadm device options... Shorthand for --manage. Any parameter that does not start with '-' is treated as a device name or, for --examine-bitmap, a file name. The first such name is often the name of an md device. Subsequent names are often names of component devices. For detailed help on the above major modes use --help after the mode e.g. mdadm --assemble --help For general help on options use mdadm --help-options
El primer pas és crear el disc del que volem fer un mirror.
$ sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 missing
NOTA: level igual a 1 indica que el RAID és de tipus RAID-1
Si volguéssim crear un altre disc, per exemple sdb1:
$ sudo mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb1 missing
Ara afegim els mirrrors:
$ sudo mdadm --manage --add /dev/md0 /dev/sdc1 $ sudo mdadm --manage --add /dev/md1 /dev/sdd1
$ sudo mdadm --examine --scan ARRAY /dev/md0 level=raid1 num-devices=2 UUID=d0f8d39e:a64a8338:2a05684f:df56ff87 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=f0fe6ee9:43a07b92:3cd54359:562c2dd1 ARRAY /dev/md/2 level=raid0 metadata=1.0 num-devices=2 UUID=24509369:d61a5db8:f831da14:3f59ae88 name=2
Primer cal trobar l'array al sistema realitzant un scan:
$ sudo apt-get install mdadm $ sudo mdadm --examine --scan ARRAY /dev/md/0 level=raid1 metadata=1.0 num-devices=2 UUID=f18fe92b:32402bed:43a96742:218cdb0b name=0
En aquest cas s'ha trobat un array (/dev/md0) de dos dispositius (dos particions) de tipus RAID 1. Ara el problema serà que no existeix el dispositiu /dev/mdo, primer cal fer un assemble:
$ sudo mdadm --detail --scan --verbose
i després activar:
$ sudo mdadm -A -s mdadm: /dev/md/0 has been started with 1 drive (out of 2). mdadm: /dev/md/2 has been started with 1 drive (out of 2).
A l'exemple veureu que estem recuperant el sistema a partir de un sol disc.
I ara ja podeu muntar les dades:
$ sudo mkdir p $ sudo mount /dev/md0 p
$ cat /proc/mdstat Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md1 : active raid1 sdf1[1] sdd1[0] 244195904 blocks [2/2] [UU] md0 : active raid1 sde1[1] sdc1[0] 244195904 blocks [2/2] [UU] unused devices: <none>
Les dos U indiquen que el RAID funciona correctament.
POdem simular un error amb:
$ mdadm --manage --fail /dev/md0 /dev/sda1 mdadm: set /dev/sde1 faulty in /dev/md0
Si tornem a consultar l'estat veurem:
$ cat /proc/mdstat Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md1 : active raid1 sdf1[1] sdd1[0] 244195904 blocks [2/2] [UU] md0 : active raid1 sde1[2](F) sdc1[0] 244195904 blocks [2/1] [U_]
Al md0 falla un disc (falta una U). Ara es tractaria de canviar el disc espatllat, i tornar a fer el mirroring:
$ mdadm --manage --remove /dev/md0 /dev/sda1 $ mdadm --manage --add /dev/md0 /dev/sda1
Podeu consultar l'estat del procés de mirroring executant
$ watch cat /proc/mdstat Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md1 : active raid1 sdf1[1] sdd1[0] 244195904 blocks [2/2] [UU] md0 : active raid1 sde1[2] sdc1[0] 244195904 blocks [2/1] [U_] [>....................] recovery = 0.1% (328128/244195904) finish=61.9min speed=65625K/sec unused devices: <none>
$ cat /etc/mdadm/mdadm.conf # mdadm.conf # # Please refer to mdadm.conf(5) for information about this file. # # by default, scan all partitions (/proc/partitions) for MD superblocks. # alternatively, specify devices to scan, using wildcards if desired. DEVICE partitions # auto-create devices with Debian standard permissions CREATE owner=root group=disk mode=0660 auto=yes # automatically tag new arrays as belonging to the local system HOMEHOST <system> # instruct the monitoring daemon where to send mail alerts MAILADDR root # This file was auto-generated on Thu, 15 Mar 2007 16:31:13 +0000 # by mkconf $Id: mkconf 261 2006-11-09 13:32:35Z madduck $
Recursos:
Sembla que són unes eines obsoltes. Es recomana utilitzar mdadm
$ sudo apt-get install raidtools2 S'està llegint la llista de paquets... Fet S'està construint l'arbre de dependències S'està llegint la informació de l'estat... Fet El paquet raidtools2 no té versió disponible, però un altre paquet en fa referència. Això normalment vol dir que el paquet falta, s'ha tornat obsolet o només és disponible des d'una altra font. E: El paquet raidtools2 no té candidat d'instal·lació
Segons la descripció del paquet:
Description: Device-Mapper Software RAID support tool dmraid discovers, activates, deactivates and displays properties of software RAID sets (eg, ATARAID) and contained DOS partitions. . dmraid uses the Linux device-mapper to create devices with respective mappings for the ATARAID sets discovered
Serveix per configurar RAIDS per software (fake RAID).
Per instal·lar l'eina:
$ sudo apt-get install dmraid
Per tal de detectar els RAIDS:
$ sudo dmraid -r no raid disks
L'anterior és un exemple en un sistema sense RAID. El següent en canvi:
$ sudo dmraid -r /dev/sdh: isw, "isw_bbegecfjae", GROUP, ok, 1953525166 sectors, [email protected] 0 /dev/sdg: isw, "isw_bbegecfjae", GROUP, ok, 1953525166 sectors, [email protected] 0
És un exemple amb RAID als discos sdh i sdg.
TODO
Cal fer un assemble:
$ sudo mdadm --assemble --scan
bootdegraded=true
Recursos: