mdadm命令详解及实验过程.docx
- 文档编号:29675523
- 上传时间:2023-07-26
- 格式:DOCX
- 页数:10
- 大小:21.69KB
mdadm命令详解及实验过程.docx
《mdadm命令详解及实验过程.docx》由会员分享,可在线阅读,更多相关《mdadm命令详解及实验过程.docx(10页珍藏版)》请在冰豆网上搜索。
mdadm命令详解及实验过程
mdadm命令详解及实验过程
一.概念
mdadm是multipledevicesadmin的简称,它是Linux下的一款标准的软件RAID管理工具,作者是NeilBrown
二.特点
mdadm能够诊断、监控和收集详细的阵列信息
mdadm是一个单独集成化的程序而不是一些分散程序的集合,所以对不同RAID管理命令有共通的语法
mdadm能够执行几乎所有的功能而不需要配置文件(也没有默认的配置文件)
三.作用 (引用)
据不会因为某个块设备的故障而完全丢失,而且还能在设备被替换后将丢失的数据恢复到新的设备上.
当前MD支持linear,multipath,raid0(stripping),raid1(mirror),raid4,raid5,raid6,raid10等不同的冗余级别和级成方式,当然也能支持多个RAID陈列的层叠组成raid10,raid51等类型的陈列
四.实验
试题:
建立4个大小为1G的磁盘,并将其中3个创建为raid5的阵列磁盘,1个为热备份磁盘。
测试热备份磁盘替换阵列中的磁盘并同步数据。
移除损坏的磁盘,添加一个新磁盘作为热备份磁盘。
最后要求开机自动挂载。
4.1创建磁盘
[root@xiao~]#fdisk/dev/sda
WARNING:
DOS-compatiblemodeisdeprecated.It'sstronglyrecommendedto
switchoffthemode(command'c')andchangedisplayunitsto
sectors(command'u').
Command(mforhelp):
n
Firstcylinder(10486-13054,default10486):
Usingdefaultvalue10486
Lastcylinder,+cylindersor+size{K,M,G}(10486-13054,default13054):
+1G
Command(mforhelp):
n
Firstcylinder(10618-13054,default10618):
Usingdefaultvalue10618
Lastcylinder,+cylindersor+size{K,M,G}(10618-13054,default13054):
+1G
Command(mforhelp):
n
Firstcylinder(10750-13054,default10750):
Usingdefaultvalue10750
Lastcylinder,+cylindersor+size{K,M,G}(10750-13054,default13054):
+1G
Command(mforhelp):
n
Firstcylinder(10882-13054,default10882):
Usingdefaultvalue10882
Lastcylinder,+cylindersor+size{K,M,G}(10882-13054,default13054):
+1G
Command(mforhelp):
t
Partitionnumber(1-8):
8
Hexcode(typeLtolistcodes):
fd
Changedsystemtypeofpartition8tofd(Linuxraidautodetect)
Command(mforhelp):
t
Partitionnumber(1-8):
7
Hexcode(typeLtolistcodes):
fd
Changedsystemtypeofpartition7tofd(Linuxraidautodetect)
Command(mforhelp):
t
Partitionnumber(1-8):
6
Hexcode(typeLtolistcodes):
fd
Changedsystemtypeofpartition6tofd(Linuxraidautodetect)
Command(mforhelp):
t
Partitionnumber(1-8):
5
Hexcode(typeLtolistcodes):
fd
Changedsystemtypeofpartition5tofd(Linuxraidautodetect)
Command(mforhelp):
p
Disk/dev/sda:
107.4GB,107374182400bytes
255heads,63sectors/track,13054cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):
512bytes/512bytes
I/Osize(minimum/optimal):
512bytes/512bytes
Diskidentifier:
0x0008ed57
DeviceBoot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition1doesnotendoncylinderboundary.
/dev/sda2 26 10225 81920000 83 Linux
/dev/sda3 10225 10486 2097152 82 Linuxswap/Solaris
/dev/sda4 10486 13054 20633279 5 Extended
/dev/sda5 10486 10617 1058045 fd Linuxraidautodetect
/dev/sda6 10618 10749 1060258+ fd Linuxraidautodetect
/dev/sda7 10750 10881 1060258+ fd Linuxraidautodetect
/dev/sda8 10882 11013 1060258+ fd Linuxraidautodetect
Command(mforhelp):
w
Thepartitiontablehasbeenaltered!
Callingioctl()tore-readpartitiontable.
WARNING:
Re-readingthepartitiontablefailedwitherror16:
设备或资源忙.
Thekernelstillusestheoldtable.Thenewtablewillbeusedat
thenextrebootorafteryourunpartprobe(8)orkpartx(8)
Syncingdisks.
4.2加载内核
[root@xiao~]#partx-a/dev/sda5/dev/sda
[root@xiao~]#partx-a/dev/sda6/dev/sda
[root@xiao~]#partx-a/dev/sda7/dev/sda
[root@xiao~]#partx-a/dev/sda8/dev/sda
4.3创建raid5及其热备份盘
[root@xiao~]#mdadm-C/dev/md0-l5-n3-x1 /dev/sda{5,6,7,8}
mdadm:
/dev/sda5appearstobepartofaraidarray:
level=raid5devices=3ctime=WedDec1700:
58:
242019
mdadm:
/dev/sda6appearstobepartofaraidarray:
level=raid5devices=3ctime=WedDec1700:
58:
242019
mdadm:
/dev/sda7appearstobepartofaraidarray:
level=raid5devices=3ctime=WedDec1700:
58:
242019
mdadm:
/dev/sda8appearstobepartofaraidarray:
level=raid5devices=3ctime=WedDec1700:
58:
242019
Continuecreatingarray?
y
mdadm:
Defaultingtoversion1.2metadata
mdadm:
array/dev/md0started.
4.4初始化时间和磁盘阵列的读写的应用相关,使用cat/proc/mdstat信息查询RAID阵列当前重构的速度和预期的完成时间。
[root@xiao~]#cat/proc/mdstat
Personalities:
[raid1][raid0][raid6][raid5][raid4]
md0:
activeraid5sda7[4]sda8[3](S)sda6[1]sda5[0]
2113536blockssuper1.2level5,512kchunk,algorithm2[3/2][UU_]
[=========>...........] recovery=45.5%(482048/1056768)finish=0.3minspeed=30128K/sec
unuseddevices:
[root@xiao~]#cat/proc/mdstat
Personalities:
[raid1][raid0][raid6][raid5][raid4]
md0:
activeraid5sda7[4]sda8[3](S)sda6[1]sda5[0]
2113536blockssuper1.2level5,512kchunk,algorithm2[3/3][UUU]
unuseddevices:
4.5挂载raid到/mnt目录下,并查看是否正常(显示lost+found为正常)
[root@xiao~]#mount/dev/md0/mnt
[root@xiao~]#ls/mnt
lost+found
4.6查看raid阵列的详细信息
[root@xiao~]#mdadm-D/dev/md0
/dev/md0:
Version:
1.2
CreationTime:
WedDec1703:
38:
082019
RaidLevel:
raid5
ArraySize:
2113536(2.02GiB2.16GB)
UsedDevSize:
1056768(1032.17MiB1082.13MB)
RaidDevices:
3
TotalDevices:
4
Persistence:
Superblockispersistent
UpdateTime:
WedDec1703:
55:
112019
State:
clean
ActiveDevices:
3
WorkingDevices:
4
FailedDevices:
0
SpareDevices:
1
Layout:
left-symmetric
ChunkSize:
512K
Name:
xiao:
0 (localtohostxiao)
UUID:
bce110f2:
34f3fbf1:
8de472ed:
633a374f
Events:
18
Number Major Minor RaidDeviceState
0 8 5 0 activesync /dev/sda5
1 8 6 1 activesync /dev/sda6
4 8 7 2 activesync /dev/sda7
3 8 8 - spare /dev/sda8
4.7模拟损坏其中的一个磁盘,这里我选择 /dev/sda6磁盘
[root@xiao~]#mdadm/dev/md0--fail/dev/sda6
mdadm:
set/dev/sda6faultyin/dev/md0
4.7查看raid阵列详细信息,发现/dev/sda8自动替换了损坏的/dev/sda6磁盘。
[root@xiao~]#mdadm-D/dev/md0
/dev/md0:
Version:
1.2
CreationTime:
WedDec1703:
38:
082019
RaidLevel:
raid5
ArraySize:
2113536(2.02GiB2.16GB)
UsedDevSize:
1056768(1032.17MiB1082.13MB)
RaidDevices:
3
TotalDevices:
4
Persistence:
Superblockispersistent
UpdateTime:
WedDec1704:
13:
592019
State:
clean,degraded,recovering
ActiveDevices:
2
WorkingDevices:
3
FailedDevices:
1
SpareDevices:
1
Layout:
left-symmetric
ChunkSize:
512K
RebuildStatus:
43%complete
Name:
xiao:
0 (localtohostxiao)
UUID:
bce110f2:
34f3fbf1:
8de472ed:
633a374f
Events:
26
Number Major Minor RaidDeviceState
0 8 5 0 activesync /dev/sda5
3 8 8 1 sparerebuilding /dev/sda8
4 8 7 2 activesync /dev/sda7
1 8 6 - faulty /dev/sda6
[root@xiao~]#cat/proc/mdstat
Personalities:
[raid1][raid0][raid6][raid5][raid4]
md0:
activeraid5sda7[4]sda8[3]sda6[1](F)sda5[0]
2113536blockssuper1.2level5,512kchunk,algorithm2[3/3][UUU] #正常的情况会是[UUU],若第一个磁盘损坏则显示[_UU].
4.8移除损坏的硬盘
[root@xiao~]#mdadm/dev/md0-r/dev/sda6
mdadm:
hotremoved/dev/sda6from/dev/md0
4.9添加一个新硬盘作为热备份盘
[root@xiao~]#fdisk/dev/sda
WARNING:
DOS-compatiblemodeisdeprecated.It'sstronglyrecommendedto
switchoffthemode(command'c')andchangedisplayunitsto
sectors(command'u').
Command(mforhelp):
n
Firstcylinder(11014-13054,default11014):
Usingdefaultvalue11014
Lastcylinder,+cylindersor+size{K,M,G}(11014-13054,default13054):
+1G
Command(mforhelp):
t
Partitionnumber(1-9):
9
Hexcode(typeLtolistcodes):
fd
Changedsystemtypeofpartition9tofd(Linuxraidautodetect)
Command(mforhelp):
p
Disk/dev/sda:
107.4GB,107374182400bytes
255heads,63sectors/track,13054cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):
512bytes/512bytes
I/Osize(minimum/optimal):
512bytes/512bytes
Diskidentifier:
0x0008ed57
DeviceBoot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition1doesnotendoncylinderboundary.
/dev/sda2 26 10225 81920000 83 Linux
/dev/sda3 10225 10486 2097152 82 Linuxswap/Solaris
/dev/sda4 10486 13054 20633279 5 Extended
/dev/sda5 10486 10617 1058045 fd Linuxraidautodetect
/dev/sda6 10618 10749 1060258+ fd Linuxraidautodetect
/dev/sda7 10750 10881 1060258+ fd Linuxraidautodetect
/dev/sda8 10882 11013 1060258+ fd Linuxraidautodetect
/dev/sda9 11014 11145 1060258+ fd Linuxraidautodetect
Command(mforhelp):
w
Thepartitiontablehasbeenaltered!
Callingioctl()tore-readpartitiontable.
WARNING:
Re-readingthepartitiontablefailedwitherror16:
设备或资源忙.
Thekernelstillusestheoldtable.Thenewtablewillbeusedat
thenextrebootorafteryourunpartprobe(8)orkpartx(8)
Syncingdisks.
[root@xiao~]#partx-a/dev/sda9/dev/sda
[root@xiao~]#mdadm/dev/md0--add/dev/sda9
mdadm:
added/dev/sda9
[root@xiao~]#mdadm-D/dev/md0
/dev/md0:
Version:
1.2
CreationTime:
WedDec1703:
38:
082019
RaidLevel:
raid5
ArraySize:
2113536(2.02GiB2.16GB)
UsedDevSize:
1056768(1032.17MiB1082.13MB)
RaidDevices:
3
TotalDevices:
4
Persistence:
Superblockispersist
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- mdadm 命令 详解 实验 过程