Linux 软Raid创建方法:
一。Raid 0 创建
# mdadm -C /dev/md0 -n 2 -a yes -l 0 -x /dev/sdb1 /dev/sdb2 /dev/sdb3[创建Raid 0 ,其中-C 创建, -n 指定磁盘块数, -a You haven‘t given enough devices (real or missing) to create this array, -x 指定空闲盘个数]
2. 查看
#mdadm -D /dev/md0
#cat /proc/mdstat
3. 模拟磁盘故障
#mdadm /dev/md0 -f|--fail /dev/sdb1
root@cnshla02 ~]# mdadm /dev/md0 -f /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
[root@cnshla02 ~]# madam -D /dev/md0
-bash: madam: command not found
[root@cnshla02 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Apr 26 07:19:59 2014
Raid Level : raid5
Array Size : 2117632 (2.02 GiB 2.17 GB)
Used Dev Size : 1058816 (1034.17 MiB 1084.23 MB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Sat Apr 26 07:30:41 2014
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 1
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Name : cnshla02.la.com:0 (local to host cnshla02.la.com)
UUID : 32d58274:62d5e406:7a0cbd5d:5cd42c00
Events : 37
Number Major Minor RaidDevice State
3 8 22 0 active sync /dev/sdb6
1 8 18 1 active sync /dev/sdb2
4 8 19 2 active sync /dev/sdb3
0 8 17 - faulty spare /dev/sdb1
4.剔除故障磁盘
root@cnshla02 ~]# mdadm /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1 from /dev/md0
5.添加磁盘到指定的raid
[root@cnshla02 ~]# mdadm /dev/md0 -a /dev/sdb1
mdadm: added /dev/sdb1