马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!1、LVM逻辑卷办理手艺发生的背景
企业日趋变更的存储必要使得传统的磁盘分区存储显得不敷天真
2、磁盘分区存储
关于如许的三个物理分区的话,早晚有一天会被数据填满,由于它是逝世的,没法举行缩放。
假定上面暗示的是/dev/sda磁盘上的三个分区:
1)、初始化/dev/sda上的这三个物理分区:
下令:#pvcreate/dev/sda1/dev/sda2/dev/sda3或#pvcreate/dev/sda[1-3]
2)、将这三个物理卷PV,兼并成一个卷组(VGVolumeGroup)
下令:#vgcreatevg0/dev/sda[1-2]
3)、从卷组VG0中创立逻辑卷LV,逻辑卷称号为date
下令:#lvcreate–ndate–L10Mvg0
4)、扩大LV逻辑卷date的巨细:
下令:#e2fsadm–L+10M/dev/vg0/date
5)、将别的一个PV逻辑卷/dev/sda3增添到VG中:
下令:#vgextendvg0/dev/sda3
6)、从逻辑卷组LV中先移除一局部物理分区:
下令:1、#pvmove/dev/sda1<--------将sda1中的数据移到别的的物理卷中
2、#vgreducevg0/dev/sda1<--------将sda1分区从vg0卷组中移出
----------------------------------实践的设置历程----------------------------------
[root@localhostroot]#fdisk/dev/sdb<---------在/dev/sdb分区上做这个实行
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):1
Firstcylinder(1-522,default1):
Usingdefaultvalue1
Lastcylinderor+sizeor+sizeMor+sizeK(1-522,default522):200
Command(mforhelp):t<---------转换分区范例
Selectedpartition1
Hexcode(typeLtolistcodes):L<--------列出一切分区的范例代码
0Empty1cHiddenWin95FA70DiskSecureMultbbBootWizardhid
1FAT121eHiddenWin95FA75PC/IXbeSolarisboot
2XENIXroot24NECDOS80OldMinixc1DRDOS/sec(FAT-
3XENIXusr39Plan981Minix/oldLinc4DRDOS/sec(FAT-
4FAT16<32M3cPartitionMagic82Linuxswapc6DRDOS/sec(FAT-
5Extended40Venix8028683Linuxc7Syrinx
6FAT1641PPCPRePBoot84OS/2hiddenC:daNon-FSdata
7HPFS/NTFS42SFS85LinuxextendeddbCP/M/CTOS/.
8AIX4dQNX4.x86NTFSvolumesetdeDellUtility
9AIXbootable4eQNX4.x2ndpart87NTFSvolumesetdfBootIt
aOS/2BootManag4fQNX4.x3rdpart8eLinuxLVMe1DOSaccess
bWin95FAT3250OnTrackDM93Amoebae3DOSR/O
cWin95FAT32(LB51OnTrackDM6Aux94AmoebaBBTe4SpeedStor
eWin95FAT16(LB52CP/M9fBSD/OSebBeOSfs
fWin95Extd(LB53OnTrackDM6Auxa0IBMThinkpadhieeEFIGPT
10OPUS54OnTrackDM6a5FreeBSDefEFI(FAT-12/16/
11HiddenFAT1255EZ-Drivea6OpenBSDf0Linux/PA-RISCb
12Compaqdiagnost56GoldenBowa7NeXTSTEPf1SpeedStor
14HiddenFAT16<35cPriamEdiska8DarwinUFSf4SpeedStor
16HiddenFAT1661SpeedStora9NetBSDf2DOSsecondary
17HiddenHPFS/NTF63GNUHURDorSysabDarwinbootfdLinuxraidauto
18ASTSmartSleep64NovellNetwareb7BSDIfsfeLANstep
1bHiddenWin95FA65NovellNetwareb8BSDIswapffBBT
Hexcode(typeLtolistcodes):8e<------输出对应的LinuxLVM分区代码
Changedsystemtypeofpartition1to8e(LinuxLVM)
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):2
Firstcylinder(201-522,default201):
Usingdefaultvalue201
Lastcylinderor+sizeor+sizeMor+sizeK(201-522,default522):401
Command(mforhelp):t
Partitionnumber(1-4):2
Hexcode(typeLtolistcodes):8e
Changedsystemtypeofpartition2to8e(LinuxLVM)
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):3
Firstcylinder(402-522,default402):
Usingdefaultvalue402
Lastcylinderor+sizeor+sizeMor+sizeK(402-522,default522):
Usingdefaultvalue522
Command(mforhelp):t
Partitionnumber(1-4):3
Hexcode(typeLtolistcodes):8e
Changedsystemtypeofpartition3to8e(LinuxLVM)
Command(mforhelp):p<------打印出分区表信息
Disk/dev/sdb:4294MB,4294967296bytes
255heads,63sectors/track,522cylinders
Units=cylindersof16065*512=8225280bytes
DeviceBootStartEndBlocksIdSystem
/dev/sdb112001606468+8eLinuxLVM
/dev/sdb22014011614532+8eLinuxLVM
/dev/sdb3402522971932+8eLinuxLVM
Command(mforhelp):w<--------保留加入~!
Thepartitiontablehasbeenaltered!
Callingioctl()tore-readpartitiontable.
Syncingdisks.
[root@localhostroot]#pvcreate/dev/sdb[1-3]<---------创立物理卷PV
pvcreate--ERROR:"/etc/lvmtab"doesntexist;pleaserunvgscan<--初度创立,要运转vgscan,天生设置文件/etc/lvmtab
[root@localhostroot]#vgscan<-----运转vgscan下令,天生设置文件/etc/lvmtab.
vgscan--readingallphysicalvolumes(thismaytakeawhile...)
vgscan--"/etc/lvmtab"and"/etc/lvmtab.d"successfullycreated<----提醒已乐成创立所必要的两个文件
vgscan--WARNING:ThisprogramdoesnotdoaVGDAbackupofyourvolumegroup
[root@localhostroot]#pvcreate/dev/sdb[1-3]<------再次创立pv物理分区
pvcreate--physicalvolume"/dev/sdb1"successfullycreated
pvcreate--physicalvolume"/dev/sdb2"successfullycreated
pvcreate--physicalvolume"/dev/sdb3"successfullycreated
[root@localhostroot]#vgcreatevg0/dev/sdb[1-2]<--------创立vg卷组
vgcreate--INFO:usingdefaultphysicalextentsize4MB
vgcreate--INFO:maximumlogicalvolumesizeis255.99Gigabyte
vgcreate--doingautomaticbackupofvolumegroup"vg0"
vgcreate--volumegroup"vg0"successfullycreatedandactivated
[root@localhostroot]#vgdisplayvg0<----------检察VG卷组的信息
---Volumegroup---
VGNamevg0
VGAccessread/write
VGStatusavailable/resizable
VG#0
MAXLV256
CurLV0
OpenLV0
MAXLVSize255.99GB
MaxPV256
CurPV2
ActPV2
VGSize3.06GB<---------可用的VG的总巨细
PESize4MB<---------扩大块的巨细为4M
TotalPE784<---------统共包括的扩大块数目
AllocPE/Size0/0<----------以PEsize的情势来分派巨细
FreePE/Size784/3.06GB
VGUUIDfsfUSc-GH4e-lQGl-EjS6-EMKF-56xa-V6Qpy4
[root@localhostroot]#lvcreate-ndata-L100Mvg0<--------在vg0卷组中,创立逻辑卷lv:data
lvcreate--doingautomaticbackupof"vg0"
lvcreate--logicalvolume"/dev/vg0/data"successfullycreated
[root@localhostroot]#mkfs.ext3/dev/vg0/data<---------格局化逻辑卷lv
mke2fs1.32(09-Nov-2002)
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
25688inodes,102400blocks
5120blocks(5.00%)reservedforthesuperuser
Firstdatablock=1
13blockgroups
8192blockspergroup,8192fragmentspergroup
1976inodespergroup
Superblockbackupsstoredonblocks:
8193,24577,40961,57345,73729
Writinginodetables:done
Creatingjournal(4096blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery20mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
[root@localhostroot]#mount/dev/vg0/data/mnt<----挂载逻辑卷
[root@localhostroot]#cp/etc/services/mnt<--------测试是不是可使用
[root@localhostroot]#lvdisplay/dev/vg0/data<-------显现lv的具体信息
---Logicalvolume---
LVName/dev/vg0/data
VGNamevg0
LVWriteAccessread/write
LVStatusavailable
LV#1
#open1
LVSize100MB<---------逻辑卷的空间巨细
CurrentLE25
AllocatedLE25
Allocationnextfree
Readaheadsectors1024
Blockdevice58:0
[root@localhostroot]#vgdisplayvg0<--------显现卷组vg的具体情形
---Volumegroup---
VGNamevg0
VGAccessread/write
VGStatusavailable/resizable
VG#0
MAXLV256
CurLV1
OpenLV1
MAXLVSize255.99GB
MaxPV256
CurPV2
ActPV2
VGSize3.06GB
PESize4MB
TotalPE784
AllocPE/Size25/100MB<----------以PEsize的情势来暗示已分派的空间巨细
FreePE/Size759/2.96GB<----------以PEsize的情势来暗示残剩的空间巨细
VGUUIDfsfUSc-GH4e-lQGl-EjS6-EMKF-56xa-V6Qpy4
[root@localhostroot]#lvscan<-------检察逻辑卷的信息
lvscan--ACTIVE"/dev/vg0/data"[100MB]
lvscan--1logicalvolumeswith100MBtotalin1volumegroup
lvscan--1activelogicalvolumes
[root@localhostroot]#df–lh<-------检察挂载分区的利用情形
FilesystemSizeUsedAvailUse%Mountedon
/dev/sda15.0G1.1G3.6G24%/
none78M078M0%/dev/shm
/dev/vg0/data97M4.1M88M5%/mnt
[root@localhostroot]#umount/mnt<------卸载/dev/vg0/data逻辑卷
[root@localhostroot]#e2fsadm-L+200M/dev/vg0/data<------为逻辑卷/dev/vg0/data扩容200M
e2fsck1.32(09-Nov-2002)
Pass1:Checkinginodes,blocks,andsizes
Pass2:Checkingdirectorystructure
Pass3:Checkingdirectoryconnectivity
Pass4:Checkingreferencecounts
Pass5:Checkinggroupsummaryinformation
/dev/vg0/data:12/25688files(0.0%non-contiguous),7398/102400blocks
lvextend--extendinglogicalvolume"/dev/vg0/data"to300MB
lvextend--doingautomaticbackupofvolumegroup"vg0"
lvextend--logicalvolume"/dev/vg0/data"successfullyextended
resize2fs1.32(09-Nov-2002)
Beginpass1(max=25)
ExtendingtheinodetableXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Beginpass2(max=1)
RelocatingblocksXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Beginpass3(max=13)
ScanninginodetableXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Beginpass5(max=7)
MovinginodetableXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Thefilesystemon/dev/vg0/dataisnow307200blockslong.
e2fsadm--ext2fsinlogicalvolume/dev/vg0/datasuccessfullyextendedto300MB<------已乐成扩容到300M
[root@localhostroot]#mount/dev/vg0/data/mnt<-------再次挂载逻辑卷data
[root@localhostroot]#df–lh<-----检察挂载分区的利用情形
FilesystemSizeUsedAvailUse%Mountedon
/dev/sda15.0G1.1G3.6G24%/
none78M078M0%/dev/shm
/dev/vg0/data291M4.1M272M2%/mnt<----------已乐成扩容,并挂载乐成.
[root@localhostroot]#vgdisplayvg0<--------检察VG卷组的信息
---Volumegroup---
VGNamevg0
VGAccessread/write
VGStatusavailable/resizable
VG#0
MAXLV256
CurLV1
OpenLV1
MAXLVSize255.99GB
MaxPV256
CurPV2
ActPV2
VGSize3.06GB
PESize4MB
TotalPE784
AllocPE/Size75/300MB
FreePE/Size709/2.77GB
VGUUIDfsfUSc-GH4e-lQGl-EjS6-EMKF-56xa-V6Qpy4
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们! |