Understand LVM 2 LVM Components

Source: Internet
Author: User
(I) physical volume (1) PV Overview

 

A device must be initialized to a PV before it can be used by LVM. This will place a tag at the start of the device, also known as "8e ".
By default, LVM labels are placed in 2nd 512-byte sectors.
However, you can place the PV tag in any of the first four 512-byte sectors of a disk.
An LVM label also exists after restart and is known in a cluster.
LVM labels are used to identify a device as a PV
LVM labels include:
① Random and unique identifier (UUID) of the device)
② Indicate the size (in bytes) of the block Device)
③ Record the storage location of LVM metadata
④ Device sequence information (because the device may appear in any order when the system starts)

(2) LVM metadata

 

The LVM metadata contains detailed configuration information about the LVM volume group. By default, metadata of a volume group is stored in a special area of each PV in the volume group. Metadata is small and stored in ASCII format.
Currently, LVM allows the storage of 1, 1, and 2 copies of metadata on each pv. The default value is 1.
Once you copy the number of metadata stored on each PV, you cannot change it later. (That is, once PV is added to VG, modification is not allowed)
The first copy is placed at the start of the device, behind the PV tag. If there are 2nd copies, they are placed at the end of the device.
If you accidentally overwrite the data at the starting position, you can use 2nd copies of the Ending position to restore the data.

 

(3) LVM physical volume Layout

 

The LVM label is placed in 2nd sectors, followed by the metadata of the volume group where the PV is located, and then the available space. The first sector may be the start sector.

 

(4) partition as LVM

 

LVM allows you to use partitions for PV, rather than the entire disk. However, we recommend that you divide the entire disk into one partition.
Cause:
1. Ease of management. In addition, if multiple PVS exist on a disk, the kernel will warn that the partition type is unknown at startup.
2. Strip performance. Because LVM cannot determine whether two PVS are on the same disk, If you create a striped logical volume on such PV, the performance will decrease.
Of course, you can consider using a testing machine and a single disk and multiple zones for PV.

 

(Ii) volume group

 

In a VG, the disk space is divided into fixed units, called extent. We usually call it "pe ".

PE is the smallest storage unit of the entire LVM, that is to say, in fact, our file data is written to PE for processing.

In short, PE is like a block in Oracle.

The focus of LVM is that it can elastically adjust the capacity of the file system. This is achieved by exchanging PES for data conversion and moving the PES in the original LV to other devices to reduce the LV capacity,

Or add the PE of other devices to this LV to Increase the capacity.
The following figure shows the correlation between PE and VG:

To expand this VG, add other PVS. The most important LV is to be expanded by adding a pe that is not used in the VG!

 

(Iii) logical volume

 

VG is divided into multiple logical volumes. Three options are available: Linear logical volume, striped logical volume, and image volume.


① Linear logical volume


A linear logical volume aggregates multiple PVs and is called a logical volume. For example, if you have two 60 GB disks, you can create a 120 GB logical volume.
Two physical storage devices can be regarded as the first connected device.
When a linear volume is created, a range of PES will be allocated to LV in order.

 

The PV used to create the LV does not need the same size

 

You can create multiple linear logical volumes from the available PES.

 

② Strip logical volume

 

You can create a striped logical volume to control how data is written to a physical volume. This can improve performance for large continuous reads and writes.
Strip improves performance by writing data to a predetermined number of PVS cyclically. Through striping, I/O can be performed in parallel. In some cases, the performance can be improved to almost linear multiples.
The following is a strip logical volume distributed on three PVS. The principle is the same as RAID-0.
The difference is that raid-0 requires the same size of each member device, while LVM does not.

In a strip logical volume, the size of the stripe cannot exceed the size of the PE.
To expand a striped logical volume is not as easy as to expand a linear logical volume. Therefore, the volume group where the logical volume is located must have free space to move data.
For example, if you have a striped lv that spans two pvs, if you want to expand it, you must add at least two PVS to achieve the expansion of the Strip logical volume.

 

③ Logical volume of the image

 

When a part of an image LV becomes invalid (for example, a PV becomes invalid), the image LV becomes a common Linear LV and can still be accessed.
LVM supports image volumes. When creating an image logical volume, LVM ensures that data written into an underlying PV is written into another PV.
You can use LVM to create a logical volume with multiple images
An LVM image device divides the source devices into different regions, with a size of 512 KB. LVM maintains a log, which is used to track that (some) region for synchronization. '
This log can be stored on the disk, and will not be lost after restart, or it can be read into the memory.

Currently, the cluster does not support image volumes.

 

④ Snapshot volume

 

The LVM snapshot function allows you to create a "virtual" image for a device at a specific time point without interrupting the service.
Like image logical volumes, the snapshot function of LVM is not supported by clusters.
After the snapshot is created, if the source device changes, a copy of the changed region will be made, which can be used to recreate the device in the future.
Because snapshot only copies the changed data area after the snapshot volume is created, the snapshot function only requires a small amount of storage space.
For example, in a rarely updated LV, 3-5% of the space is enough to maintain the snapshot volume.
Note that snapshot is only a virtual copy, not an actual media backup. Snapshot does not replace the common backup process.
Once the snapshot volume is full, it is detached. This is to ensure that the source file system has sufficient space. You should regularly observe the usage of snapshot volumes. The Snapshot volume can be resized.
When you create a snapshot file system, the source file system can still be read and written. If a chunk of the snapshot is changed, the chunk is marked and will not be copied from the original volume.
Snapshot volumes are used as follows:

1. You can back up an LV without detaching the original file system or stopping the application.

2. You can perform fsck on the snapshot volume to determine whether the original file system needs to be repaired.

3. Because the snapshot volume can be read and written, you can tell the application to test the data of the snapshot volume without having to change the original data.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.