mdadm命令详解及实验过程_第1页
mdadm命令详解及实验过程_第2页
免费预览已结束,剩余29页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、mdadm 命令详解及实验过程一概念mdadm 是 multiple devices admin的简称,它是 Linux 下的一款标准的软件 RAID 管理工具,作者是二特点mdadm 能够诊断、监控和收集详细的阵列信息mdadm 是一个单独集成化的程序而不是一些分散程序的集合,所以对不同RAID 管理命令有共通的语法mdadm 能够执行几乎所有的功能而不需要配置文件(也没有默认的配置文件)三作用(引用)Neil Brown据不会因为某个块设备的故障而完全丢失,而且还能在设备被替换后将丢失的数据恢复到新的设备上当前 MD 支持 linear,multipath,raidO(stripping)

2、,raid1(mirror),raid4,raid5,raid6,raid10等不同的冗余级别和级成方式,当然也能支持多个 RAID 陈列的层叠组成 raidl 0,raid5 1 等类型的陈列四.实验试题:建立 4 个大小为 1G 的磁盘,并将其中 3 个创建为 raid5 的阵列磁盘,1 个为热备份磁盘。测试热备份磁盘替换阵列中的磁 盘并同步数据。移除损坏的磁盘,添加一个新磁盘作为热备份磁盘。最后要求开机自动挂载。4.1 创建磁盘rootxiao # fdisk /dev/sdaWARNING : DOS-compatible mode is deprecated. Its strongl

3、y recommended toswitch off the mode (comma nd c) and cha nge display un its to sectors (comma nd u).Comma nd (m for help)nFirst cyli nder (10486-13054, default 10486)Using default value 10486Last cylinder, +cylinders or +sizeK,M,G (10486-13054, default 13054)Comma nd (m for help): nFirst cyli nder (

4、10618-13054, default 10618):Using default value 10618Last cylinder, +cylinders or +sizeK,M,G (10618-13054, default 13054)Comma nd (m for help): nFirst cyli nder (10750-13054, default 10750):Using default value 10750Last cylinder, +cylinders or +sizeK,M,G (10750-13054, default 13054):+1G:+1G:+1GComma

5、 nd (m for help)nFirst cyli nder (10882-13054, default 10882)Using default value 10882Last cylinder, +cylinders or +sizeK,M,G (10882-13054, default 13054)Comma nd (m for help): tPartiti on number (1-8):8Hex code (type L to list codes) : fdChan ged system type of partiti on 8 to fd (Li nux raid autod

6、etect)Comma nd (m for help): tPartiti on number (1-8):7Hex code (type L to list codes) : fdChan ged system type of partiti on 7 to fd (Li nux raid autodetect):+1GComma nd (m for help)nPartiti on number (1-8): 6Hex code (type L to list codes) : fdChan ged system type of partiti on 6 to fd (Li nux rai

7、d autodetect)Comma nd (m for help): tPartiti on number (1-8): 5Hex code (type L to list codes) : fdChan ged system type of partiti on 5 to fd (Li nux raid autodetect)Comma nd (m for help): pDisk /dev/sda :107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cyli ndersComma nd (m for help)n

8、Units = cyli nders of 16065 * 512 = 8225280 bytesSector size (logical/physical)512 bytes / 512 bytesI/O size (mi nimum/optimal): 512 bytes / 512 bytesDisk ide ntifier :0 x0008ed57Device Boot StartEnd Blocks Id System/dev/sda1 *12620480083 LinuxPartiti on 1 does not end on cyli nder boun dary./dev/sd

9、a226102258192000083Linux/dev/sda31022510486209715282 Li nux swap / Solaris/dev/sda41048613054206332795 Exte nded/dev/sda510486106171058045fdLinux raid autodetect/dev/sda610618107491060258+fdLinux raid autodetect/dev/sda710750108811060258+fdLinux raid autodetectComma nd (m for help)n/dev/sda810882110

10、131060258+fdLinux raid autodetectComma nd (m for help)nThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING : Re-reading the partition table failed with error 16 The kernel still uses the old table. The new table will be used at the n ext rebootor after you run par

11、tprobe(8) or kpartx(8) Syncing disks.4.2 加载内核rootxiao # partx -a /dev/sda5 /dev/sdarootxiao # partx -a /dev/sda6 /dev/sda:设备或资源忙.rootxiao # partx -a /dev/sda7 /dev/sda rootxiao # partx -a /dev/sda8 /dev/sda4.3 创建 raid5 及其热备份盘rootxiao # mdadm -C /dev/mdO -l 5 -n 3 -x 1/dev/sda5,6,7,8mdadm : /dev/sda5

12、 appears to be part of a raid array:level=raid5 devices=3 ctime=Wed Dec 17 00: 58 : 24 2019mdadm : /dev/sda6 appears to be part of a raid array:level=raid5 devices=3 ctime=Wed Dec 17 00: 58 : 24 2019mdadm : /dev/sda7 appears to be part of a raid array:level=raid5 devices=3 ctime=Wed Dec 17 00: 58 :

13、24 2019mdadm : /dev/sda8 appears to be part of a raid array:level=raid5 devices=3 ctime=Wed Dec 17 00: 58 : 24 2019Con ti nue creat ing array? y mdadm : Defaulting to version 1.2 metadatamdadm : array /dev/mdO started.4.4 初始化时间和磁盘阵列的读写的应用相关,使用 cat /proc/mdstat信息查询 RAID 阵列当前重构的速度和预期的完成时间rootxiao # ca

14、t /proc/mdstatPerso nalities : raid1 raid0 raid6 raid5 raid4md0 : active raid5 sda74 sda83(S) sda61 sda502113536 blocks super 1.2 level 5, 512k chunk, algorithm 2 3/2 UU =. recovery = 45.5% (482048/1056768) fin ish=0.3min speed=30128K/secunu sed devices : rootxiao # cat /proc/mdstatPerso nalities :

15、raidl raidO raid6 raid5 raid4mdO : active raid5 sda74 sda83(S) sda61 sda502113536 blocks super 1.2 level 5, 512k chu nk, algorithm 2 3/3 UUUunu sed devices : 4.5 挂载 raid 到/mnt 目录下,并查看是否正常(显示 lost+found为正常)rootxiao # mount /dev/md0 /mntrootxiao # ls /mntlost+fo undPersiste nee: Superblock is persiste

16、 nt4.6 查看 raid 阵列的详细信息rootxiao # mdadm -D /dev/mdO/dev/mdOVersio n :1.2Creation Time : Wed Dec 17 03 : 38 : 08 2019Raid Level : raid5Array Size :2113536 (2.02 GiB 2.16 GB)Used Dev Size :1056768 (1032.17 MiB 1082.13 MB)Raid Devices :3Total Devices :4Update Time : Wed Dec 17 03 : 55 : 11 2019State : c

17、leanActive Devices :3Worki ng Devices: 4Failed Devices :0Spare Devices :1Layout : left-symmetricChu nk Size :512KName : xiao : 0 (local to host xiao)UUID : bce110f2 : 34f3fbf1 : 8de472edEve nts :18633a374fNumber MajorMin orRaidDevice State0850active sync/dev/sda51861active sync/dev/sda64872active sy

18、nc/dev/sda7388spare /dev/sda84.7 模拟损坏其中的一个磁盘,这里我选择/dev/sda6 磁盘rootxiao # mdadm /dev/mdO -fail /dev/sda6 mdadm : set /dev/sda6 faulty in /dev/mdO4.7 查看 raid 阵列详细信息,发现/dev/sda8自动替换了损坏的/dev/sda6rootxiao # mdadm -D /dev/md0 /dev/md0磁盘Versio n1.2Creatio n Time: Wed Dec 17 03 : 38 : 08 2019Raid Level :rai

19、d5Array Size :2113536 (2.02 GiB 2.16 GB)Used Dev Size:1056768 (1032.17 MiB 1082.13 MB)Raid Devices :3Total Devices:4Persiste neeSuperblock is persiste ntUpdate Time: Wed Dec 17 04 : 13 : 59 2019State :clea n, degraded, recoveri ngActive Devices:2Work ing Devices:3Failed DevicesSpare Devices :1Layout

20、 : left-symmetricChu nk Size :512KRebuild Status :43% completeName : xiao : 0 (local to host xiao)UUID : bce110f2 : 34f3fbf1 : 8de472ed : 633a374fEve nts :26Number MajorMin orRaidDevice State0850 active sync /dev/sda53881spare rebuildi ng/dev/sda84872active sync /dev/sda7186-faulty /dev/sda6rootxiao

21、 # cat /proc/mdstatPerso nalities : raidl raidO raid6 raid5 raid4mdO : active raid5 sda74 sda83 sda61(F) sda502113536 blocks super 1.2 level 5, 512k chu nk, algorithm 2 3/3 UUU_UU .4.8 移除损坏的硬盘rootxiao # mdadm /dev/md0 -r /dev/sda6 mdadm : hot removed /dev/sda6 from/dev/md0#正常的情况会是UUU,若第一个磁盘损坏则显示4.9

22、添加一个新硬盘作为热备份盘rootxiao # fdisk /dev/sdaWARNING : DOS-compatible mode is deprecated. Its strongly recommended toswitch off the mode (comma nd c) and cha nge display un its tosectors (comma nd u).Comma nd (m for help) : nFirst cyli nder (11014-13054, default 11014)Using default value 11014Last cyli nde

23、r, +cyli nders or +sizeK,M,G (11014-13054, default 13054):Comma nd (m for help) : tPartition number (1-9)+1GHex code (type L to list codes)fdChan ged system type of partiti on 9 to fd (Li nux raid autodetect)Comma nd (m for help): pDisk /dev/sda :107.4 GB, 107374182400 bytes255 heads, 63 sectors/tra

24、ck, 13054 cyli ndersUnits = cyli nders of 16065 * 512 = 8225280 bytesSector size (logical/physical) :512 bytes / 512 bytesI/O size (mi nimum/optimal): 512 bytes / 512 bytesDisk ide ntifier :0 x0008ed57Device Boot StartEnd Blocks Id System/dev/sda1 *12620480083 LinuxHex code (type L to list codes)fdP

25、artiti on 1 does not end on cyli nder boun dary./dev/sda226102258192000083Linux/dev/sda31022510486209715282 Li nux swap / Solaris/dev/sda41048613054206332795 Exte nded/dev/sda510486106171058045fdLinux raid autodetect/dev/sda610618107491060258+fdLinux raid autodetect/dev/sda710750108811060258+fdLinux

26、 raid autodetect/dev/sda810882110131060258+fdLinux raid autodetect/dev/sda911014111451060258+fdLinux raid autodetectComma nd (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING : Re-reading the partition table failed with error 16The kernel still us

27、es the old table. The new table will be used at the n ext reboot or after you run partprobe(8) or kpartx(8) Syncing disks.rootxiao # partx -a /dev/sda9 /dev/sdarootxiao # mdadm /dev/mdO -add /dev/sda9mdadm : added /dev/sda9rootxiao # mdadm -D /dev/mdO/dev/mdOVersio n :1.2Creation Time : Wed Dec 17 0

28、3 : 38 : 08 2019:设备或资源忙.Raid Level :raid5Array Size :2113536 (2.02 GiB 2.16 GB)Used Dev Size:1056768 (1032.17 MiB 1082.13 MB)Raid Devices:3Total Devices:4Persiste nee : Superblock is persiste ntUpdate Time: Wed Dec 17 04 : 39 : 35 2019State : eleanActive Devices:3Work ing Devices:4Failed Devices :0S

29、pare Devices:1Layout : left-symmetricChu nk Size:512KNamexiao :0(local to host xiao)UUID :bce110f2 :34f3fbf1 : 8de472ed : 633a374fEve nts :41NumberMajorMinor- RaidDevice State0 850active sync /dev/sda53881active sync /dev/sda84872active sync /dev/sda7589spare /dev/sda95开机自动挂载编辑/etc/fsab 文件/dev/mdO /

30、mnt ext3 defaults 0 0:wq6.mdadm 中文 man(引用)基本语法 : mdadm mode opti onsmode有 7 种:Assemble :将以前定义的某个阵列加入当前在用阵列。Build : Build a legacy array ,每个 device 没有 superblocksCreate :创建一个新的阵列,每个 device 具有 superblocksMan age : 管理阵列,比如 add 或 removeMisc :允许单独对阵列中的某个device 做操作,比如抹去 superblocks 或 终止在用的阵列。Follow or Mon

31、itor :监控 raid 1,4,5,6 和 multipath 的状态Grow :改变 raid 容量或阵列中的 device 数目可用的options:-A, -assemble:加入一个以前定义的阵列-B, -build : Build a legacy array without superblocks.-C, -create :创建一个新的阵列-Q, -query :查看一个 device,判断它为一个 md device 或是一个 md 阵列的一部分-D, -detail :打印一个或多个 md device 的详细信息-E, -examine :打印 device 上的 md superblock 的内容-F, -follow, -monitor:选择 Monitor 模式-G, -grow :改变在用阵列的大小或形态-h

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论