在 Linux 上创建 Software RAID 10

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

在Linux上创建SoftwareRAID10昨天重装一台老服务器的时候发现IntelhardwareRAID控制卡有问题,不能识别所有硬盘,但是安装操作系统过程中可以识别所有硬盘,还有一个问题就是操作系统安装正常,但是安装完后无法启动,某种原因导致BIOS不能从硬盘启动系统。所以打算把操作系统安装到一个USB盘上,然后从USB盘启动系统,并给上面的6块硬盘做成SoftwareRAID10后挂载到系统里用。做SoftwareRAID不要求硬盘都一模一样,但是强烈推荐用同一厂商、型号和大小的硬盘。为啥RAID10,不选RAID0,RAID1,RAID5呢?答:RAID0太危险,RAID1性能稍逊一些,RAID5频繁写情况下性能差,RAID10似乎是当今磁盘阵列的最佳选择,特别适合做KVM/Xen/VMware虚拟机母机(host)的本地存储系统(如果不考虑SAN和分布式存储的话)。这台服务器上有6块完全相同的硬盘,给每块硬盘分成一个区,分区格式为Linuxsoftwareraid:#fdisk/dev/sdaWARNING:DOS-compatiblemodeisdeprecated.It'sstronglyrecommendedtoswitchoffthemode(command'c')andchangedisplayunitstosectors(command'u').Command(mforhelp):nCommandactioneextendedpprimarypartition(1-4)pPartitionnumber(1-4):1Firstcylinder(1-91201,default1):Usingdefaultvalue1Lastcylinder,+cylindersor+size{K,M,G}(1-91201,default91201):Usingdefaultvalue91201Command(mforhelp):pDisk/dev/sda:750.2GB,750156374016bytes255heads,63sectors/track,91201cylindersUnits=cylindersof16065*512=8225280bytesSectorsize(logical/physical):512bytes/512bytesI/Osize(minimum/optimal):512bytes/512bytesDiskidentifier:0x0005c259DeviceBootStartEndBlocksIdSystem/dev/sda119120173257200183LinuxCommand(mforhelp):tSelectedpartition1Hexcode(typeLtolistcodes):fdChangedsystemtypeofpartition1tofd(Linuxraidautodetect)Command(mforhelp):wThepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.Syncingdisks.按照上面的/dev/sda的分区例子依次给剩下的5块硬盘sdc,sdd,sde,sdf,sdg分区、更改分区格式:#fdisk/dev/sdc...#fdisk/dev/sdd...#fdisk/dev/sde...#fdisk/dev/sdf...#fdisk/dev/sdg...分区完成后就可以开始创建RAID了,在上面的6个相同大小的分区上创建raid10:#mdadm--create/dev/md0-v--raid-devices=6--level=raid10/dev/sda1/dev/sdc1/dev/sdd1/dev/sde1/dev/sdf1/dev/sdg1mdadm:layoutdefaultston2mdadm:layoutdefaultston2mdadm:chunksizedefaultsto512Kmdadm:sizesetto732440576Kmdadm:Defaultingtoversion1.2metadatamdadm:array/dev/md0started.查看磁盘阵列的初始化过程(build),根据磁盘大小和速度,整个过程大概需要几个小时:#watchcat/proc/mdstatEvery2.0s:cat/proc/mdstatTueFeb1112:51:252014Personalities:[raid10]md0:activeraid10sdg1[5]sdf1[4]sde1[3]sdd1[2]sdc1[1]sda1[0]2197321728blockssuper1.2512Kchunks2near-copies[6/6][UUUUUU][....................]resync=0.2%(5826816/2197321728)finish=278.9minspeed=130948K/secunuseddevices:等阵列完成初始化后,就可以给md0设备创建分区和文件系统了,有了文件系统就可以挂载到系统里:#fdisk/dev/md0#mkfs.ext4/dev/md0p1#mkdir/raid10#mount/dev/md0p1/raid10修改/etc/fstab文件让每次系统启动时自动挂载:#vi/etc/fstab.../dev/md0p1/raid10ext4noatime,rw00在上面的/etc/fstab文件里使用/dev/md0p1设备名不是一个好办法,因为udev的缘故,这个设备名常在重启系统后变化,所以最好用UUID,使用blkid命令找到相应分区的UUID:#blkid.../dev/md0p1:UUID=093e0605-1fa2-4279-99b2-746c70b78f1bTYPE=ext4然后修改相应的fstab,使用UUID挂载:#vi/etc/fstab...#/dev/md0p1/raid10ext4noatime,rw00UUID=093e0605-1fa2-4279-99b2-746c70b78f1b/raid10ext4noatime,rw00查看RAID的情况:#mdadm--query--detail/dev/md0/dev/md0:Version:1.2CreationTime:TueFeb1112:50:382014RaidLevel:raid10ArraySize:2197321728(2095.53GiB2250.06GB)UsedDevSize:732440576(698.51GiB750.02GB)RaidDevices:6TotalDevices:6Persistence:SuperblockispersistentUpdateTime:TueFeb1118:48:102014State:cleanActiveDevices:6WorkingDevices:6FailedDevices:0SpareDevices:0Layout:near=2ChunkSize:512KName:local:0(localtohostlocal)UUID:e3044b6c:5ab972ea:8e742b70:3f766a11Events:70NumberMajorMinorRaidDeviceState0810activesync/dev/sda118331activesync/dev/sdc128492activesync/dev/sdd138653activesync/dev/sde148814activesync/dev/sdf158975activesync/dev/sdg1昨天重装一台老服务器的时候发现IntelhardwareRAID控制卡有问题,不能识别所有硬盘,但是安装操作系统过程中可以识别所有硬盘,还有一个问题就是操作系统安装正常,但是安装完后无法启动,某种原因导致BIOS不能从硬盘启动系统。所以打算把操作系统安装到一个USB盘上,然后从USB盘启动系统,并给上面的6块硬盘做成SoftwareRAID10后挂载到系统里用。做SoftwareRAID不要求硬盘都一模一样,但是强烈推荐用同一厂商、型号和大小的硬盘。为啥RAID10,不选RAID0,RAID1,RAID5呢?答:RAID0太危险,RAID1性能稍逊一些,RAID5频繁写情况下性能差,RAID10似乎是当今磁盘阵列的最佳选择,特别适合做KVM/Xen/VMware虚拟机母机(host)的本地存储系统(如果不考虑SAN和分布式存储的话)。这台服务器上有6块完全相同的硬盘,给每块硬盘分成一个区,分区格式为Linuxsoftwareraid:#fdisk/dev/sdaWARNING:DOS-compatiblemodeisdeprecated.It'sstronglyrecommendedtoswitchoffthemode(command'c')andchangedisplayunitstosectors(command'u').Command(mforhelp):nCommandactioneextendedpprimarypartition(1-4)pPartitionnumber(1-4):1Firstcylinder(1-91201,default1):Usingdefaultvalue1Lastcylinder,+cylindersor+size{K,M,G}(1-91201,default91201):Usingdefaultvalue91201Command(mforhelp):pDisk/dev/sda:750.2GB,750156374016bytes255heads,63sectors/track,91201cylindersUnits=cylindersof16065*512=8225280bytesSectorsize(logical/physical):512bytes/512bytesI/Osize(minimum/optimal):512bytes/512bytesDiskidentifier:0x0005c259DeviceBootStartEndBlocksIdSystem/dev/sda119120173257200183LinuxCommand(mforhelp):tSelectedpartition1Hexcode(typeLtolistcodes):fdChangedsystemtypeofpartition1tofd(Linuxraidautodetect)Command(mforhelp):wThepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.Syncingdisks.按照上面的/dev/sda的分区例子依次给剩下的5块硬盘sdc,sdd,sde,sdf,sdg分区、更改分区格式:#fdisk/dev/sdc...#fdisk/dev/sdd...#fdisk/dev/sde...#fdisk/dev/sdf...#fdisk/dev/sdg...分区完成后就可以开始创建RAID了,在上面的6个相同大小的分区上创建raid10:#mdadm--create/dev/md0-v--raid-devices=6--level=raid10/dev/sda1/dev/sdc1/dev/sdd1/dev/sde1/dev/sdf1/dev/sdg1mdadm:layoutdefaultston2mdadm:layoutdefaultston2mdadm:chunksizedefaultsto512Kmdadm:sizesetto732440576Kmdadm:Defa

1 / 16
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功