Administrators Linux Logical Volume

博文结构
什么是LVM
LVM中PV、VG、PE、LV
扩大LV容量
LVM的磁盘快照
LVM 相关指令汇整

What is LVM:

LVM focus is "elastically adjust capacity filesystem! Performance data in that rather than above preservation.
Reliability If the read and write performance required file or data array with RAID disks should

LVM partition can integrate multiple entities together, so that these partitions looks like a disk the same! Also, you can add or remove other entities in the future to the LVM partition disks managed by them

LVM中PV、VG、PE、LV:

LVM's full name is the Logical Volume Manager, Chinese can be translated as a logical volume manager.

LVM partitions of practice to several entities (or disk) become the software appears to be a combination of a large independent disks (VG), then go through this big disk partitions become available partitions (LV), eventually will be able to mount use.

Physical Volume, PV, entity Reel

Our actual partition (or Disk) need to adjust the system identification code (system ID) becomes 8E (LVM identification code), and then through pvcreate command him turn into LVM bottom entity reel (the PV), then it is possible to these PV take advantage! Adjusting party is the system ID is through gdisk

Administrators Linux Logical Volume

Volume Group, VG, reel group

By one or more physical volumes as a whole, it is called volume groups may be added or removed dynamically physical volumes in the volume group. Can be composed of a plurality of physical volumes of different volume groups respectively, the group name of the volume defined by the user.

LVM disk is large so-called PV integrated into the many things that VG is it! So LVM VG is a combination of large disk!
Then the maximum number of large disk capacity can be to do? (Format version of PE and about LVM)
In the default case, 32-bit Linux systems only support a maximum LV substantially to only 65,534 PE, when using PE default 4MB case, the maximum capacity of the it can only reach about 256GB ~ However, the problem in the above 64-bit Linux system does not exist! LV hardly what capacity constraints

Administrators Linux Logical Volume

Physical Extent, PE, entity range block

LVM default 4MB PE block, but only up to the LVM LV contains 65,534 PE (LVM1 format) on a 32-bit system, the default LVM LV will 4M * 65534 / (1024M / G ) = 256G .
He is the smallest of the entire LVM storage block, that is, in fact, our data files are written by the PE handled. (Block size is similar to the file system)

Logical Volume, LV, logic Reel

Administrators Linux Logical Volume

Logical volume group on the establishment of sub-ah, not directly related to the physical volumes for logical volumes, every volume group is a whole, this whole "cut out" a small space, as users create a file system based on this small piece of space called logical volumes, after creating a file system on the logical volume using tools such as mkfs, it can be mounted directly to the Linux operating system directory to use.

最终的 VG 还会被切成 LV,这个 LV 就是最后可以被格式化使用的类似分区
那么 LV 是否可以随意指定大小呢?(否)
既然 PE 是整个 LVM 的最小储存单位,那么 LV 的大小就与在此 LV 内的 PE 总数有关。
为了方便使用者利用 LVM 来管理其系统,因此 LV 的设备文件名通常指定为“/dev/vgname/lvname ”的样式!

Administrators Linux Logical Volume

Administrators Linux Logical Volume

VG阶段

vgcreate :就是主要创建 VG 的指令
vgscan :搜寻系统上面是否有 VG 存在
vgdisplay :显示目前系统上面的 VG 状态
vgextend :在 VG 内增加额外的 PV
vgreduce :在 VG 内移除 PV
vgchange :设置 VG 是否启动(active)
vgremove :删除一个 VG 
LV 阶段

lvcreate :创建 LV 
lvscan :查询系统上面的 LV 
lvdisplay :显示系统上面的 LV 状态
lvextend :在 LV 里面增加容量
lvreduce :在 LV 里面减少容量
lvremove :删除一个 LV 
lvresize :对 LV 进行容量大小的调整

创建逻辑卷并使用的顺序:创建物理卷→创建卷组→创建逻辑卷→格式化挂载

Administrators Linux Logical Volume

常用的LVM逻辑卷与文件系统管理的命令:

Administrators Linux Logical Volume

pvscan命令:用于扫描系统中所有的物理卷,并输出相关信息

Administrators Linux Logical Volume

pvcreate命令:用于将分区或整个硬盘转换为物理卷,主要是添加LVM属性信息并划分PE存储单位(该命令需要使用硬盘或分区的设备文件作为参数,可以是多个)

Administrators Linux Logical Volume

pvdisplay命令:用于显示物理卷的详细信息,需要使用指定的物理卷作为命令参数,默认时将显示所有物理卷的信息

Administrators Linux Logical Volume

pvremove命令:用于将物理卷还原成普通分区或磁盘,不再用于LVM体系,被移除的物理卷将无法被pvscan识别。

Administrators Linux Logical Volume

卷组管理命令:
vgscan命令:用于扫描系统中以建立的LVM卷组及相关信息。通过执行命令可以列出cl卷组。

Administrators Linux Logical Volume

vgcreate命令:用于将一个或多个物理卷创建为一个卷组。

[root@localhost ~]# vgcreate web_document  /dev/sdb1 /dev/sdb2 
#使用物理卷/dev/sdb1、/dev/sdb2创建名为web_document的卷组。

vgdisplay命令:用于显示系统中个卷组的详细信息,需要使用指定卷组名作为命令参数(未指定卷组名时将显示所有卷组的信息)

Administrators Linux Logical Volume

vgremove命令:用于删除指定的卷组,将指定卷组名作为参数即可。

Administrators Linux Logical Volume

vgextend命令:用于扩展卷组的磁盘空间,当创建新的物理卷,并需要将其添加到已有卷组中时,就可以使用vgextend命令,该命令的第一个参数为需要扩展容量的卷组名称,后面是为需要添加到该卷组中的物理卷。

Administrators Linux Logical Volume


Logical Volume Manager command:

lvscan command: scanning for logical volume and related information systems established. Cl can be listed in the logical volume group command.

Administrators Linux Logical Volume

lvcreate command: used to split from the specified volume group space to create a new logical volume, you need to specify the size of the logical volume, the volume name and the group name as a parameter

Administrators Linux Logical Volume

lvdisplay command: Details for displaying logical volume, the logical volume device file can be specified as parameters, also may be used as a parameter volume group name to display the information for all logical volumes in the volume group

Administrators Linux Logical Volume

lvextend command: dynamic expansion space for the logical volume, the logical volume when there is insufficient space currently in use, you can split the extra space to expand from where the volume group. Just specify the size and the need to increase the capacity of the logical volume device file locations can be provided that the volume group still has not been allocated disk space, otherwise you need to expand the capacity of the volume group.

Administrators Linux Logical Volume

vcreate command: to delete the specified logical volume, the logical volume file directly using the device as a parameter.

Administrators Linux Logical Volume

Configuration Examples


Creating a Logical Volume

Administrators Linux Logical Volume

Formatted logical volume, create an XFS file system.

Administrators Linux Logical Volume


Mounting

Administrators Linux Logical Volume

If adding or deleting a logical volume, use the command "xfs_growfs mount point" updates the Logical Volume!

1, xfs file system backup --xfsdump command:

xfsdump命令的限制:

xfsdump不支持没有挂载的文件系统,所以只能备份已挂载的;
Xfsdump必须使用root的权限才能操作(涉及文件系统的关系);
Xfsdump只能备份xfs文件系统;
Xfsdump备份下来的数据(文件或存储媒体)只能让xfsrestore解压;
Xfsdump是通过文件系统的UUID来分辨各个备份文件的,因此不能备份两个具有相同UUID的文件系统。
常用选项:

-L:xfsdump会记录每次备份的session标头,这里可以填写针对此文件系统的简易说明;
-M:xfsdump可以记录存储媒体的标头,这里可以填写此媒体的简易说明。
-l:是L的小写,就是指定等级,有0~9共10个等级,默认为0,即完整备份,1~9是指增量备份。
-f:有点类似tar,后面接产生的文件,也可以接例如/dev/st0设备文件名或其他一般文件文件名;
-I:大写的“i”,从/var/lib/xfsdump/inventory 列出目前备份的信息状态。
root@localhost ~]# xfsdump -l O -L boot_all -Mboot_all -f /srv/boot.dump /boot
#将完整备份的文件名记录成为/srv/boot.dump
#如果不加-L和-M选项进入互动模式
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsdump: WARNING: most recent level 0 dump was interrupted, but not resuming that dump since resume (-R) option not specified
xfsdump: level 0 dump of localhost.localdomain:/boot  #开始备份本机的/boot系统
xfsdump: dump date: Wed Aug 21 00:04:00 2019  #备份的时间
xfsdump: session id: 2ab52f27-54d8-4cb3-b99f-5f78601afeed  #这次dump的ID
xfsdump: session label: "boot_all"  #简单给予一个名字记忆
#开始备份程序
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 146934272 bytes
xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 146605160 bytes
xfsdump: dump size (non-dir files) : 146370000 bytes
xfsdump: dump complete: 1 seconds elapsed
xfsdump: Dump Summary:
xfsdump:   stream 0 /srv/boot.dump OK (success)
xfsdump: Dump Status: SUCCESS
[root@localhost ~]# xfsdump -I  #查看有没有文件被xfsdump备份过的数据

2, xfs file system restore --xfsrestore command:

常用选项如下:

-I:大写的“i”跟xfsdump相同的输出!可查询备份数据,包括Label名称和备份时间等;
-f:后面接的就是备份文件!企业中很有可能会接/dev/st0等磁带机!
-L:可用“-I”查询到的数据。在这个选项后输入;
-s:需要接某特定目录,也能复原某一文件或目录;
-r:如果是用文件来存储备份数据,那这个就不需要使用。如果是一个磁盘内有多个文件,需要使用它来达成累积复原;
-i:进入互动模式(一般不需要)
[root@localhost ~]# xfsrestore -I  #查看备份文件数据
[root@localhost ~]# xfsrestore -f /srv/boot.dump -L boot_all /boot#  直接将备份数据覆盖回去

Guess you like

Origin blog.51cto.com/14400213/2449075