In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
A brief introduction to LVM
LVM is a logical mechanism for managing disk partitions in the Linux system. It is a logical layer built on hard disks and partitions and under the file system. It shields the underlying disk partition layout when establishing the file system, and can dynamically adjust the disk capacity while keeping the existing data unchanged, thus improving the flexibility of disk management.
When automatic partitioning is selected during the installation of the CentOS system, the LVM partitioning scheme is adopted by default, and manual configuration is no longer required. If you have special needs, you can also use the disk customization tool provided by the installation wizard to adjust the LVM partition. It is important to note that the "/ boot" partition cannot be created based on LVM and must be independent.
II. LVM mechanism
1. PV (physical volume)
Physical volume is the basic storage device of LVM mechanism, which usually corresponds to a normal partition or the whole hard disk. When you create a physical volume, a reserved block is created in the head of the partition or hard disk to record the attributes of the LVM, and the storage space is divided into basic units (Physical Extent,PE) with the default size of 4MB, thus forming the physical volume.
2. VG (volume group)
It is composed of one or more physical vouchers, which is called volume group, in which physical vouchers can be dynamically added or removed.
3. LV (logical volume)
Logical volumes are built on top of volume groups and are not directly related to physical volumes. For logical volumes, each volume group is a whole, from which a small piece of space is "cut" as the basis for users to create a file system, which is called a logical volume.
3. Manage LVM
1. Common LVM management commands
2. PV physical volume management
(1) pvscan command
Pvscan is used to scan all physical volumes in the system and output relevant information.
(2) pvcreat command
Pvcreat is used to convert a partition or an entire hard disk into a physical volume, mainly by adding LVM attribute information and dividing PE storage devices.
As shown in the figure, first convert the partitions of our three disks to LVM type (for more information on how to create partitions, please refer to disk and File Management section).
Then execute the "pvcreate / dev/sd {b.. d} 1" command to quickly replace the hard drive into a physical volume, and you can execute the "pvscan" command to view the physical volume.
(3) pvdisplay command
Pvdisplay is used to display the details of physical vouchers. You need to use the specified physical voucher volumes as command parameters. By default, the information of all physical volumes will be displayed.
(4) pvremove command
Pvremove restores the physical volume to a normal partition or disk, which is no longer used in the LVM system, and the removed physical volume will not be recognized by pvscan.
3. VG volume group management
(1) vgscan command
The vgscan command is used to scan established LVM volume groups and related information in the system.
(2) vgcreat command
Vgcreat is used to create one or more physical volumes as a volume group, the first command parameter is used to set the name of the new volume group, and the next time it specifies the main physical voucher parameters that need to be typed into the volume group.
As shown in the figure, we execute the "vgcreate mailbox / dev/sd {b. D} 1" command to create a volume group, but we cannot view the volume group information by executing the "vgscan" command.
(3) vgdisplay command
Vgdisplay is used to display the details of each volume group in the system, and you need to use the specified volume group as the command parameter.
We execute the "vgdisplay" command to view the volume group information.
(4) vgremove command
Vgremove is used to delete the specified volume group and specify the volume group name as a parameter.
(5) vgextend command
Vgextend is used to expand the disk space of the volume group.
4. LV logical volume management
(1) lvscan command
Lvscan is used to scan established logical volumes and related information in the system.
(2) lvcreat command
Lvcreat is used to subdivide space from a specified volume group to create innovative logical volumes.
As shown in the figure, we execute the "lvcreate-L 60G-n mbox01 mailbox" command to create logical volumes.
(3) lvdisplay command
Lvdisplay is used to display the details of logical coupons. You need to specify the device file of logical coupons as a parameter, or you can use the volume group name as a parameter to display the information of all logical coupons in the volume group.
In the figure, we execute the "lvdisplay" command to view the logical volume information.
(4) lvextend command
Lvextend is used to dynamically extend the space of logical volumes, which can be extended by dividing additional space in the volume group when there is insufficient space for logical volumes currently in use.
(5) lvremove command
Lvremove is used to delete the specified logical volume and directly use the device file of the logical voucher as a parameter.
Formatting and mounting logical volumes
1. As shown in the figure, we execute the "mkfs-t xfs / dev/mailbox/mbox01" command to format the logical volume.
2, execute "mkdir / opt/mbox {1... 2}" to create two mount points, then execute the "vim / etc/fstab" command to enter the configuration file, press the G key and then press the o key to go to the trailing line to write. (press the Tab key in the blank space of "/ dev/mailbox/mbox01 / opt/mbox01 xfs defaults 00") Save and exit after writing the number, and automatically mount it after the execution of the "mount-a" command.
5. Disk quota
1. Conditions for realizing disk quota
Linux kernel support is required
Install xfsprogs and quota software packages
2. Characteristics of Linux disk quota.
Scope: for the specified file system (partition)
Restricted object: user account, group account
Type of limit: disk capacity, number of files
Limit method: soft limit, hard limit
3. Enable disk quota support
Add usruota and grquota mount parameters
4. Disk quota management
(1) Editing quota settings for user and group accounts
The common options are as follows.
-u: specify the user
-g: specify a group
-x: enable expert mode
-c: use command execution
Restricted field
Bsoft: soft limit (expire for 7 days)
Bhard: hard limit
Isoft: soft node (expired for 7 days)
Ihard: hard nod
(2) verify disk quota function
Switch to the partition where the quota is set (mount directory)
Create a specified number of files: use the touch command, or the cp command
Create a file of specified capacity: use the dd command, or the cp command
(3) check the usage of quotas
The common options are as follows.
-a: view all quotas
-I: view node information
-b: output report
-u: view user quota
-g: view group quota
Practice part:
1. First, we execute the command "rpm-qa | grep xfprogs" to see if there is a "xfprogs" function in the kernel; then search for "quota" in "xfprogs"; and then execute "setenforce0" to turn off the enhanced security option function.
2. Execute the "vim / etc/fstab" command to write the configuration file. Add the ", usrquota,gpquota" mount parameter to "/ dev/mailbox/mbox02 / opt/mbox02 xfs defaults 00".
3. Execute the "umount + mount point" command to unmount, and then re-mount the device to run the mount parameters!
4. Execute the command "xfs_quota-x-c'limit-u bsoft=10M bhard=30M isoft=4 ihard=6 zhangsan'/mailbox/" to set the user quota.
Note: once one condition in the quota setting exceeds the quota, the other condition cannot be implemented!
5. Execute the "xfs_quota-x-c'report-abi'" command as shown in the figure to view the current quota usage in the form of a report.
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.