




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
基本语法: mdadm mode options 目前支持: LINEAR, RAID0(striping), RAID1(mirroring), RAID4, RAID5, RAID6, RAID10, MULTIPATH和FAULTY模式(7种):Assemble:加入一个以前定义的阵列Build:创建一个没有超级块的阵列Create:创建一个新的阵列,每个设备具有超级块Manage: 管理阵列(如添加和删除)Misc:允许单独对阵列中的某个设备进行操作(如停止阵列)Follow or Monitor:监控RAID的状态Grow:改变RAID的容量或阵列中的设备数目选项:-A, -assemble:加入一个以前定义的阵列-B, -build:创建一个没有超级块的阵列(Build a legacy array without superblocks.)-C, -create:创建一个新的阵列-F, -follow, -monitor:选择监控(Monitor)模式-G, -grow:改变激活阵列的大小或形态-I, -incremental:添加一个单独的设备到合适的阵列,并可能启动阵列-auto-detect:请求内核启动任何自动检测到的阵列-h, -help:帮助信息,用在以上选项后,则显示该选项信息-help-options:显示更详细的帮助-V, -version:打印mdadm的版本信息-v, -verbose:显示细节-b, -brief:较少的细节。用于 -detail 和 -examine 选项-Q, -query:查看一个device,判断它为一个 md device 或是 一个 md 阵列的一部分-D, -detail:打印一个或多个 md device 的详细信息-E, -examine:打印 device 上的 md superblock 的内容-c, -config= :指定配置文件,缺省为 /etc/mdadm.conf-s, -scan:扫描配置文件或 /proc/mdstat以搜寻丢失的信息。配置文件/etc/mdadm.conf使用mdadm创建RAID5Create (mdadm -create)模式用来创建一个新的阵列。 在这里我们首先使用mdadm -create -help查看一下帮助:rootlocalhost mdadm-2.6.2# mdadm -create -helpUsage: mdadm -create device -chunk=X -level=Y -raid-devices=Z devicesThis usage will initialise a new md array, associate somedevices with it, and activate the array. In order to create anarray with some devices missing, use the special word missing inplace of the relevant device name.Before devices are added, they are checked to see if they already containraid superblocks or filesystems. They are also checked to see ifthe variance in device size exceeds 1%.If any discrepancy is found, the user will be prompted for confirmationbefore the array is created. The presence of a -run can override thiscaution.If the -size option is given then only that many kilobytes of eachdevice is used, no matter how big each device is.If no -size is given, the apparent size of the smallest drive givenis used for raid level 1 and greater, and the full device is used forother levels.Options that are valid with -create (-C) are: -bitmap= : Create a bitmap for the array with the given filename -chunk= -c : chunk size of kibibytes -rounding= : rounding factor for linear array (=chunk size) -level= -l : raid level: 0,1,4,5,6,linear,multipath and synonyms -parity= -p : raid5/6 parity algorithm: left,right-,asymmetric -layout= : same as -parity -raid-devices= -n : number of active devices in array -spare-devices= -x: number of spares (eXtras) devices in initial array -size= -z : Size (in K) of each drive in RAID1/4/5/6/10 - optional -force -f : Honour devices as listed on command line. Dont : insert a missing drive for RAID5. -run -R : insist of running the array even if not all : devices are present or some look odd. -readonly -o : start the array readonly - not supported yet. -name= -N : Textual name for array - max 32 characters -bitmap-chunk= : bitmap chunksize in Kilobytes. -delay= -d : bitmap update delay in seconds.接下来我们使用mdadm创建在/dev/md0上创建一个由sdb、sdc、sdd3块盘组成(另外1块盘sde为热备)的RAID5:rootlocalhost mdadm-2.6.2# mdadm -create -verbose /dev/md0 -level=raid5 -raid-devices=3 /dev/sdb /dev/sdc /dev/sdd -spare-devices=1 /dev/sdemdadm: layout defaults to left-symmetricmdadm: chunk size defaults to 64Kmdadm: size set to 8388544Kmdadm: array /dev/md0 started.每个mdadm的选项都有一个缩写的形式,例如,上面我们创建RAID 5的命令可以使用下列的缩写形式:rootlocalhost mdadm-2.6.2# mdadm -Cv /dev/md0 -l5 -n3 /dev/sdb /dev/sdc /dev/sdd -x1 /dev/sde二者的效果是相同的。切记:此处需建立配置文件,如果没有配置文件,在停止raid后就无法再激活rootmylab # echo DEVICE /dev/sdb5-8 /etc/mdadm.confrootmylab # mdadm -Ds /etc/mdadm.conf 没有配置文件的测试:rootmylab # mv /etc/mdadm.conf /etc/mdadm.conf.oldrootmylab # mdadm -S /dev/md0 mdadm: stopped /dev/md0rootmylab # mdadm -A /dev/md0 mdadm: /dev/md0 not identified in config file.rootmylab # mv /etc/mdadm.conf.old /etc/mdadm.confrootmylab # mdadm -A /dev/md0 mdadm: /dev/md0 has been started with 3 drives and 1 spare.查看RAID状态接下来我们使用cat /proc/mdstat命令来查看一下RAID的状态,我们也可以利用watch命令来每隔一段时间刷新/proc/mdstat的输出。使用CTRL+C可以取消。rootlocalhost mdadm-2.6.2# watch -n 10 cat /proc/mdstatEvery 10s: cat /proc/mdstat Thu May 24 11:53:46 2007Personalities : raid5read_ahead 1024 sectorsmd0 : active raid5 sdd4 sde3 sdc1 sdb0 16777088 blocks level 5, 64k chunk, algorithm 2 3/2 UU_ =. recovery = 24.0% (2016364/8388544) finish=10.2minspeed=10324K/secunused devices: rootlocalhost mdadm-2.6.2#接下来我们为阵列创建文件系统:rootlocalhost mdadm-2.6.2# mkfs.ext3 /dev/md0mke2fs 1.34 (25-Jul-2003)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)2097152 inodes, 4194272 blocks209713 blocks (5.00%) reserved for the super userFirst data block=0128 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000Writing inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 34 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.You have new mail in /var/spool/mail/root我们尝试向RAID中写入一个test2文件:rootlocalhost eric4ever# vi test2copy succeed!erictlfurl/urldone!rootlocalhost eric4ever# lsLATEST.tgz mdadm-2.6.2 test2rootlocalhost eric4ever# mount /dev/md0 /mnt/md0rootlocalhost eric4ever# df -lhFilesystem Size Used Avail Use% Mounted on/dev/sda1 2.9G 1.8G 1.1G 63% /dev/sda3 4.6G 33M 4.3G 1% /optnone 125M 0 125M 0% /dev/shm/dev/md0 16G 33M 15G 1% /mnt/md0rootlocalhost eric4ever# ls /mnt/md0lost+foundrootlocalhost eric4ever# cp ./test2 /mnt/md0rootlocalhost eric4ever# ls /mnt/md0lost+found test2rootlocalhost eric4ever# ls -lh /mnt/md0total 20Kdrwx- 2 root root 16K May 24 11:55 lost+found-rw-r-r- 1 root root 63 May 24 11:56 test2使用mdadm -detail /dev/md0(或mdadm -D /dev/md0)命令以及cat /proc/mdstat命令可以查看RAID设备的状态:rootlocalhost eric4ever# mdadm -D /dev/md0 (或mdadm -detail /dev/md0)/dev/md0: Version : 00.90.00 Creation Time : Thu May 24 13:45:35 2007 Raid Level : raid5 Array Size : 16777088 (16.00 GiB 17.18 GB) Used Dev Size : 8388544 (8.00 GiB 8.59 GB) Raid Devices : 3 Total Devices : 5Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Thu May 24 13:45:36 2007 State : active, degraded, recoveringActive Devices : 2Working Devices : 4Failed Devices : 1 Spare Devices : 2 Layout : left-symmetric Chunk Size : 64KRebuild Status : 16% complete UUID : 4b15050e:7d0c477d:98ed7d00:0f3c29e4 Events : 0.2 Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 2 0 0 2 removed 3 8 64 3 spare /dev/sde 4 8 48 4 spare /dev/sdd通过mdadm -D命令,我们可以查看RAID的版本、创建的时间、RAID级别、阵列容量、可用空间、设备数量、超级块、更新时间、各个设备的状态、RAID算法以及块大小等信息,通过上面的信息我们可以看到目前RAID正处于重建过程之中,进度为16%,其中/dev/sdb和/dev/sdc两块盘已经同步。使用watch命令每个30秒刷新一下查看的进度:rootlocalhost eric4ever# watch -n 30 cat /proc/mdstatEvery 30s: cat /proc/mdstat Thu May 24 13:55:56 2007Personalities : raid5read_ahead 1024 sectorsmd0 : active raid5 sdd4 sde3 sdc1 sdb0 16777088 blocks level 5, 64k chunk, algorithm 2 3/2 UU_ =. recovery = 72.3% (6067444/8388544) finish=3.7minspeed=10324K/secunused devices: 当进度进行到100%时,显示如下:Every 30s: cat /proc/mdstat Thu May 24 14:00:57 2007Personalities : raid5read_ahead 1024 sectorsmd0 : active raid5 sdd2 sde3 sdc1 sdb0 16777088 blocks level 5, 64k chunk, algorithm 2 3/3 UUUunused devices: 这是我们再使用mdadm -D命令查看一下:rootlocalhost eric4ever# mdadm -D /dev/md0 (或mdadm -detail /dev/md0)/dev/md0: Version : 00.90.00 Creation Time : Thu May 24 13:45:35 2007 Raid Level : raid5 Array Size : 16777088 (16.00 GiB 17.18 GB) Used Dev Size : 8388544 (8.00 GiB 8.59 GB) Raid Devices : 3 Total Devices : 5Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Thu May 24 13:59:48 2007 State : activeActive Devices : 3Working Devices : 4Failed Devices : 1 Spare Devices : 1 Layout : left-symmetric Chunk Size : 64K UUID : 4b15050e:7d0c477d:98ed7d00:0f3c29e4 Events : 0.3 Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 2 8 48 2 active sync /dev/sdd 3 8 64 3 spare /dev/sde这时我们可以发现sdb、sdc、sdd三块盘均已经同步。一般来说,一个新阵列被创建后我们最好创建一个/etc/mdadm.conf文件。没有该文件在激活阵列时我们就得指定更详细的信息,为方便,我们使用下列命令:rootlocalhost eric4ever# mdadm -detail -scanARRAY /dev/md0 level=raid5 num-devices=3 spares=1 UUID=4b15050e:7d0c477d:98ed7d00:0f3c29e4rootlocalhost eric4ever# mdadm -detail -scan /etc/mdadm.confrootlocalhost eric4ever# cat /etc/mdadm.confARRAY /dev/md0 level=raid5 num-devices=3 spares=1 UUID=4b15050e:7d0c477d:98ed7d00:0f3c29e4启动停止RAID使用-stop或-S命令选项可以停止运行的阵列(注意: 停止前必须先umount):rootlocalhost eric4ever# umount /mnt/md0rootlocalhost eric4ever# mdadm -S /dev/md0 (或mdadm -stop /dev/md0)mdadm: stopped /dev/md0重新启动可以使用:rootlocalhost eric4ever# mdadm -As /dev/md0mdadm: /dev/md0 has been started with 3 drives and 1 spare.注意:停止之前需要umount,然后mdadm S /dev/md0 启动:rootcentos /# mdadm -A /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 如果已经建立了配置文件,启动可使用命令mdadm As /dev/md0 为使系统reboot后能够自动挂载raid目录,需要修改/etc/fstab文件,加入如下一行:/dev/md0 /mnt/md0 ext3 defaults 0 0附:简单的故障模拟四、故障测试 1.测试前,在/mnt/radi下建立一个文件使用 rootcentos raid# ll / |tee ./ls.txt mdadm自带命令可以标记某块硬盘为损坏,参看帮助mdadm -manage h。 故障测试中,标记sda硬盘损坏 rootcentos /# mdadm /dev/md0 -f /dev/sda1 mdadm: set /dev/sda1 faulty in /dev/md0 2.查看状态 rootcentos /# more /proc/mdstat Personalities : raid5 md0 : active raid5 sdd13 sdc12 sdb11 sda14(F) 16771584 blocks level 5, 64k chunk, algorithm 2 3/2 _UU =. recovery = 22.8% (1916928/8385792) finish=1.9min speed=55892K/sec unused devices: rootcentos /# 因为sdd硬盘为热备,系统显示raid重构中,进度22.8%,且sda1标记(F)。 稍等再次查看: rootcentos/# more /proc/mdstat Personalities : raid5 md0 : active raid5 sdd10 sdc12 sdb11 sda13(F) 16771584 blocks level 5, 64k chunk, algorithm 2 3/3 UUU unused devices: rootcentos /# mdadm -D /dev/md0 /dev/md0: Version : 00.90.01 Creation Time : Fri Jun 1 13:00:31 2007 Raid Level : raid5 Array Size : 16771584 (15.99 GiB 17.17 GB) Device Size : 8385792 (7.100 GiB 8.59 GB) Raid Devices : 3 Total Devices : 4 Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Fri Jun 1 13:23:49 2007 State : clean Active Devices : 3 Working Devices : 3 Failed Devices : 1 Spare Devices : 0 Layout : left-symmetric Chunk Size : 64K Number Major Minor RaidDevice State 0 8 49 0 active sync /dev/sdd1 1 8 17 1 active sync /dev/sdb1 2 8 33 2 active sync /dev/sdc1 3 8 1 -1 faulty /dev/sda1 UUID : 63cb965b:79486986:d389c551:67677f20 Events : 0.16 rootcentos /# 3.移除损坏的硬盘 rootcentos /# mdadm /dev/md0 -r /dev/sda mdadm: hot removed /dev/sda rootcentos /# 至此可以拿下损坏的硬盘 4.添加新的硬盘到raid中 新硬盘接入系统中,应进行正确的分区,且最好与之前换掉的硬盘保持相同的设备号。然后执行命令 rootcentos /# mdadm /dev/md0 -a /dev/sda 模拟故障同raidtools一样,mdadm也可以软件模拟故障,命令选项为-fail或-set-faulty:rootlocalhost eric4ever# mdadm -set-faulty -helpUsage: mdadm arraydevice options component devices.This usage is for managing the component devices within an array.The -manage option is not needed and is assumed if the first argumentis a device name or a management option.The first device listed will be taken to be an md array device, andsubsequent devices are (potential) components of that array.Options that are valid with management mode are: -add -a : hotadd subsequent devices to the array -remove -r : remove subsequent devices, which must not be active -fail -f : mark subsequent devices a faulty -set-faulty : same as -fail -run -R : start a partially built array -stop -S : deactivate array, releasing all resources -readonly -o : mark array as readonly -readwrite -w : mark array as readwriterootlocalhost eric4ever# mdadm -fail -helpUsage: mdadm arraydevice options component devices.This usage is for managing the component devices within an array.The -manage option is not needed and is assumed if the first argumentis a device name or a management option.The first device listed will be taken to be an md array device, andsubsequent devices are (potential) components of that array.Options that are valid with management mode are: -add -a : hotadd subsequent devices to the array -remove -r : remove subsequent devices, which must not be active -fail -f : mark subsequent devices a faulty -set-faulty : same as -fail -run -R : start a partially built array -stop -S : deactivate array, releasing all resources -readonly -o : mark array as readonly -readwrite -w : mark array as readwrite接下来我们模拟/dev/sdb故障:rootlocalhost eric4ever# mdadm -manage -set-faulty /dev/md0 /dev/sdbmdadm: set /dev/sdb faulty in /dev/md0查看一下系统日志,如果你配置了冗余磁盘,可能会显示如下信息: kernel: raid5: Disk failure on sdb, disabling device. kernel: md0: resyncing spare disk sde to replace failed disk检查/proc/mdstat,如果配置的冗余磁盘可用,阵列可能已经开始重建。首先我们使用mdadm -detail /dev/md0命令来查看一下RAID的状态:rootlocalhost eric4ever# mdadm -detail /dev/md0/dev/md0: Version : 00.90.00 Creation Time : Thu May 24 13:45:35 2007 Raid Level : raid5 Array Size : 16777088 (16.00 GiB 17.18 GB) Used Dev Size : 8388544 (8.00 GiB 8.59 GB) Raid Devices : 3 Total Devices : 5Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Thu May 24 14:07:55 2007 State : active, degraded, recoveringActive Devices : 2Working Devices : 3Failed Devices : 2 Spare Devices : 1 Layout : left-symmetric Chunk Size : 64KRebuild Status : 3% complete UUID : 4b15050e:7d0c477d:98ed7d00:0f3c29e4 Events : 0.6 Number Major Minor RaidDevice State 0 8 16 0 faulty spare /dev/sdb 1 8 32 1 active sync /dev/sdc 2 8 48 2 active sync /dev/sdd 3 8 64 3 spare rebuilding /dev/sde查看/proc/mdstat:rootlocalhost eric4ever# cat /proc/mdstatPersonalities : raid5read_ahead 1024 sectorsmd0 : active raid5 sdb4 sde3 sdd2 sdc1 16777088 blocks level 5, 64k chunk, algorithm 2 3/2 _UU =. recovery = 10.2% (858824/8388544) finish=12.4min speed=10076K/secunused devices: 再查看一下RAID状态:rootlocalhost eric4ever# mdadm -detail /dev/md0/dev/md0: Version : 00.90.00 Creation Time : Thu May 24 13:45:35 2007 Raid Level : raid5 Array Size : 16777088 (16.00 GiB 17.18 GB) Used Dev Size : 8388544 (8.00 GiB 8.59 GB) Raid Devices : 3 Total Devices : 5Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Thu May 24 14:08:27 2007 State : active, degraded, recoveringActive Devices : 2Working Devices : 4Failed Devices : 1 Spare Devices : 2 Layout : left-symmetric Chunk Size : 64KRebuild Status : 11% complete UUID : 4b15050e:7d0c477d:98ed7d00:0f3c29e4 Events : 0.8 Number Major Minor RaidDevice State 0 0 0 0 removed 1 8 32 1 active sync /dev/sdc 2 8 48 2 active sync /dev/sdd 3 8 64 3 spare /dev/sde 4 8 16 4 spare /dev/sdb已经完成到11%了。查看一下日志消息:rootlocalhost eric4ever# tail /var/log/messagesMay 24 14:08:27 localhost kernel: - rd:3 wd:2 fd:1May 24 14:08:27 localhost kernel: disk 0, s:0, o:0, n:0 rd:0 us:0 dev:dev 00:00May 24 14:08:27 localhost kernel: disk 1, s:0, o:1, n:1 rd:1 us:1 dev:sdcMay 24 14:08:27 localhost kernel: disk 2, s:0, o:1, n:2 rd:2 us:1 dev:sddMay 24 14:08:27 localhost kernel: RAID5 conf printout:May 24 14:08:27 localhost kernel: - rd:3 wd:2 fd:1May 24 14:08:27 localhost kernel: disk 0, s:0, o:0, n:0 rd:0 us:0 dev:de
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 45982.3-2025第二代高温超导体微连接第3部分:接头试验方法
- 期权权限考试题库及答案
- 畜牧证考试题库及答案
- 森林防火灭火安全知识培训课件
- 森林法知识培训课件
- 森林护林员培训知识课件
- 桥梁道路知识培训课件
- 2025年财务会计中级职称考试面试预测题集
- 《机械员》考试题库带答案(黄金题型)
- 2025年调酒师资格认证考试高级模拟题及解析
- 旅游景区规划设计方案
- 损伤识别和结构健康监测中的动态响应特征
- 高一语文开学第一课 课件 2024-2025学年统编版高中语文必修上册
- 2022新能源光伏电站电力监控系统安全防护实施方案
- 2024智能变电站新一代集控站设备监控系统技术规范部分
- 奶茶店饮品制作手册
- 初中化学课程标准(2022年版)考试题库(含答案)
- 部编人教版六年级上册语文全册教学课件+单元复习课件
- 酒店消防安全管理制度(2022版)
- 人教部编七年级语文全册专项知识点梳理归纳字词、文言文、古诗词
- 国家基本公共卫生服务规范第三版测试
评论
0/150
提交评论