已阅读5页,还剩21页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
mdadm命令详解及实验过程一.概念mdadm是multiple devices admin的简称,它是Linux下的一款标准的软件 RAID 管理工具,作者是Neil Brown二.特点mdadm能够诊断、监控和收集详细的阵列信息 mdadm是一个单独集成化的程序而不是一些分散程序的集合,因此对不同RAID管理命令有共通的语法 mdadm能够执行几乎所有的功能而不需要配置文件(也没有默认的配置文件)三.作用(引用)在linux系统中目前以MD(Multiple Devices)虚拟块设备的方式实现软件RAID,利用多个底层的块设备虚拟出一个新的虚拟设备,并且利用条带化(stripping)技术将数据块均匀分布到多个磁盘上来提高虚拟设备的读写性能,利用不同的数据冗祭算法来保护用户数据不会因为某个块设备的故障而完全丢失,而且还能在设备被替换后将丢失的数据恢复到新的设备上.目前MD支持linear,multipath,raid0(stripping),raid1(mirror),raid4,raid5,raid6,raid10等不同的冗余级别和级成方式,当然也能支持多个RAID陈列的层叠组成raid1 0,raid5 1等类型的陈列四.实验试题:建立4个大小为1G的磁盘,并将其中3个创建为raid5的阵列磁盘,1个为热备份磁盘。测试热备份磁盘替换阵列中的磁盘并同步数据。移除损坏的磁盘,添加一个新磁盘作为热备份磁盘。最后要求开机自动挂载。4.1创建磁盘rootxiao # fdisk /dev/sdaWARNING: DOS-compatible mode is deprecated. Its strongly recommended to switch off the mode (command c) and change display units to sectors (command u).Command (m for help): nFirst cylinder (10486-13054, default 10486):Using default value 10486Last cylinder, +cylinders or +sizeK,M,G (10486-13054, default 13054): +1GCommand (m for help): nFirst cylinder (10618-13054, default 10618):Using default value 10618Last cylinder, +cylinders or +sizeK,M,G (10618-13054, default 13054): +1GCommand (m for help): nFirst cylinder (10750-13054, default 10750):Using default value 10750Last cylinder, +cylinders or +sizeK,M,G (10750-13054, default 13054): +1GCommand (m for help): nFirst cylinder (10882-13054, default 10882):Using default value 10882Last cylinder, +cylinders or +sizeK,M,G (10882-13054, default 13054): +1GCommand (m for help): tPartition number (1-8): 8Hex code (type L to list codes): fdChanged system type of partition 8 to fd (Linux raid autodetect)Command (m for help): tPartition number (1-8): 7Hex code (type L to list codes): fdChanged system type of partition 7 to fd (Linux raid autodetect)Command (m for help): tPartition number (1-8): 6Hex code (type L to list codes): fdChanged system type of partition 6 to fd (Linux raid autodetect)Command (m for help): tPartition number (1-8): 5Hex code (type L to list codes): fdChanged system type of partition 5 to fd (Linux raid autodetect)Command (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0008ed57 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 10225 81920000 83 Linux/dev/sda3 10225 10486 2097152 82 Linux swap / Solaris/dev/sda4 10486 13054 20633279 5 Extended/dev/sda5 10486 10617 1058045 fd Linux raid autodetect/dev/sda6 10618 10749 1060258+ fd Linux raid autodetect/dev/sda7 10750 10881 1060258+ fd Linux raid autodetect/dev/sda8 10882 11013 1060258+ fd Linux raid autodetectCommand (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 16: 设备或资源忙.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.4.2加载内核rootxiao # partx -a /dev/sda5 /dev/sdarootxiao # partx -a /dev/sda6 /dev/sdarootxiao # partx -a /dev/sda7 /dev/sdarootxiao # partx -a /dev/sda8 /dev/sda4.3创建raid5及其热备份盘rootxiao # mdadm -C /dev/md0 -l 5 -n 3 -x 1 /dev/sda5,6,7,8mdadm: /dev/sda5 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014mdadm: /dev/sda6 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014mdadm: /dev/sda7 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014mdadm: /dev/sda8 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014Continue creating array? ymdadm: Defaulting to version 1.2 metadatamdadm: array /dev/md0 started.4.4初始化时间和磁盘阵列的读写的应用相关,使用cat /proc/mdstat信息查询RAID阵列当前重构的速度和预期的完成时间。rootxiao # cat /proc/mdstatPersonalities : raid1 raid0 raid6 raid5 raid4md0 : active raid5 sda74 sda83(S) sda61 sda50 2113536 blocks super 1.2 level 5, 512k chunk, algorithm 2 3/2 UU_ =. recovery = 45.5% (482048/1056768) finish=0.3min speed=30128K/secunused devices: rootxiao # cat /proc/mdstatPersonalities : raid1 raid0 raid6 raid5 raid4md0 : active raid5 sda74 sda83(S) sda61 sda50 2113536 blocks super 1.2 level 5, 512k chunk, algorithm 2 3/3 UUUunused devices: 4.5挂载raid到/mnt目录下,并查看是否正常(显示lost+found为正常)rootxiao # mount /dev/md0 /mntrootxiao # ls /mntlost+found4.6查看raid阵列的详细信息rootxiao # mdadm -D /dev/md0/dev/md0: Version : 1.2 Creation Time : Wed Dec 17 03:38:08 2014 Raid Level : raid5 Array Size : 2113536 (2.02 GiB 2.16 GB) Used Dev Size : 1056768 (1032.17 MiB 1082.13 MB) Raid Devices : 3 Total Devices : 4 Persistence : Superblock is persistent Update Time : Wed Dec 17 03:55:11 2014 State : cleanActive Devices : 3Working Devices : 4Failed Devices : 0 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Name : xiao:0 (local to host xiao) UUID : bce110f2:34f3fbf1:8de472ed:633a374f Events : 18 Number Major Minor RaidDevice State 0 8 5 0 active sync /dev/sda5 1 8 6 1 active sync /dev/sda6 4 8 7 2 active sync /dev/sda7 3 8 8 - spare /dev/sda84.7模拟损坏其中的一个磁盘,这里我选择 /dev/sda6磁盘rootxiao # mdadm /dev/md0 -fail /dev/sda6mdadm: set /dev/sda6 faulty in /dev/md04.7查看raid阵列详细信息,发现/dev/sda8自动替换了损坏的/dev/sda6磁盘。rootxiao # mdadm -D /dev/md0/dev/md0: Version : 1.2 Creation Time : Wed Dec 17 03:38:08 2014 Raid Level : raid5 Array Size : 2113536 (2.02 GiB 2.16 GB) Used Dev Size : 1056768 (1032.17 MiB 1082.13 MB) Raid Devices : 3 Total Devices : 4 Persistence : Superblock is persistent Update Time : Wed Dec 17 04:13:59 2014 State : clean, degraded, recoveringActive Devices : 2Working Devices : 3Failed Devices : 1 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512KRebuild Status : 43% complete Name : xiao:0 (local to host xiao) UUID : bce110f2:34f3fbf1:8de472ed:633a374f Events : 26 Number Major Minor RaidDevice State 0 8 5 0 active sync /dev/sda5 3 8 8 1 spare rebuilding /dev/sda8 4 8 7 2 active sync /dev/sda7 1 8 6 - faulty /dev/sda6rootxiao # cat /proc/mdstatPersonalities : raid1 raid0 raid6 raid5 raid4md0 : active raid5 sda74 sda83 sda61(F) sda50 2113536 blocks super 1.2 level 5, 512k chunk, algorithm 2 3/3 UUU #正常的情况会是UUU,若第一个磁盘损坏则显示 _UU .4.8 移除损坏的硬盘rootxiao # mdadm /dev/md0 -r /dev/sda6mdadm: hot removed /dev/sda6 from /dev/md04.9添加一个新硬盘作为热备份盘rootxiao # fdisk /dev/sdaWARNING: DOS-compatible mode is deprecated. Its strongly recommended to switch off the mode (command c) and change display units to sectors (command u).Command (m for help): nFirst cylinder (11014-13054, default 11014):Using default value 11014Last cylinder, +cylinders or +sizeK,M,G (11014-13054, default 13054): +1GCommand (m for help): tPartition number (1-9): 9Hex code (type L to list codes): fdChanged system type of partition 9 to fd (Linux raid autodetect)Command (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0008ed57 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 10225 81920000 83 Linux/dev/sda3 10225 10486 2097152 82 Linux swap / Solaris/dev/sda4 10486 13054 20633279 5 Extended/dev/sda5 10486 10617 1058045 fd Linux raid autodetect/dev/sda6 10618 10749 1060258+ fd Linux raid autodetect/dev/sda7 10750 10881 1060258+ fd Linux raid autodetect/dev/sda8 10882 11013 1060258+ fd Linux raid autodetect/dev/sda9 11014 11145 1060258+ fd Linux raid autodetectCommand (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 16: 设备或资源忙.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.rootxiao # partx -a /dev/sda9 /dev/sdarootxiao # mdadm /dev/md0 -add /dev/sda9mdadm: added /dev/sda9rootxiao # mdadm -D /dev/md0/dev/md0: Version : 1.2 Creation Time : Wed Dec 17 03:38:08 2014 Raid Level : raid5 Array Size : 2113536 (2.02 GiB 2.16 GB) Used Dev Size : 1056768 (1032.17 MiB 1082.13 MB) Raid Devices : 3 Total Devices : 4 Persistence : Superblock is persistent Update Time : Wed Dec 17 04:39:35 2014 State : cleanActive Devices : 3Working Devices : 4Failed Devices : 0 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Name : xiao:0 (local to host xiao) UUID : bce110f2:34f3fbf1:8de472ed:633a374f Events : 41 Number Major Minor RaidDevice State 0 8 5 0 active sync /dev/sda5 3 8 8 1 active sync /dev/sda8 4 8 7 2 active sync /dev/sda7 5 8 9 - spare /dev/sda95.开机自动挂载编辑/etc/fsab文件/dev/md0/mntext3defaults0 0:wq6.mdadm中文man(引用)基本语法 : mdadm mode optionsmode 有7种:Assemble:将以前定义的某个阵列加入当前在用阵列。Build:Build a legacy array ,每个device 没有 superblocksCreate:创建一个新的阵列,每个device 具有 superblocksManage: 管理阵列,比如 add 或 removeMisc:允许单独对阵列中的某个 device 做操作,比如抹去superblocks 或 终止在用的阵列。Follow or Monitor:监控 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, -
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026中国能源建设集团云南省电力设计院有限公司招聘笔试考试备考试题及答案解析
- 2026年陕西省面向吉林大学招录选调生考试笔试参考题库附答案解析
- 2025江西兴宜技术服务有限公司招聘产数工程师3人笔试考试备考题库及答案解析
- 2025年淮北市消防救援支队公开招聘政府专职消防文员17人笔试考试参考试题及答案解析
- 2025年临沧高新技术产业开发区管理委员会招聘(4人)考试笔试参考题库附答案解析
- 2026陕西省面向中山大学招录选调生笔试考试备考试题及答案解析
- 2025城发环保能源有限公司巩义分公司招聘13人(河南)考试笔试备考题库及答案解析
- 2026中南大学湘雅三医院卫生专业技术人员招聘考试笔试模拟试题及答案解析
- 2025内蒙古工程项目管理有限公司招聘6人笔试考试参考题库及答案解析
- 2026广西医科大学第二附属医院护理人员招聘70人笔试考试参考题库及答案解析
- 放射科科室管理
- 数据岗位招聘笔试题与参考答案(某大型央企)2025年
- 三期梅毒性脑膜炎的护理
- KFC副经理工作汇报
- 2025年陕西省安全员《A证》考试题库及答案
- 2025年度中央机关公开遴选和公开选调公务员真题及答案解析
- 工厂废弃物回收利用方案
- 预算评审专项知识培训班课件
- 2025年银行贷款项目可行性研究报告内容
- 碎石厂管理知识培训课件
- 水晶培训知识课件
评论
0/150
提交评论