Recherche


imprimer pdf
Pour gerer le RAID SOFT, nous allons utiliser mdadm.

Attention: IL EST DANGEREUX DE JOUER AVEC MDADM LORSQU'ON
NE CONNAIT PAS BIEN SON FONCTIONNEMENT. VOUS RISQUEZ DE
PERDRE LES DONNEES. FAITES UN BACKUP AVANT DE COMMENCER
LA LECTURE DE GUIDE.

Note:
Si votre serveur vient de subir un changement de disque, celui ci vous est rendue avec un disque dans le RAID soft et un disque vierge qui ne contient aucune table de partition.
Il faut donc copier la partition du disque intact vers ce nouveau disque.

dans le cas du changement du SDA:

sfdisk -d /dev/sdb | sfdisk /dev/sda

dans le cas du changement du SDB:

sfdisk -d /dev/sda | sfdisk /dev/sdb


Comment voir quel disque n'as pas de partition?

fdisk -l


1.) Installation de MDADM

La suite des logiciels MDADM n'est pas installé par défaut
sur le serveur.

En release 1:

rpm -Uvh --nodeps ftp://ftp.ovh.net/made-in-ovh/sources/mdadm-2.5.5p1-1.i386.rpm
Retrieving ftp://ftp.ovh.net/made-in-ovh/sources/mdadm-2.5.5p1-1.i386.rpm
Preparing... ########################################### 100%
1:mdadm ########################################### 100%



2.) Aide

Pour avoir une aide complete, utilisez --help

# mdadm --misc --help
Usage: mdadm misc_option devices...

This usage is for performing some task on one or more devices, which
may be arrays or components, depending on the task.
The --misc option is not needed (though it is allowed) and is assumed
if the first argument in a misc option.

Options that are valid with the miscellaneous mode are:
--query -Q : Display general information about how a
device relates to the md driver
--detail -D : Display details of an array
--examine -E : Examine superblock on an array component
--examine-bitmap -X: Display contents of a bitmap file
--zero-superblock : erase the MD superblock from a device.
--run -R : start a partially built array
--stop -S : deactivate array, releasing all resources
--readonly -o : mark array as readonly
--readwrite -w : mark array as readwrite
--test -t : exit status 0 if ok, 1 if degrade, 2 if dead, 4 if missing



3.) Informations

Pour avoir les informations sur l'état du RAID utilisez
la commande --misc


  1. mdadm --misc --detail /dev/md1
/dev/md1:
Version : 00.90.00
Creation Time : Tue Nov 7 22:01:16 2006
Raid Level : raid1
Array Size : 3068288 (2.93 GiB 3.14 GB)
Device Size : 3068288 (2.93 GiB 3.14 GB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 1
Persistence : Superblock is persistent

Update Time : Wed Nov 8 15:42:35 2006
State : active, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

UUID : 4a9a446d:af55e24b:b311aa61:8dc74ed4
Events : 0.12

Number Major Minor RaidDevice? State
0 8 1 0 active sync /dev/sda1
1 0 0 1 removed


On voit qu'on a un RAID 1 de 3Go qui est en mode degradé
car il manque le disque sdb1

4.) ADD d'un disque en mode degradé

Voici un exemple des commandes, pour rajouter un disque dans un raid
en mode degradé:


  1. mdadm /dev/md1 --manage --add /dev/sdb1
mdadm: hot added /dev/sdb1


Le raid en reconstruction


  1. cat /proc/mdstat
Personalities : linear raid0 raid1 raid5
read_ahead 1024 sectors
md1 : active raid1 sdb12 sda10
3068288 blocks 2/1 U_
=>................... recovery = 5.4% (167028/3068288) finish=0.8min speed=55676K/sec
md2 : active raid1 sda20
240597376 blocks 2/1 U_



Au bout de quelques minutes la reconstruction a fini:


  1. mdadm --misc --detail /dev/md1
/dev/md1:
Version : 00.90.00
Creation Time : Tue Nov 7 22:01:16 2006
Raid Level : raid1
Array Size : 3068288 (2.93 GiB 3.14 GB)
Device Size : 3068288 (2.93 GiB 3.14 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 1
Persistence : Superblock is persistent

Update Time : Wed Nov 8 16:01:02 2006
State : active
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

UUID : 4a9a446d:af55e24b:b311aa61:8dc74ed4
Events : 0.14

Number Major Minor RaidDevice? State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1



Nous allons faire pareil sur md2:


  1. mdadm /dev/md2 --manage --add /dev/sdb2
mdadm: hot added /dev/sdb2


La reconstruction en cours:


  1. mdadm --misc --detail /dev/md2
/dev/md2:
Version : 00.90.00
Creation Time : Tue Nov 7 22:01:16 2006
Raid Level : raid1
Array Size : 240597376 (229.45 GiB 246.37 GB)
Device Size : 240597376 (229.45 GiB 246.37 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 2
Persistence : Superblock is persistent

Update Time : Wed Nov 8 16:06:43 2006
State : active, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1

Rebuild Status : 0% complete

UUID : e8754328:26f28599:8b834aba:ade37773
Events : 0.10

Number Major Minor RaidDevice? State
0 8 2 0 active sync /dev/sda2
1 0 0 1 removed

2 8 18 2 spare /dev/sdb2

  1. cat /proc/mdstat
Personalities : linear raid0 raid1 raid5
read_ahead 1024 sectors
md1 : active raid1 sdb11 sda10
3068288 blocks 2/2 UU

md2 : active raid1 sdb22 sda20
240597376 blocks 2/1 U_
>.................... recovery = 0.2% (655104/240597376) finish=73.2min speed=54592K/sec
unused devices: <none>




Vérifiez a la fin la taille de votre swap.

cat /proc/swaps
Filename Type Size Used Priority
/dev/sdb3 partition 522104 43984 -1


Il faut maintenant réajouter le swap du disque que vous vennez de formater et reajouter au RAID.

mkswap /dev/sda3
swapon -a

Vous pouvez voir avec la commande free que tout l'éspace swap est nouveau activé.