linux系统中RAID和LVM综合使用技巧!,raidlvm
linux系统中RAID和LVM综合使用技巧!,raidlvm
由于 LVM 可以弹性调整 filesystem 的大小,但是缺点是可能没有加速与硬件备份(与快照不同)的功能。 而磁盘阵列则具有性能与备份的功能,但是无法提供类似 LVM 的优点。在此情境中,我们想利用『在 RAID 上面建置 LVM』的功能,以达到两者兼顾的能力。
目标:测试在 RAID 磁盘上面架构 LVM 系统;
需求:需要具有磁盘管理的能力,包括 RAID 与 LVM;
那要如何处理呢?如下的流程一个步骤一个步骤的实施看看吧:
利用 umount 先卸除之前挂载的文件系统;
修改 /etc/fstab 里面的数据,让开机不会自动挂载;
利用 fdisk 将该分割槽初除。
最终你的系统应该会只剩下如下的模样:(/dev/sd{b,c,d,e,f}都是已经用mkds格式化为ext3)
[cpp] view plain copyDisk/dev/sdb:8589MB,8589934592bytes255heads,63sectors/track,1044cylinders
Units=cylindersof16065*512=8225280bytes
Disk/dev/sdbdoesn'tcontainavalidpartitiontable
Disk/dev/sdc:8589MB,8589934592bytes255heads,63sectors/track,1044cylinders
Units=cylindersof16065*512=8225280bytes
Disk/dev/sdcdoesn'tcontainavalidpartitiontable
Disk/dev/sdd:8589MB,8589934592bytes255heads,63sectors/track,1044cylinders
Units=cylindersof16065*512=8225280bytes
Disk/dev/sdddoesn'tcontainavalidpartitiontable
Disk/dev/sde:8589MB,8589934592bytes255heads,63sectors/track,1044cylinders
Units=cylindersof16065*512=8225280bytes
Disk/dev/sdedoesn'tcontainavalidpartitiontable
Disk/dev/sdf:8589MB,8589934592bytes255heads,63sectors/track,1044cylinders
Units=cylindersof16065*512=8225280bytes
Disk/dev/sdfdoesn'tcontainavalidpartitiontable
2、建立 RAID ,假设我们利用五个(/dev/sd{b,c,d,e,f}) 8GB 的分割槽建立 RAID-5 ,且具有一个 spare disk
[cpp] view plain copy
[root@linux~]#mdadm--create--auto=yes/dev/md0--level=5--raid-devices=4--spare-devices=1/dev/sd{b,c,d,e,f}mdadm:/dev/sdbappearstocontainanext2fsfilesystem
size=8388608Kmtime=ThuJan108:00:001970mdadm:/dev/sdcappearstocontainanext2fsfilesystem
size=8388608Kmtime=ThuJan108:00:001970mdadm:/dev/sddappearstocontainanext2fsfilesystem
size=8388608Kmtime=ThuJan108:00:001970mdadm:/dev/sdeappearstocontainanext2fsfilesystem
size=8388608Kmtime=ThuJan108:00:001970mdadm:/dev/sdfappearstocontainanext2fsfilesystem
size=8388608Kmtime=ThuJan108:00:001970Continuecreatingarrayy
mdadm:array/dev/md0started.
3、开始处理 LVM ,现在我们假设所有的参数都使用默认值,包括 PE ,然后 VG 名为 raidvg ,LV 名为 raidlv ,底下为基本的流程:[cpp] view plain copy
[root@linux~]#pvcreate/dev/md0Physicalvolume"/dev/md0"successfullycreated
[root@linux~]#vgcreateraidvg/dev/md0/dev/cdrom:openfailed:只读文件系统
Attempttoclosedevice'/dev/cdrom'whichisnotopen./dev/cdrom:openfailed:只读文件系统
Attempttoclosedevice'/dev/cdrom'whichisnotopen.Volumegroup"raidvg"successfullycreated
[root@linux~]#lvcreate-l6143-nraidlvraidvgLogicalvolume"raidlv"created
[root@linux~]#lvdisplay---Logicalvolume---
LVName/dev/raidvg/raidlvVGNameraidvg
LVUUIDrBySS0-JxZ6-ANYe-Vp8G-xlUd-Rz1x-G6NjnTLVWriteAccessread/write
LVStatusavailable#open0
LVSize24.00GBCurrentLE6143
Segments1Allocationinherit
Readaheadsectorsauto-currentlysetto768
Blockdevice253:0
4、挂载[cpp] view plain copy
[root@linux~]#mkdir/mnt/raidlvm[root@linux~]#mkfs-text3/dev/raidvg/raidlv
mke2fs1.39(29-May-2006)Filesystemlabel=
OStype:LinuxBlocksize=4096(log=2)
Fragmentsize=4096(log=2)3145728inodes,6290432blocks
314521blocks(5.00%)reservedforthesuperuserFirstdatablock=0
Maximumfilesystemblocks=0192blockgroups
32768blockspergroup,32768fragmentspergroup16384inodespergroup
Superblockbackupsstoredonblocks:32768,98304,163840,229376,294912,819200,884736,1605632,2654208,
4096000
Writinginodetables:doneCreatingjournal(32768blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery21mountsor180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
[root@linux~]#mount/dev/raidvg/raidlv/mnt/raidlvm/
[cpp] view plain copy
[root@linuxraidlvm]#mdadm--detail/dev/md0|grepUUIDUUID:99de722a:bfd56556:7b3978e1:3bf3f4f9
[root@linuxraidlvm]#cat/etc/mdadm.confARRAY/dev/md0UUID=99de722a:bfd56556:7b3978e1:3bf3f4f9
[root@linuxraidlvm]#cat/etc/fstab|grep/mnt/raidlvm/dev/raidvg/raidlv/mnt/raidlvmext3defaults126、检查[cpp] view plain copy
[root@linuxraidlvm]#mdadm--detail/dev/md0/dev/md0:
Version:0.90CreationTime:FriFeb1722:26:442012
RaidLevel:raid5ArraySize:25165632(24.00GiB25.77GB)
UsedDevSize:8388544(8.00GiB8.59GB)RaidDevices:4
TotalDevices:5PreferredMinor:0
Persistence:Superblockispersistent
UpdateTime:FriFeb1722:39:112012State:clean
ActiveDevices:4WorkingDevices:5
FailedDevices:0SpareDevices:1
Layout:left-symmetric
ChunkSize:64K
UUID:99de722a:bfd56556:7b3978e1:3bf3f4f9Events:0.2
NumberMajorMinorRaidDeviceState
08160activesync/dev/sdb18321activesync/dev/sdc
28482activesync/dev/sdd38643activesync/dev/sde
4880-spare/dev/sdf
[root@linuxraidlvm]#cat/proc/mdstatPersonalities:[raid6][raid5][raid4]
md0:activeraid5sde[3]sdf[4](S)sdd[2]sdc[1]sdb[0]25165632blockslevel5,64kchunk,algorithm2[4/4][UUUU]
unuseddevices:
[root@linuxraidlvm]#pvscan/dev/cdrom:openfailed:只读文件系统
Attempttoclosedevice'/dev/cdrom'whichisnotopen.PV/dev/md0VGraidvglvm2[24.00GB/0free]
Total:1[24.00GB]/inuse:1[24.00GB]/innoVG:0[0][root@linuxraidlvm]#pvdisplay
---Physicalvolume---PVName/dev/md0
VGNameraidvgPVSize24.00GB/notusable3.81MB
Allocatableyes(butfull)PESize(KByte)4096
TotalPE6143FreePE0
AllocatedPE6143PVUUIDKgwVH9-HwTG-q4it-z0Ps-ACac-Si1y-8RxTkx
[root@linuxraidlvm]#vgscan
Readingallphysicalvolumes.Thismaytakeawhile.../dev/cdrom:openfailed:只读文件系统
Attempttoclosedevice'/dev/cdrom'whichisnotopen.Foundvolumegroup"raidvg"usingmetadatatypelvm2
[root@linuxraidlvm]#vgdisplay---Volumegroup---
VGNameraidvgSystemID
Formatlvm2MetadataAreas1
MetadataSequenceNo2VGAccessread/write
VGStatusresizableMAXLV0
CurLV1OpenLV1
MaxPV0CurPV1
ActPV1VGSize24.00GB
PESize4.00MBTotalPE6143
AllocPE/Size6143/24.00GBFreePE/Size0/0
VGUUIDzlM0TJ-fjR0-b2kO-rCpO-D6L9-zw0m-W3SVzp
[root@linuxraidlvm]#lvscanACTIVE'/dev/raidvg/raidlv'[24.00GB]inherit
[root@linuxraidlvm]#lvdisplay---Logicalvolume---
LVName/dev/raidvg/raidlvVGNameraidvg
LVUUIDrBySS0-JxZ6-ANYe-Vp8G-xlUd-Rz1x-G6NjnTLVWriteAccessread/write
LVStatusavailable#open1
LVSize24.00GBCurrentLE6143
Segments1Allocationinherit
Readaheadsectorsauto-currentlysetto768
Blockdevice253:0[root@linux~]#df
文件系统1K-块已用可用已用%挂载点/dev/sda359912322662984301900047%/
/dev/sda1101086113738449412%/boottmpfs51754805175480%/dev/shm
/dev/mapper/raidvg-raidlv24766844176204233325561%/mnt/raidlvm
[root@linux~]#cd/mnt/raidlvm/[root@linuxraidlvm]#ll
总计20drwx------2rootroot1638402-1722:37lost+found
-rw-r--r--1rootroot602-1722:38tt[root@linuxraidlvm]#cattt
评论暂时关闭