Linux的軟RAID

byfree發表於2008-04-23

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.9-55.EL #1 Fri Apr 20 16:35:59 EDT 2007 i686 i686 i386 GNU/Linux
1.檢視是否已有mdadm包:
[root@localhost ~]# rpm -qa|grep mdadm
mdadm-1.12.0-2

2.準備足夠用的盤或LV
準備好後可通過cat /proc/partitions檢視
[root@localhost ~]# cat /proc/partitions
major minor  #blocks  name

   3     0   78149687 hda
   3     1     104391 hda1
   3     2   78043770 hda2
  22     0   39082680 hdc
  22     1   16064968 hdc1
  22     2   23013112 hdc2
 253     0   76972032 dm-0
 253     1    1015808 dm-1
 253     2    5242880 dm-2
 253     3    5242880 dm-3
 253     4    5242880 dm-4
 253     5    5242880 dm-5
此處dm-2,dm-3,dm-4,dm-5為測試用的LV,大小均為5G

3.建立RAID1
[root@localhost /]# mdadm -C /dev/md0 -l1 -n2 /dev/vg01/lv{0,1}
mdadm: /dev/vg01/lv0 appears to contain an ext2fs file system
    size=20971392K  mtime=Wed Apr 23 11:06:43 2008
mdadm: /dev/vg01/lv1 appears to contain an ext2fs file system
    size=20971392K  mtime=Wed Apr 23 11:06:43 2008
Continue creating array?    
Continue creating array? (y/n) y
mdadm: array /dev/md0 started.
命令中:-l1表示建立raid1,-n2表示兩個裝置,最後是兩個LV的具體路徑。

檢視raid配置資訊:
[root@localhost /]# cat /proc/mdstat
md0 : active raid1 dm-3[1] dm-2[0]
      5242816 blocks [2/2] [UU]
      [=>...................]  resync =  6.3% (334720/5242816) finish=29.4min speed=2778K/sec

建立第二組RAID1:     
[root@localhost /]# mdadm -C /dev/md1 -l1 -n2 /dev/vg01/lv{2,3}
mdadm: /dev/vg01/lv3 appears to be part of a raid array:
    level=0 devices=2 ctime=Wed Apr 23 13:09:40 2008
Continue creating array? y
mdadm: array /dev/md1 started.

4.建立RAID10
[root@localhost /]# mdadm -C /dev/md2 -l0 -n2 /dev/md{0,1}
mdadm: /dev/md0 appears to contain an ext2fs file system
    size=20971392K  mtime=Wed Apr 23 11:06:43 2008
Continue creating array? y
mdadm: array /dev/md2 started.

檢視raid配置資訊:
[root@localhost /]# cat /proc/mdstat
Personalities : [raid0] [raid1] [raid5]
md2 : active raid0 md1[1] md0[0]
      10485504 blocks 64k chunks
     
md1 : active raid1 dm-5[1] dm-4[0]
      5242816 blocks [2/2] [UU]
      [>....................]  resync =  2.8% (151424/5242816) finish=31.0min speed=2732K/sec
md0 : active raid1 dm-3[1] dm-2[0]
      5242816 blocks [2/2] [UU]
      [=>...................]  resync =  6.3% (334720/5242816) finish=29.4min speed=2778K/sec
unused devices:

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17997/viewspace-249091/,如需轉載,請註明出處,否則將追究法律責任。

相關文章