10、为阵列创建文件系统:
[root@rhel5 ~]# mkfs.ext3 /dev/md0
11、挂载分区
[root@rhel5 ~]#mount /dev/md0 /data
12、查看raid设备的状态
[root@rhel5 ~]#mdadm --detail /dev/md0
/dev/md0:
Version : 0.90
Creation Time : Mon Nov 12 11:55:51 2012
Raid Level : raid5
Array Size : 10485632 (10.00 GiB 10.74 GB)
Used Dev Size : 5242816 (5.00 GiB 5.37 GB)
Raid Devices : 3
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Mon Nov 12 12:52:34 2012
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 64K
UUID : 23542a8f:14e76650:90c202c4:b0bd7c76
Events : 0.14
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
2 8 48 2 active sync /dev/sdd
3 8 64 - spare /dev/sde
13、一般来说,一个新阵列被创建后我们最好创建一个/etc/mdadm.conf文件。没有该文件在激活阵列时我们就得指定更详细的信息,为方便,我们使用下列命令:
[root@rhel5 ~]#mdadm --detail --scan
ARRAY /dev/md0 level=raid5 num-devices=3 metadata=0.90 spares=1 UUID=23542a8f:14e76650:90c202c4:b0bd7c76
[root@rhel5 ~]#mdadm --detail --scan >> /etc/mdadm.conf
[root@rhel5 ~]#cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid5 num-devices=3 metadata=0.90 spares=1 UUID=23542a8f:14e76650:90c202c4:b0bd7c76
14、启动停止Raid(停止前必须先umount)
[root@rhel5 ~]#umount /data
[root@rhel5 ~]#mdadm -S /dev/md0
mdadm: stopped /dev/md0
重新启动可以使用:
[root@rhel5 ~]# mdadm -As /dev/md0
mdadm: /dev/md0 has been started with 3 drives and 1 spare.
15、模拟故障
[root@rhel5 ~]#mdadm --set-faulty --help
Usage: mdadm arraydevice options component devices...
This usage is for managing the component devices within an array.
The --manage option is not needed and is assumed if the first argument
is a device name or a management option.
The first device listed will be taken to be an md array device, and
subsequent devices are (potential) components of that array.
Options that are valid with management mode are:
--add -a : hotadd subsequent devices to the array
--remove -r : remove subsequent devices, which must not be active
--fail -f : mark subsequent devices a faulty
--set-faulty : same as --fail
--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
模拟/dev/sdb故障:
[root@rhel5 ~]#mdadm --manage --set-faulty /dev/md0 /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md0
[root@rhel5 ~]#mdadm --detail /dev/md0
/dev/md0:
Version : 0.90
Creation Time : Mon Nov 12 11:55:51 2012
Raid Level : raid5
Array Size : 10485632 (10.00 GiB 10.74 GB)
Used Dev Size : 5242816 (5.00 GiB 5.37 GB)
Raid Devices : 3
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Mon Nov 12 13:48:19 2012
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 3
Failed Devices : 1
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 64K
Rebuild Status : 13% complete
UUID : 23542a8f:14e76650:90c202c4:b0bd7c76
Events : 0.16
Number Major Minor RaidDevice State
4 8 64 0 spare rebuilding /dev/sde
1 8 32 1 active sync /dev/sdc
2 8 48 2 active sync /dev/sdd
3 8 16 - faulty spare /dev/sdb
检查/proc/mdstat,如果配置的冗余磁盘可用,阵列可能已经开始重建
[root@rhel5 ~]#cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdb[3](F) sde[4] sdd[2] sdc[1]
10485632 blocks level 5, 64k chunk, algorithm 2 [3/2] [_UU]
[=========>...........] recovery = 48.6% (2549344/5242816) finish=1.0min speed=42230K/sec
unused devices: <none>
