raid空闲盘的热迁移

  1. yum install mdadm -y
   
  2.添加一个硬盘2G大小:划分分区并修改类型
如图所示:
Disk /dev/vdb: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1af5eb72

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1        4161     2097112+   5  Extended
/dev/vdb5               1         407      205065   fd  Linux raid autodetect
/dev/vdb6             408         814      205096+  fd  Linux raid autodetect
/dev/vdb7             815        1221      205096+  fd  Linux raid autodetect
/dev/vdb8            1222        1628      205096+  fd  Linux raid autodetect
/dev/vdb9            1629        2035      205096+  fd  Linux raid autodetect
/dev/vdb10           2036        2442      205096+  fd  Linux raid autodetect

  3.使用mdadm工具建立两个raid阵列:
   raid5:
      mdadm -C /dev/md0 -a yes -l5 -n3 /dev/vdb{5,6,7} -x1 /dev/vdb8
      其中/dev/vdb8/作为hotspare
   raid1:
      mdadm -C /dev/md1 -a yes -l1 -n2 /dev/vdb{9,10}

  4.保存到配置文件并修改:
   mdadm -D -s >>  /etc/mdadm.conf
   cat /etc/mdadm.conf
# mdadm.conf written out by anaconda
MAILADDR root
AUTO +imsm +1.x -all
ARRAY /dev/md0 metadata=1.2 spares=1 name=localhost.localdomain:0 UUID=e48e7f06:d574f908:a79bfff8:fecde120 auto=yes spare-group=share
ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=2ffc5690:5463747a:d4927e90:717dd851 auto=yes spare-group=share
   其中UUID后面时手动添加的
  开启监控服务:
    /etc/init.d/mdmonitor force-reload

  5.验证:
 raid1正常情况下,信息如下:
 /dev/md1:
        Version : 1.2
  Creation Time : Fri Feb 17 08:31:44 2012
     Raid Level : raid1
     Array Size : 205084 (200.31 MiB 210.01 MB)
  Used Dev Size : 205084 (200.31 MiB 210.01 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Fri Feb 17 08:32:29 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 2ffc5690:5463747a:d4927e90:717dd851
         Events : 17

    Number   Major   Minor   RaidDevice State
       0     252       25        0      active sync   /dev/vdb9
       1     252       26        1      active sync   /dev/vdb10

  我从raid1中去除/dev/sda10
  mdadm  /dev/md1 -f /dev/sdb10

  再看raid1的信息:
 /dev/md1:
        Version : 1.2
  Creation Time : Fri Feb 17 08:31:44 2012
     Raid Level : raid1
     Array Size : 205084 (200.31 MiB 210.01 MB)
  Used Dev Size : 205084 (200.31 MiB 210.01 MB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Fri Feb 17 08:42:24 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 1
  Spare Devices : 0

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 2ffc5690:5463747a:d4927e90:717dd851
         Events : 116

    Number   Major   Minor   RaidDevice State
       2     252       24        0      active sync   /dev/vdb8
       1     252       26        1      active sync   /dev/vdb10

       0     252       25        -      faulty spare   /dev/vdb9
 
  raid1,raid5中共享的热冗余盘/dev/vdb8自动迁移了过来,/dev/vdb9修复好后
有加为hotspare,注意的是要加在raid5中!这种迁移是单向的!

你可能感兴趣的:(linux,raid)