In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Blog structure what is the LVMLVM PV, VG, PE, LV expand LV capacity LVM disk snapshot LVM-related instruction aggregation
What is LVM:
The focus of LVM is "flexibility to adjust the capacity of filesystem! not on performance and data security."
If you need the read-write performance of files or the reliability of data, you should use RAID disk arrays.
LVM can integrate multiple entity partition together to make these partitions look like a disk! Moreover, other entities partition can be added or removed to this LVM managed disk in the future.
PV, VG, PE, LV in LVM:
The full name of LVM is Logical Volume Manager, and it can be translated as logical scroll administrator in Chinese.
LVM's approach is to combine the partitions (or disk) of several entities into a seemingly independent large disk (VG), and then partition the large disk into a usable partition (LV), and finally be able to mount and use it.
Physical Volume, PV, solid Scroll
Our actual partition (or Disk) needs to adjust the system identification code (system ID) to 8e (the identification code of LVM), and then convert it to the lowest physical scroll (PV) of LVM under the instruction of pvcreate before we can take advantage of these PV! The way to adjust system ID is through gdisk.
Volume Group, VG, scroll group
It is composed of one or more physical volumes, called volume groups, in which physical volumes can be dynamically added or removed. Many physical volumes can be grouped into different volume groups, and the name of the volume group is defined by the user.
The so-called LVM big disk is the thing that integrates a lot of PV into this VG! So VG is a big disk combined with LVM!
So what is the maximum capacity of this large disk? (related to the format version of PE and LVM)
By default, when using a 32-bit Linux system, basically LV can only support a maximum of 65534 PE. If the default PE is 4MB, the maximum capacity can only reach about 256GB. However, this problem no longer exists on 64-bit Linux systems! There is almost no capacity limit for LV
Physical Extent, PE, entity scope block
LVM defaults to 4MB's PE block, while LVM's LV can only contain up to 65534 PE (in lvm1 format) on 32-bit systems, so the default LVM's LV will have 4M*65534/ (1024M/G) = 256g.
It is the smallest storage block in the entire LVM, that is, our file data is actually processed by writing to PE. (block size similar to file system)
Logical Volume, LV, logical scroll
Logical volumes are built on sub-volume groups, which are not directly related to physical volumes. for logical volumes, each volume group is a whole, and a small piece of space is "cut" from the whole as the basis for users to create a file system. This small piece of space is called logical volume. After using mkfs and other tools to create a file system on logical volumes, it can be directly mounted to the directory in the Linux operating system.
The final VG will also be cut into LV, and this LV is the final similar partition that can be used by formatting.
So can LV specify the size at will? (no)
Since the PE is the smallest unit of storage for the entire LVM, the size of the LV is related to the total number of PE in this LV.
To make it easy for users to use LVM to manage their systems, the device file name of LV is usually specified as "/ dev/vgname/lvname" style!
VG phase vgcreate: is the instruction to create VG: vgscan: search for the existence of VG on the system vgdisplay: display the current VG status on the system vgextend: add additional PVvgreduce in the VG: remove PVvgchange in the VG: set whether VG starts (active) vgremove: delete a VG LV phase lvcreate: create LV lvscan: query the LV lvdisplay above the system: display the LV status above the system lvextend: add capacity lvreduce in LV Reduce capacity in LV lvremove: delete a LV lvresize: resize the capacity of LV
The order in which logical volumes are created and used: create physical volumes → create volume groups → create logical volumes → formatted mount
Common LVM logical volume and file system management commands:
Pvscan command: used to scan all physical volumes in the system and output relevant information
Pvcreate command: used to convert a partition or an entire hard disk into a physical volume, mainly by adding LVM attribute information and dividing PE storage units (this command requires the device file of the hard disk or partition as a parameter, which can be multiple)
Pvdisplay command: used to display the details of the physical volume. You need to use the specified physical volume as the command parameter. The information of all physical volumes will be displayed by default.
Pvremove command: used to restore physical volumes to normal partitions or disks, no longer used in the LVM system, the removed physical volumes will not be recognized by pvscan.
Volume group management commands:
Vgscan command: used to scan the LVM volume group and related information in the system to be established. Cl volume groups can be listed by executing the command.
Vgcreate command: used to create one or more physical volumes as a volume group.
[root@localhost ~] # vgcreate web_document / dev/sdb1 / dev/sdb2 # uses physical volumes / dev/sdb1, / dev/sdb2 to create a volume group named web_document.
Vgdisplay command: used to display the details of each volume group in the system, using the specified volume group name as the command parameter (all volume group information will be displayed when the volume group name is not specified)
Vgremove command: used to delete the specified volume group, using the specified volume group name as a parameter.
Vgextend command: used to expand the disk space of a volume group. When you create a new physical volume and need to add it to an existing volume group, you can use the vgextend command, whose first argument is the name of the volume group that needs to be extended, followed by the physical volumes that need to be added to the volume group.
Logical volume management commands:
Lvscan command: used to scan established logical volumes and related information in the system. The command allows you to list the logical volumes in the cl volume group.
Lvcreate command: used to split space from a specified volume group to create a new logical volume. You need to specify the logical volume size, name, and volume group name as parameters.
Lvdisplay command: used to display the details of a logical volume. You can specify the device file of the logical volume as a parameter, or use the volume group name as a parameter to display information about all logical volumes in the volume group
Lvextend command: the space used to dynamically extend logical volumes, which can be extended by dividing additional space from the volume group when there is insufficient space for the logical volumes currently in use. As long as you specify the size of the capacity to be increased and the file location of the logical volume device, the prerequisite is that there is still unallocated disk space in the volume group, otherwise the volume group capacity needs to be expanded first.
Vcreate command: used to delete the specified logical volume and directly use the device file of the logical volume as a parameter.
Configuration case
Create a logical volume
Format logical volumes to create an XFS file system.
Mounting
If you add or delete a logical volume, use the command "xfs_growfs mount point" to update the logical volume!
1. Backup of xfs file system-- xfsdump command:
Limitations of the xfsdump command: xfsdump does not support unmounted file systems, so you can only back up mounted ones; Xfsdump must use the permissions of root to operate (involving file system relations); Xfsdump can only back up xfs file systems; data backed up by Xfsdump (files or storage media) can only be decompressed by xfsrestore; Xfsdump distinguishes each backup file through the UUID of the file system, so you cannot back up two file systems with the same UUID. Common options:-L:xfsdump records the session header of each backup, here you can fill in a simple description for this file system;-M:xfsdump can record the header of storage media, here you can fill in a simple description of this media. -l: it is the lowercase of L, that is, the specified level. There are 10 grades in all. The default is 0, that is, full backup, and 1x9 refers to incremental backup. -f: somewhat similar to tar, followed by the resulting file, you can also take an example such as / dev/st0 device file name or other general file name;-I: uppercase "I" to list the current backup information status from / var/lib/xfsdump/inventory. Root@localhost ~] # xfsdump-l O-L boot_all-Mboot_all-f / srv/boot.dump / boot# record the filename of the full backup as / srv/boot.dump# if you enter interactive mode without adding-L and-M options xfsdump: using file dump (drive_simple) strategyxfsdump: version 3.1.4 (dump format 3.0)-type ^ C for status and controlxfsdump: WARNING: most recent level 0 dump was interrupted But not resuming that dump since resume (- R) option not specifiedxfsdump: level 0 dump of localhost.localdomain:/boot # start backing up native / boot system xfsdump: dump date: Wed Aug 21 00:04:00 2019 # backup time xfsdump: session id: 2ab52f27-54d8-4cb3-b99f-5f78601afeed # IDxfsdump of dump: session label: "boot_all" # simply give a name memory # start backup program xfsdump: ino map phase 1: constructing initial dump listxfsdump : ino map phase 2: skipping (no pruning necessary) xfsdump: ino map phase 3: skipping (only one dump stream) xfsdump: ino map construction completexfsdump: estimated dump size: 146934272 bytesxfsdump: creating dump session media file 0 (media 0 File 0) xfsdump: dumping ino mapxfsdump: dumping directoriesxfsdump: dumping non-directory filesxfsdump: ending media filexfsdump: media file size 146605160 bytesxfsdump: dump size (non-dir files): 146370000 bytesxfsdump: dump complete: 1 seconds elapsedxfsdump: Dump Summary:xfsdump: stream 0 / srv/boot.dump OK (success) xfsdump: Dump Status: SUCCESS [root@localhost ~] # xfsdump-I # check whether there are any files backed up by xfsdump
2. Restore the xfs file system-- xfsrestore command:
The common options are as follows:-I: uppercase "I" has the same output as xfsdump! Can query backup data, including Label name and backup time, etc.-f: followed by backup files! Tape drives such as / dev/st0 are likely to be connected in the enterprise! -L: data that can be queried with "- I". Enter after this option;-s: you need to connect to a specific directory, and you can also restore a file or directory;-r: if you are using files to store backup data, this is not needed. If there are multiple files on a disk, you need to use it to achieve cumulative recovery.-I: enter interactive mode (generally not required) [root@localhost ~] # xfsrestore-I # View backup file data [root@localhost ~] # xfsrestore-f / srv/boot.dump-L boot_all / boot# directly overwrite the backup data back
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.