Cloud host dynamic expansion of disk storage (LVM) program

One, Scene

Cloud Hosting used more and more, is now almost no cloud without a host, often encounter the need to upgrade the hard drive to store operations, directly add a disk, or dynamic expansion in the original partition scheme used roughly as follows:
1, based on the dynamic expansion of the online format lvm
2 format non-lvm expansion
then we will combine the production capacity expansion programs and practices commonly used two kinds of

Two, LVM online dynamic expansion

1, lvm principles outlined

The entire birds brother explained
LVM focus is to adjust the filesystem's "capacity can be flexible! "And is not that the above performance and data preservation. Need to write the file or the performance reliability of the data, please refer to the section in front of the RAID. LVM partition can integrate multiple entities together, so that these partitions look like a disk is the same! Also, you can add or remove other entities managed by LVM partition to the disk which in the future. Thus, the use of the entire disk space, it is quite resilient ah! Since LVM so easy to use, let's try

What is LVM: PV, PE, VG, LV sense
LVM full name is the Logical Volume Manager, Chinese can be translated as a logical volume manager. It is called "reel" probably because the filesystem can be lengthened or shortened like a scroll bar with the rules! LVM practice to several entities of partitions (or disk) appears to be through a combination of software is separate large disk (VG), and then dividing this big disk becomes available again after the dividing grooves (LV) and eventually will be able to mount use. But why such a system can be expanded or reduced filesystem it? In fact, with a project called PE about! We have to come under a good chat for these projects!
Physical Volume, PV, entity Reel

Our actual partition requires adjustment system identifier (system ID) becomes 8E (LVM identification code), and then through pvcreate command will he transformed into LVM bottom entity reel (PV), then it is possible to take advantage of the PV ! The party is to adjust the system ID is through fdisk it!
Volume Group, VG, reel group

LVM disk is large so-called PV integrated into the many things that VG is it! So LVM VG is the combination of the big disk! I think just fine. Then the maximum number of large disk capacity can be to do? This PE to be described under the relevant Oh ~ because each VG can only contain a maximum of 65 534 PE only. If you are using LVM default parameters, then a VG up to 256GB of capacity ah! (Refer to the PE described below)
the Physical Extend, PE, entity block extending
LVM default 4MB of PE blocks, but only up to the LVM VG containing 65,534 PE, so the default LVM VG will 4M * 65534 / (1024M / G) = 256G. The PE is very interesting Oh! He is the smallest of the entire LVM storage block, that is, in fact, our data files are written by PE handled. Simply put, the PE bit like block size of the file system inside it. I say it should be easier to understand, right? The adjustment will affect the maximum capacity of PE VG Oh!

Logical Volume, LV, logic Reel

The final will be cut VG LV, similar to pound division is the last slot of the LV can be formatted to use it! So whether you can specify the size of the LV it freely? Of course not! Since PE is the smallest unit of storage of the entire LVM, the LV size in relation to the total number of PE in this LV. In order to facilitate users to use LVM to manage their systems, so the LV device file name is usually specified style as "/ dev / vgname / lvname" in!

The following is a schematic diagram lvm:
Cloud host dynamic expansion of disk storage (LVM) program

Having said that principle, seemingly still a little Mongolia, the next things that practice -

2, practice

Corporate offices set vmwa private cloud base, to develop, test, provide Virtual Machine environment, there is often a lack of disk space, then give the system a machine disk / partition 30G to 50G expansion
first edit in vmware cluster -> the disk expansion to 50G as shown:

Cloud host dynamic expansion of disk storage (LVM) program
Next to the virtual machine operating steps as follows:
Step:
1), adding a new formatted disk space (it may be a separate new disk)
2), was added to modify the partition 8e format
3), the refresh partition
4), create pv (the pvcreate)
. 5), extension VG of
. 6), expansion LV

The actual operation is as follows:
the fdisk -l / dev / SDB
n-
P
2
T
8E
W

Does not restart to display the new partition information
partx -a / dev / sdb2

创建新pv
pvcreate /dev/sdb2
扩展现有VG Name
vgextend vg_daemon6 /dev/sdb2
lv扩容:
#lvextend -L +20G /dev/vg_daemon6/LogVol00 # 注意 /dev/vg_daemon6/LogVol00 是通过df -TH 查询得到 的文件系统路径
Size of logical volume vg_daemon6/LogVol00 changed from 32.20 GiB (14321 extents) to 50.80 GiB (25649 extents).
Logical volume LogVol00 successfully resized.

刷新分区信息:
ext4:
#resize2fs /dev/mapper/vg_daemon6-LogVol00
xfs:
xfs_growfs /dev/mapper/centos-root

以上是基于lvm扩容,有时间服务器并没有基于lvm分区,如何是好?

3、扩容方法二

前提也是针对现有分区进行扩容
第一步也是在vmware集群或云平台上给物理机添加磁盘再通过工具在线扩容,可能需要重启

Installation Tool:
yum the install Cloud -Y-utils
expansion before the detection zone, the following are avoided ext4 xfs formatted using e2fsck tool
xfs_repair -f / dev / SDA
growpart / dev / SDA. 1
xfs_growfs / dev / sda1
further reference please here Please add a link description

Conclusion:

Before the expansion, the best is a good backup important data, in case of emergency

Guess you like

Origin blog.51cto.com/dyc2005/2411605