CN107992272A - 一种云计算架构下的lvm磁盘空间扩容方法 - Google Patents
一种云计算架构下的lvm磁盘空间扩容方法 Download PDFInfo
- Publication number
- CN107992272A CN107992272A CN201711399348.2A CN201711399348A CN107992272A CN 107992272 A CN107992272 A CN 107992272A CN 201711399348 A CN201711399348 A CN 201711399348A CN 107992272 A CN107992272 A CN 107992272A
- Authority
- CN
- China
- Prior art keywords
- dilatation
- disk
- lvm
- root
- swap
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0662—Virtualisation aspects
- G06F3/0665—Virtualisation aspects at area level, e.g. provisioning of virtual or logical volumes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0674—Disk device
- G06F3/0676—Magnetic disk device
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45583—Memory management, e.g. access or allocation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明涉及计算机领域,特别涉及一种云计算架构下的LVM磁盘空间扩容方法。本发明通过直接增大PV空间来对LVM磁盘分区进行扩容,可以减少PV磁盘数量,使磁盘布局简单化,方便存储以及磁盘日后的维护工作;该方法适合使用虚拟机或者共享存储的机器,磁盘可以直接扩容,加上虚拟机环境机器启动速度较快,且GParted分区简单快速,分区所需的停机时间比较短。
Description
技术领域
本发明涉及计算机领域,特别涉及一种云计算架构下的LVM磁盘空间扩容方法。
背景技术
LVM是Logical Volume Manager(逻辑卷管理)的简写,它将一个或多个硬盘的分区在逻辑上的集合,以此整合成一个大的存储资源池,当硬盘的空间不足时,可以继续将其它的硬盘的分区加入其中,这样可以实现磁盘空间的动态管理,相对于普通的磁盘分区有很大的灵活性。
与传统的磁盘与分区相比,LVM为计算机提供了更高层次的磁盘存储。它使系统管理员可以更方便的为应用与用户分配存储空间。在LVM管理下的存储卷可以按需要随时改变大小与移除(可能需对文件系统工具进行升级)。LVM也允许按用户组对存储卷进行管理,允许管理员用更直观的名称(如"sales'、'development')代替物理磁盘名(如'sda'、'sdb')来标识存储卷。
LVM使用分层结构,如图1所示,图中顶部,首先是实际的物理磁盘及其划分的分区和其上的物理卷(PV)。一个或多个物理卷可以用来创建卷组(VG)。然后基于卷组可以创建逻辑卷(LV)。只要在卷组中有可用空间,就可以随心所欲的创建逻辑卷。文件系统就是在逻辑卷上创建的,然后可以在操作系统挂载和访问。
随着云计算和大数据技术的发展,客户对信息存储容量的需求日益增长。如何对客户的存储空间进行安全、高效的扩容,满足客户的需求,这也是服务器优质服务提供商--浪潮需要关注和解决的问题。
传统LVM扩容方法需要增加PV磁盘,再将PV加入到VG中,从而扩大VG空间,再对相关的LV进行扩容,最后增加文件系统空间完成整个扩容工作。扩容多次后,服务器的磁盘数量会越来越多,容易增加日后维护存储和磁盘布局的难度。但是在云计算模式下,底层硬件(服务器、存储、网络设备)被虚拟成一个共享的、可按需分配的基础资源池。客户的服务器给抽象化为一个个虚拟机,基于此,只增加原本正在使用的PV磁盘空间,服务器的磁盘空间就可以直接得到扩容。这样分配给服务器的磁盘数量较少,磁盘布局结构较简单,维护起来也更加方便。
发明内容
本发明是通过如下技术方案实现的,一种云计算架构下的LVM磁盘空间扩容方法,通过直接增大PV空间来对LVM磁盘分区进行扩容。
优选的,该方法包括PV扩容,PV扩容包括如下步骤:Step1:查看系统的硬盘分区;Step2:扩容虚拟机的硬盘;Step3:运行GParted分区工具进行分区。
优选的,所述方法还包括LV及文件系统扩容步骤。
优选的,所述LV及文件系统扩容包括Step1:扩容LV;Step2:扩容root LV;Step3:扩容根文件系统;Step4:扩容swap分区。
本发明提供一种计算机存储介质,其上存有计算机程序,该程序被处理器执行以实现所述的方法。
附图说明
图1本发明背景技术提供的LVM架构图
图2本发明一实施例提供的扩容虚拟机的硬盘其一示意图
图3本发明一实施例提供的扩容虚拟机的硬盘其二示意图
图4本发明一实施例提供的运行GParted分区工具进行分区其一示意图
图5本发明一实施例提供的运行GParted分区工具进行分区其二示意图
图6本发明一实施例提供的运行GParted分区工具进行分区其三示意图
具体实施方式
下面结合附图对本发明的较佳实施例进行详细阐述。以下实施例仅用于更加清楚地说明本发明的技术方案,而不能以此来限制本发明的保护范围。
GParted(Gnome Partition Editor)是一种非常小巧自启动运行光盘,采用Xorg,轻量级的Fluxbox窗口管理器,以及最新的2.6Linux内核建构。其中包含的GParted硬盘分区工具,作为系统维护盘非常有用。GParted支持多种linux下常见的分区格式,包括ext2、ext4、fat、hfs、jfs、reiser4、reiserfs、xfs,甚至ntfs。另外官方还提供了LiveCD和LiveUSB版本的GParted,方便在没有主系统的情况下对硬盘进行分区。
本发明的提供了一种实施例,通过使用GParted分区软件扩大PV空间的方式来扩容整个VG,从而最终扩大文件系统的使用空间。
一、本实施例的运行环境
Host OS:ESXi
Guest OS:Centos7.0x64
虚拟机上安装了两块硬盘,大小分别为10GB和5GB,作为PV,建立了一个VG。
二、PV扩容过程
Step1:查看系统的硬盘分区
系统下输入parted,进入分区管理界面,输入print all,可以看到系统硬盘分区情况如下:
机器上有两个硬盘分区sda和sdb,其中sda有两个分区,分区sda1为boot启动分区,分区sda2为LVM PV分区,lvm的VG(sdb)有两个LV(root和swap)组成。另外,parted无法识别/dev/sdb,显示错误“unrecognised disk label”。
依次输入pvs、lvs和vgs命令查看LVM的详细信息:
可以看到,sda2和sdb均为LVM VG中的PV,sda2为sda磁盘中的第二个分区,而对于使用sdb整块硬盘建立的PV,parted是无法识别的,因为该磁盘为没有建立文件系统的裸设备。LVM中有一个VG(Centos7.0),VG的大小为14.5G,该VG由两个LV,root和swap组成。
Step2:扩容虚拟机的硬盘
如图2-3,使用Vsphere Client连接Vcenter,右键点击该虚拟机选择“编辑设置”,在“硬件”选项卡中,分别将硬盘1和硬盘2的大小各增加5GB:
输入以下命令识别新增空间:
echo′1′>/sys/class/scsi_disk/0\:0\:0\:0/device/rescan
echo′1′>/sys/class/scsi_disk/0\:0\:1\:0/device/rescan
运行parted,输入print all free,发现磁盘大小已经增加,而且在磁盘/dev/sda尾部有5GB未分配空间。
Step3:运行GParted分区工具进行分区
Gparted Live CD是镜像版本,可以将该ISO文件上传到ESX主机的数据存储中,然后挂载到虚拟机的光驱中,接着调整启动顺序用该CD引导启动该虚拟机。Live CD启动后,机器硬盘的分区结构和未分配空间识别如图4。
如图5,鼠标右键点击/dev/sda2分区,用鼠标点击右边的三角符号,拉动鼠标将分区扩容5GB选中,点击“调整大小/移动”,最后点击工具栏上的“Apply”应用更改。
如图6,点击工具栏最右边的按钮选择/dev/sdb硬盘,会看到sdb硬盘所有的空间都是未分配,因为sdb磁盘是直接在上面建立PV的裸设备磁盘,这种磁盘没有分区表和分区,GParted无法识别并进行分区。
卸载光盘,重启虚拟机进入本地系统,查看PV空间:
使用GParted,sda2扩容成功。
键入pvresize命令扩容sdb:
键入pvs、vgs确认扩容后的空间:
可以看到两个PV和VG中都有可分配的剩余空间了,PV扩容完毕。三、LV及文件系统扩容
Step1:扩容LV
将LV swap扩容到3GB,另外的LV root则分配剩余的全部空间。查看原来LV空间情况:
现在的root LV大小为13.5G,swap LV大小为1G。
将LV swap的空间增加2GB:
[root@user ~]# lvextend -L +2g/dev/centos/swap
Extending logical volume swap to 3.00 GiB
Logical volume swap successfully resized
查看VG剩余PE数量:
剩余2048个PE。
Step2:扩容root LV:
[root@user ~]# lvextend -1 +2048/dev/centos/root
Extending logical volume root to 21.50 GiB
Logical volume root successfully resized
查看LV大小确认:
[root@user ~]# lvextend -1 +2048 /dev/centos/root
Extending logical volume root to 21.50 GiB
Logical volume root successfully resized
两个LV已经扩容成功。
Step3:扩容根文件系统
LV扩容后需文件系统还没有扩容,键入df-h查看空间:
根分区现在大小是14GB。
使用resize2fs命令对跟分区文件系统进行在线扩容:
[root@user ~]# resize2fs -p/dev/centos/root
resize2fs 1.42.9(28-Dec-2013)
Filesystem at/dev/centos/root is mounted on/;on-line resizingrequired old_desc_blocks=2,new_desc_blocks=3
The filesystem on/dev/centos/root is now 5637120 blocks long
再次查看分区大小:
分区大小已经扩容为22GB。
Step4:扩容swap分区
Swap分区不能直接扩容,需先将其删除再重建。
分别使用free-m和swapon-s命令查看swap分区大小。可以看到这时候swap分区大小还是1GB。
停止swap分区:
[root@user ~]# swapoff -v/dev/centos/swap
swapoff/dev/centos/swap
重新建立swap分区:
[root@user ~]# mkswap/dev/centos/swap
mkswap:/dev/centos/swap:warning:wiping old swap signature.
Setting up swapspaceversion 1,size=3145724 KiB
no label,UUID=6dca44dc-9bf2-40b2-b0c8-d73cbe409002
启用Swap分区:
[root@user ~]# swapon -v/dev/centos/swap
swapon/dev/centos/swap
swapon:/dev/mapper/centos-swap:found swap signature:version 1,page-size 4,samebyte order
swapon:/dev/mapper/centos-swap:pagesize=4096,swapsize=3221225472,devsize=3221225472
再次查看swap分区大小,swap分区已变成了3GB:
本发明通过直接增大PV空间来对LVM磁盘分区进行扩容,可以减少PV磁盘数量,使磁盘布局简单化,方便存储以及磁盘日后的维护工作。但需要使用GParted光盘引导服务器重启进行分区,若服务器不能停机则不太适合该方法。这种方法比较适合使用虚拟机或者共享存储的机器,磁盘可以直接扩容,加上虚拟机环境机器启动速度较快,且GParted分区简单快速,分区所需的停机时间比较短。
建立LVM时,若使用整块硬盘作为PV,应先在磁盘上建立分区表和分区,再设置分区的lvm标志位(Parted中使用set lvm on,fdisk中按t,然后设置8e),不然的话就会出现sdb磁盘无法被GParted或者其他分区软件识别的情况,很容易被误操作。另外,对任何分区操作前应先对分区数据进行备份。
术语“计算机系统”包括根据上述实施方式实现系统或执行方法的硬件、软件和数据存储装置。例如,计算机系统可包括中央处理单元(CPU)、输入装置、输出装置和数据存储。优选地,计算机系统具有用于提供视觉输出显示的监视器(例如,商业处理设计)。数据存储可包括RAM、盘驱动器或其它计算机可读介质。计算机系统可包括通过网络连接的多个计算装置,并且能够经过该网络彼此通信。
以上实施方式的方法可设为计算机程序或者携带计算机程序的计算机程序产品或者计算机可读介质,所述计算机程序设置成在计算机上运行时执行上述方法。
术语“计算机可读介质”包括(但不限于)可直接由计算机或者计算机系统读取或者访问的任何非临时媒体或介质。所述介质可包括(但不限于)诸如软盘、硬盘存储媒体和磁带的磁存储介质;诸如光盘或者CD-ROM的光学存储介质;诸如存储器的电存储介质,包括RAM、ROM和闪速存储器;以及以上的混合和组合,诸如磁/光学存储介质。
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。
Claims (5)
1.一种云计算架构下的LVM磁盘空间扩容方法,其特征在于:通过直接增大PV空间来对LVM磁盘分区进行扩容。
2.根据权利要求1所述的方法,其特征在于:该方法包括PV扩容,PV扩容包括如下步骤:
Step1:查看系统的硬盘分区;Step2:扩容虚拟机的硬盘;Step3:运行GParted分区工具进行分区。
3.根据权利要求1-2任一项所述的方法,其特征在于:所述方法还包括LV及文件系统扩容步骤。
4.根据权利要求3所述的方法,其特征在于:所述LV及文件系统扩容包括Step1:扩容LV;Step2:扩容root LV;Step3:扩容根文件系统;Step4:扩容swap分区。
5.一种计算机存储介质,其上存有计算机程序,该程序被处理器执行以实现权利要求1-4任一项所述的方法。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711399348.2A CN107992272A (zh) | 2017-12-21 | 2017-12-21 | 一种云计算架构下的lvm磁盘空间扩容方法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711399348.2A CN107992272A (zh) | 2017-12-21 | 2017-12-21 | 一种云计算架构下的lvm磁盘空间扩容方法 |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107992272A true CN107992272A (zh) | 2018-05-04 |
Family
ID=62039492
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711399348.2A Pending CN107992272A (zh) | 2017-12-21 | 2017-12-21 | 一种云计算架构下的lvm磁盘空间扩容方法 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107992272A (zh) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110781164A (zh) * | 2019-09-29 | 2020-02-11 | 苏州浪潮智能科技有限公司 | 一种数据库一体机的设计方法、设备及介质 |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104182176A (zh) * | 2013-05-24 | 2014-12-03 | 华中科技大学 | 一种独立磁盘冗余阵列raid5的快速扩容方法 |
CN106250207A (zh) * | 2016-07-27 | 2016-12-21 | 汉柏科技有限公司 | 一种虚拟机扩容处理方法及装置 |
-
2017
- 2017-12-21 CN CN201711399348.2A patent/CN107992272A/zh active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104182176A (zh) * | 2013-05-24 | 2014-12-03 | 华中科技大学 | 一种独立磁盘冗余阵列raid5的快速扩容方法 |
CN106250207A (zh) * | 2016-07-27 | 2016-12-21 | 汉柏科技有限公司 | 一种虚拟机扩容处理方法及装置 |
Non-Patent Citations (1)
Title |
---|
MARCO_HWT: "Linux LVM磁盘空间扩容的新方法", 《51CTO》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110781164A (zh) * | 2019-09-29 | 2020-02-11 | 苏州浪潮智能科技有限公司 | 一种数据库一体机的设计方法、设备及介质 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10222983B2 (en) | Storage management computer and management method of storage apparatus | |
US9727430B2 (en) | Failure recovery method in information processing system and information processing system | |
US8165177B2 (en) | System and method for hybrid virtual machine monitor file system operations | |
US10025806B2 (en) | Fast file clone using copy-on-write B-tree | |
US9448728B2 (en) | Consistent unmapping of application data in presence of concurrent, unquiesced writers and readers | |
US9116846B2 (en) | Virtual machine backup from storage snapshot | |
US7478177B2 (en) | System and method for automatic reassignment of shared storage on blade replacement | |
US8868877B2 (en) | Creating encrypted storage volumes based on thin-provisioning mode information | |
US9959207B2 (en) | Log-structured B-tree for handling random writes | |
US9792075B1 (en) | Systems and methods for synthesizing virtual hard drives | |
CN103699372A (zh) | 从中央存储装置引导计算机系统 | |
US9613053B1 (en) | Techniques for providing access to a virtualized block storage device over a file-based network storage protocol | |
CN104598170B (zh) | 确定读写路径的方法和装置 | |
CN105138431A (zh) | 一种Linux系统的备份和还原方法 | |
US11138028B1 (en) | Hot growing a cloud hosted block device | |
WO2019000949A1 (zh) | 分布式存储系统中元数据存储方法、系统及存储介质 | |
CN104615508A (zh) | 一种恢复Linux系统下LVM配置的方法 | |
US20160210198A1 (en) | One-click backup in a cloud-based disaster recovery system | |
CN107992272A (zh) | 一种云计算架构下的lvm磁盘空间扩容方法 | |
CN105607869A (zh) | 一种快速格式化与使用虚拟机磁盘的方法 | |
CN101876884B (zh) | 虚拟硬盘的容量扩展方法 | |
US10983819B2 (en) | Dynamic provisioning and delivery of virtual applications | |
Nakashima et al. | File Placing Control for Improving the I/O Performance of Hadoop in Virtualized Environment | |
US9262424B1 (en) | Techniques for performing slice consistency checks | |
US8713281B1 (en) | Storage device performance alignment notification |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180504 |