6-6-4、增加一个新磁盘到磁盘阵列中(某些阵列模式,如RAID0等,是不能用--add的)
[root@localhost ~]# mdadm /dev/md1 --add /dev/sdc1
mdadm: re-added /dev/sdc1
查看状态
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 0.90
Creation Time : Sun Aug 22 16:53:39 2010
Raid Level : raid1
Array Size : 1044096 (1019.80 MiB 1069.15 MB)
Used Dev Size : 1044096 (1019.80 MiB 1069.15 MB)
Raid Devices : 3
Total Devices : 3
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Sun Aug 22 17:06:33 2010
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
UUID : e8030aeb:b0324799:98ea885e:c1e1b507
Events : 0.8
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 2 active sync /dev/sdd1
6-7、新建两块磁盘的Raid1,增加一块热备盘
6-7-1、创建阵列,查询状态
[root@localhost ~]# mdadm -Cv /dev/md1 -l1 -n2 /dev/sd{b,c}1 -x1 /dev/sdd1
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid1 devices=2 ctime=Tue Aug 24 23:34:31 2010
mdadm: /dev/sdc1 appears to be part of a raid array:
level=raid1 devices=2 ctime=Tue Aug 24 23:34:31 2010
mdadm: /dev/sdd1 appears to be part of a raid array:
level=raid5 devices=3 ctime=Sun Aug 22 17:31:02 2010
mdadm: size set to 1044096K
Continue creating array? y
mdadm: array /dev/md1 started.
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 0.90
Creation Time : Tue Aug 24 23:44:07 2010
Raid Level : raid1
Array Size : 1044096 (1019.80 MiB 1069.15 MB)
Used Dev Size : 1044096 (1019.80 MiB 1069.15 MB)
Raid Devices : 2
Total Devices : 3
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Tue Aug 24 23:44:23 2010
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
UUID : 13cb5b8f:bcc55020:f58d3ef0:227ad6da
Events : 0.2
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 - spare /dev/sdd1
6-7-2、模拟故障,查看状态
[root@localhost ~]# mdadm /dev/md1 --set-faulty /dev/sdc1
mdadm: set /dev/sdc1 faulty in /dev/md1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 0.90
Creation Time : Tue Aug 24 23:44:07 2010
Raid Level : raid1
Array Size : 1044096 (1019.80 MiB 1069.15 MB)
Used Dev Size : 1044096 (1019.80 MiB 1069.15 MB)
Raid Devices : 2
Total Devices : 3
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Tue Aug 24 23:46:09 2010
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0
UUID : 13cb5b8f:bcc55020:f58d3ef0:227ad6da
Events : 0.6
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 49 1 active sync /dev/sdd1
2 8 33 - faulty spare /dev/sdc1
6-7-3、模拟移除/dev/sdc1,更换新盘,查看状态
[root@localhost ~]# mdadm /dev/md1 --remove /dev/sdc1
mdadm: hot removed /dev/sdc1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 0.90
Creation Time : Tue Aug 24 23:44:07 2010
Raid Level : raid1
Array Size : 1044096 (1019.80 MiB 1069.15 MB)
Used Dev Size : 1044096 (1019.80 MiB 1069.15 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Tue Aug 24 23:46:58 2010
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : 13cb5b8f:bcc55020:f58d3ef0:227ad6da
Events : 0.8
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 49 1 active sync /dev/sdd1
[root@localhost ~]# mdadm /dev/md1 --add /dev/sdc1
mdadm: added /dev/sdc1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 0.90
Creation Time : Tue Aug 24 23:44:07 2010
Raid Level : raid1
Array Size : 1044096 (1019.80 MiB 1069.15 MB)
Used Dev Size : 1044096 (1019.80 MiB 1069.15 MB)
Raid Devices : 2
Total Devices : 3
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Tue Aug 24 23:46:58 2010
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
UUID : 13cb5b8f:bcc55020:f58d3ef0:227ad6da
Events : 0.8
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 49 1 active sync /dev/sdd1
2 8 33 - spare /dev/sdc1
6-8、监控:在Follow或Monitor状态下,可以使用mdadm对阵列进行监控,例如当阵列出现问题的时候,发送邮件给管理员;或者当磁盘出现问题的时候进行自动的磁盘替换。
[root@localhost ~]# nohup mdadm --monitor --mail=sysadmin --delay=300 /dev/md1 &
上述定义:每300秒监控一次,当阵列出现错误,会发送邮件给sysadmin用户。由于monitor启动后是不会自动退出的,所以需要加上nohup和&,使之持续在后台运行。