6-3、停止磁盘阵列(--stop)
[root@localhost ~]# mdadm -S /dev/md0
mdadm: stopped /dev/md0
注意:停止磁盘阵列前要从文件系统umount磁盘阵列;停止后,原组成阵列的磁盘将处于空闲状态,一旦误操作这些磁盘,将不能再 重启激活原阵列。
6-4、启动磁盘阵列(--assemble)
[root@localhost ~]# mdadm -A /dev/md0 /dev/sd{b,c,d}1
mdadm: /dev/md0 has been started with 3 drives.
因为上面配置了/etc/mdadm.conf文件,也可以用-s查找
[root@localhost ~]# mdadm -S /dev/md0
mdadm: stopped /dev/md0
[root@localhost ~]# mdadm -As /dev/md0
mdadm: /dev/md0 has been started with 3 drives.
6-5、检查磁盘属于哪个阵列(--examine)
[root@localhost ~]# mdadm -E /dev/sdb1
/dev/sdb1:
Magic : a92b4efc
Version : 0.90.00
UUID : 75e92985:cb128e1d:a99bce53:46f65900
Creation Time : Sat Aug 21 23:11:22 2010
Raid Level : raid0
Used Dev Size : 0
Raid Devices : 3
Total Devices : 3
Preferred Minor : 0
Update Time : Sat Aug 21 23:11:22 2010
State : active
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Checksum : 739a0841 - correct
Events : 1
Chunk Size : 64K
Number Major Minor RaidDevice State
this 0 8 17 0 active sync /dev/sdb1
0 0 8 17 0 active sync /dev/sdb1
1 1 8 33 1 active sync /dev/sdc1
2 2 8 49 2 active sync /dev/sdd1
6-6、删除和添加磁盘:mdadm可以在Manage模式下,对运行中的阵列进行删除和添加磁盘。常用于标识failed磁盘,增加spare(冗余)磁盘,以及替换磁盘等。
6-6-1、删除磁盘阵列
6-6-1a、查看目前磁盘状态
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 0.90
Creation Time : Sat Aug 21 23:11:22 2010
Raid Level : raid0
Array Size : 3132288 (2.99 GiB 3.21 GB)
Raid Devices : 3
Total Devices : 3
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Sat Aug 21 23:11:22 2010
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Chunk Size : 64K
UUID : 75e92985:cb128e1d:a99bce53:46f65900
Events : 0.1
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-6-1b、删除磁盘阵列
[root@localhost ~]# mdadm -S /dev/md0
mdadm: stopped /dev/md0
6-6-1c、修改/etc/mdadm.conf、/ect/fstab等配置文件的/dev/md0相关参数的地方去掉
6-6-2、创建新的磁盘阵列RAID1
[root@localhost ~]# mdadm -Cv /dev/md1 -l1 -n3 /dev/sd{b,c,d}1
mdadm: /dev/sdb1 appears to contain an ext2fs file system
size=3132288K mtime=Sat Aug 21 23:35:25 2010
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid0 devices=3 ctime=Sat Aug 21 23:11:22 2010
mdadm: /dev/sdc1 appears to be part of a raid array:
level=raid0 devices=3 ctime=Sat Aug 21 23:11:22 2010
mdadm: /dev/sdd1 appears to be part of a raid array:
level=raid0 devices=3 ctime=Sat Aug 21 23:11:22 2010
mdadm: size set to 1044096K
Continue creating array? y
mdadm: array /dev/md1 started.
查看磁盘阵列状态
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid0] [raid1]
md1 : active raid1 sdd1[2] sdc1[1] sdb1[0]
1044096 blocks [3/3] [UUU]
unused devices: <none>
配置 /etc/mdadm.conf文件:
[root@localhost ~]# echo DEVICE /dev/sd{b,c,d}1 >> /etc/mdadm.conf
[root@localhost ~]# mdadm --detail --scan >> /etc/mdadm.conf
查看磁盘阵列的详细信息
[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 16:53:57 2010
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
UUID : e8030aeb:b0324799:98ea885e:c1e1b507
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 2 active sync /dev/sdd1
6-6-3、移除磁盘:可以使用--fail参数指定坏磁盘,并移除该磁盘(--remove):(某些阵列模式,如raid0,是不能用--fail和--remove的)
[root@localhost ~]# mdadm /dev/md1 --fail /dev/sdc1 --remove /dev/sdc1
mdadm: set /dev/sdc1 faulty in /dev/md1
mdadm: hot removed /dev/sdc1
查看磁盘阵列的信息
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid0] [raid1]
md1 : active raid1 sdd1[2] sdb1[0]
1044096 blocks [3/2] [U_U]
unused devices: <none>
[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 : 2
Preferred Minor : 1
Persistence : Superblock is persistent
Update Time : Sun Aug 22 17:01:13 2010
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : e8030aeb:b0324799:98ea885e:c1e1b507
Events : 0.6
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 0 0 1 removed
2 8 49 2 active sync /dev/sdd1