Raid: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
KKeine Bearbeitungszusammenfassung
Zeile 103: Zeile 103:
[http://shsc.info/LinuxSoftwareRAID a guide to Linux software RAID under the 2.4 and 2.6 kernels]<br>
[http://shsc.info/LinuxSoftwareRAID a guide to Linux software RAID under the 2.4 and 2.6 kernels]<br>
[http://www.devil-linux.org/documentation/1.0.x/ch01s05.html Software Raid (little bit outdated)]<br>
[http://www.devil-linux.org/documentation/1.0.x/ch01s05.html Software Raid (little bit outdated)]<br>
[http://www.parisc-linux.org/faq/raidboot-howto.html PA-RISC Linux RAID1 Root HOWTO]
[http://www.parisc-linux.org/faq/raidboot-howto.html PA-RISC Linux RAID1 Root HOWTO]<br>
[http://emidio.planamente.ch/pages/linux_howto_root_lvm_raid.php Root on LVM on software RAID micro howto]

Version vom 25. Januar 2006, 12:23 Uhr

Hier geht es eigentlich um Software-Raid unter Linux. Unser Server hat zwei IDE-Platten (hda und hdb), die jeweils gespiegelt werden (raid1-Mirroring). Insgesamt hat jede Platte fünf 'Partitionen'. Für jede Partition gibt es ein 'virtuelles' Device, das man mountet. Über eine Konfiguration werden die Raid-Optionen eingestellt. Z.B. welches Raid-Level, wieviele Platten/Partitionen hängen am Raid, gibt es eine Not/Reserve-Platte usw.. Raid schützt 'NUR' gegen Hardwareauffall. Bei Datenverlust hilft nur ein Backup. Ein Backup sollte(muß) zusätzlich gemacht werden!

Besonders sollte noch beachtet werden, dass bei Sarge die md-Module nicht fest im Kernel enthalten sind, sondern als Modul. Das hat zur Folge, dass wenn man von einer Raid-Partition booten will, es erstmal kracht, da der Kernel keine Treiber fürs Raid hat. Lösung ist hier, die md-Module in die Initrd zu packen.

Wenn man nicht schon bei der Linux-Installation die Raid-Arrays erstellt hat, muss man die Einrichtung im Nachhinein machen. D.h. das System ist z. B. bereits auf der ersten Platte installiert und eine zweite(möglichst baugleich) fürs Raid kommt neu hinzu. Dann kann man sogar die Umstellung sogar fast unter laufenden Betrieb machen. Jedenfalls geht es remote über eine ssh-session ;-).

Dazu kopiert man die erste auf die zweite Platte:

  • Partitionstabelle (also die ersten 512 Blöcke der Festplatte) kopieren, z.b. mit
dd if=/dev/hda of=/dev/hdb count=512 bs=1 (OHNE GEWÄHR!!)

dann die Partitionen kopieren, hier hat sich rsync bewährt

rsync -ax /usr/ /mnt/md0/usr/ 

Commands

Proc/Status

Einen Schnellstatus bekommt man übers Proc-FS.

gretchen:/home/jonathan# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 hda2[0] hdb2[1]
      96320 blocks [2/2] [UU]

md3 : active raid1 hda3[0] hdb3[1]
      5855616 blocks [2/2] [UU]

md6 : active raid1 hda6[0] hdb6[1]
      64316096 blocks [2/2] [UU]

md1 : active raid1 hda1[0] hdb1[1]
      1951744 blocks [2/2] [UU]

md5 : active raid1 hda5[0] hdb5[1]
      7815488 blocks [2/2] [UU]

unused devices: <none>


Create Raid-Array

Create Raid: device will be md2, raidlevel is 1, overall 2 devices for this raiddevice, first (hda2) will come later, second is hdb2

mdadm --create /dev/md2 --level 1 --raid-devices=2 missing /dev/hdb2

After creating, save the information about the just created array(s)

echo 'DEVICE /dev/hd*' > /etc/mdadm/mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
#cat /etc/mdadm/mdadm.conf
DEVICE /dev/hda* /dev/hdb*
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=281866a2:081c9b2f:5ee8cab6:c0084d66
   devices=/dev/hda2,/dev/hdb2
ARRAY /dev/md3 level=raid1 num-devices=2 UUID=1edbcdf2:a8a30679:d1d91895:67f0721c
   devices=/dev/hda3,/dev/hdb3
ARRAY /dev/md6 level=raid1 num-devices=2 UUID=1f04467f:36e59a11:5260e589:fb3003bd
   devices=/dev/hda6,/dev/hdb6
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=d3271d85:39fe2f29:c6185d0f:2d89a548
   devices=/dev/hda1,/dev/hdb1
ARRAY /dev/md5 level=raid1 num-devices=2 UUID=e0b7c473:604c71c9:f8cc5281:fb1a5def
   devices=/dev/hda5,/dev/hdb5

attach the new partitions

attach the new partitions to the existing (degraded) RAID arrays:

mdadm /dev/md2 -a /dev/hda2

Print Info about raid-devices

This will find out if a given device is a raid array, or is part of one, and will provide brief information about the device.

gretchen:/home/jonathan# mdadm --query /dev/md2
/dev/md2: 94.06MiB raid1 2 devices, 0 spares. Use mdadm --detail for more detail.
/dev/md2: No md super block found, not an md component.

More information about an Array.

gretchen:/home/jonathan# mdadm --detail /dev/md2
/dev/md2:
        Version : 00.90.01
  Creation Time : Mon Oct 24 23:13:40 2005
     Raid Level : raid1
     Array Size : 96320 (94.06 MiB 98.63 MB)
    Device Size : 96320 (94.06 MiB 98.63 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 2
    Persistence : Superblock is persistent

    Update Time : Fri Jan 20 00:00:43 2006
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 281866a2:081c9b2f:5ee8cab6:12345678
         Events : 0.2297

    Number   Major   Minor   RaidDevice State
       0       3        2        0      active sync   /dev/hda2
       1       3       66        1      active sync   /dev/hdb2 

Links

Root System to Bootable Software RAID1 (Debian)
a guide to Linux software RAID under the 2.4 and 2.6 kernels
Software Raid (little bit outdated)
PA-RISC Linux RAID1 Root HOWTO
Root on LVM on software RAID micro howto