构建软RAID5磁盘阵列&RAID设备恢复-2


探索热备

查看md1的详细信息:

    [root@test2 jason]# mdadm -D /dev/md1
    /dev/md1:
    Version : 1.2
      Creation Time : Mon Jun 20 13:07:04 2016
     Raid Level : raid5
     Array Size : 6306816 (6.01 GiB 6.46 GB)
      Used Dev Size : 2102272 (2.00 GiB 2.15 GB)
       Raid Devices : 4
      Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon Jun 20 22:45:38 2016
      State : clean, degraded 
     Active Devices : 3
    Working Devices : 3
     Failed Devices : 0
      Spare Devices : 0

     Layout : left-symmetric
     Chunk Size : 512K

       Name : test2:1  (local to host test2)
       UUID : 8f4b5df4:f380ce6c:2ff605af:1b33ebcd
     Events : 25

    Number   Major   Minor   RaidDevice State
       0   000  removed
       1   8   821  active sync   /dev/sdf2
       2   8   982  active sync   /dev/sdg2
       5   8  1143  active sync   /dev/sdh2

从"Spare Devices : 0"可以看出来,创建热备的时候是没有创建成功的,所以当移除RAID当中一块逻辑盘的时候,并没有自动加入进来。


man mdadm

-x, --spare-devices=

Specify the number of spare (eXtra) devices in the initial array.Spares can also be added and removed later. The number of component devices listed on the command line must equal the number of RAID devices plus the number of spare devices.</font>

分析"Spares can also be added and removed later",也就是说,在已经创建好md1的前提下,是可以追加一个热备盘的。


man mdadm

Manage

This is for doing things to specific components of an array such as adding new spares and removing faulty devices.

-a, --add

hot-add listed devices. If a device appears to have recently been part of the array (possibly it failed or was removed) the device is re-added as described in the next point. If that fails or the device was never part of the array, the device is added as a hot-spare. If the array is degraded, it will immedi- ately start to rebuild data onto that spare.

Note that this and the following options are only meaningful on array with redundancy. They don’t apply to RAID0 or Linear.</font>

分析"If that fails or the device was never part of the array,the device is added as a hot-spare."也就是说新增加到RAID的逻辑盘不是RAID的成员,那么就会成为热备。


将原成员sde2重新添加到md1中

    [root@test2 jason]# mdadm --manage /dev/md1 -a /dev/sde2
    mdadm: added /dev/sde2

查看进度:

    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sde2[4] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]
      [===>.................]  recovery = 16.8% (353536/2102272) finish=1.3min speed=22096K/sec

    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sde2[4] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]
      [========>............]  recovery = 43.0% (905984/2102272) finish=0.9min speed=20831K/sec

    unused devices: 

添加完成:

    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sde2[4] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

    unused devices: 

将非md1成员sdc3加入到md1当中:

    [root@test2 jason]# mdadm --manage /dev/md1 -a /dev/sdc3
    mdadm: added /dev/sdc3

查看:

    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sdc3[6](S) sde2[4] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

    unused devices: 

可以看到sdc3[6](S),S代表spare(备用).

通过移除sde2来测试sdc3:

    [root@test2 jason]# mdadm /dev/md1 -f /dev/sde2
    mdadm: set /dev/sde2 faulty in /dev/md1
    [root@test2 jason]# mdadm /dev/md1 -r /dev/sde2
    mdadm: hot removed /dev/sde2 from /dev/md1

查看移除sde2后的状态:

    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sdc3[6] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]
      [========>............]  recovery = 40.6% (854528/2102272) finish=0.5min speed=37153K/sec

    unused devices: 
    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sdc3[6] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]
      [===================>.]  recovery = 98.5% (2072676/2102272) finish=0.0min speed=40297K/sec

    unused devices: 

热备sdc3自动添加完成:

    [root@test2 jason]# cat /proc/mdstat 
    Personalities : [raid6] [raid5] [raid4] 
    md1 : active raid5 sdc3[6] sdg2[2] sdh2[5] sdf2[1]
      6306816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

    unused devices: 




没有实现的:创建的同时增加热备



results matching ""

    No results matching ""