In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Basic application, extension and reduction implementation of Lvm
What is Lvm: logical volume manager, logical volume management
What can we achieve by learning lvm? The function of Lvm is to shield the underlying disk layout, so it is convenient to dynamically adjust the disk capacity, and then manage the disk efficiently.
Note: boot partition is used to store boot files, and lvm mechanism cannot be applied.
Learn lvm first to learn about pv,vg.
How did pv,pv come from and how was it created? Pv is physical volume (physical volume), an entire hard disk or a normal partition created by disk partitioning tools such as fdisk. It also includes many PE (physical extent base units) with the default 4MB size
What is vg, and how to create vg? Vg (volume group) is a whole composed of one or more physical volumes.
Relationship diagrams between pv,vg,lv in lvm: lvm logical volume management diagram
Lvm related commands
Scan; scan
# pvscan
# vgscan
# lvscan
Show; display (Show details)
# pvdisplay
# vgdisplay
# lvdisplay
# pvs/vgs/lvs; display device list (profile display)
Create; create
Create a physical volume
# pvcreate device
Create a volume group
# vgcreate VGname PV1 PV2 PV3...
Create a logical volume
# lvcreate-L size-n LVname VG
Expand
Logical volume expansion
# lvextend-L + size / dev/VGname/LVname
Volume group extension
# vgcreate VGanme / path/to/PV
Logical volume reduction: # lvreduce-L-size / dev/VGname/LVname
Remove; remove.
Physical volume removal
# pvremove / dev/device
Volume group removal
# vgremove / dev/VG
Logical volume removal
# lvremove / dev/VG/LV
Reread the file system size command
Resize / PATH/TO/LV (path to logical volumes)
The block group directory appears only after the logical volume has been created.
Pay attention
1. The physical volume cannot be formatted, otherwise the physical volume will not be recognized and data loss will occur
two。 Logical volumes can increase the capacity dynamically, but when you want to reduce the capacity, you should use the command to inform the system of the size of the modified file before clipping, otherwise the file will be damaged and data will be lost.
Principle: after the logical volume creates a file system, it will read and write data in the original divided disk capacity. Increasing the capacity will not affect the read and write operation of the original area, while reducing the capacity will operate within the capacity identified by the file system, which will destroy the file system and cause data loss (is it no problem to perform the operation after unmounting the file system? )
The example implements the lvm creation process:
Description: the company's mail server due to the large number of users, mail storage needs a lot of space, taking into account the need for dynamic expansion, plans to add two SCSI hard drives and build LVM logical volumes, mount to the "/ mail directory specifically for storing mail data."
Step 1: convert physical volumes
Use the fdisk command to plan two partitions with the type set to "8e" / dev/sdb1, / dev/sdc1
Use the pvcreate command to convert the above partitions to physical volumes
2: create a volume group:
Use the vgcreat command to create a volume group mail_store that includes the above two physical volumes
3: create a logical volume
Use the lvcreate command to create a logical volume mail, delimiting 60GB space from the volume group mail_store
Then use the mkfs command to create an ext4 file system
Additional operations: capacity expansion and reduction implementation
4: bit logic volume expansion
Use the lvextend command to expand the logical volume mail, and delimit the 10GB from the volume group mail_store to the logical volume mail
5: reduce the same command as step 4 to use lvreduce
Note: lvm created and formatted to create the file system must be mounted before use, expand and shrink after the file system can not show the expanded or reduced size, then you have to use the resize2fs command, it can stand on the file system to read, so that the df command can be used to view the expanded size displayed on the file system.
Its implementation order is as follows:
[root@bucktan] # lvextend-L + 10G / dev/mail_store/mail
[root@bucktan ~] # df-lh (at this time, the result shows that it has not been expanded or reduced)
[root@bucktan ~] # resize2fs / dev/mail_store/mail
[root@bucktan ~] # df-lh (at this time, the result shows that the capacity is expanded or reduced)
Lvm Snapshot; snapshot, online backup
Working mechanism:
Lvm snapshots back up metadata, not the data itself
When the data is about to change, start the snapshot, copy the original data to the snapshot, and then write the new data to the original data block. no matter how the data changes, the snapshot saves the data before the initial (first) data change. if you need to restore, the original data copied in the snapshot will be overwritten to the original data block.
Note that snapshots are also logical volumes. Snapshots can only back up logical volumes, and can only back up logical volumes in the same volume group.
Several Concepts of data backup
Cold backup; unmount the file system, unable to read or write to the file system
Warm backup; do not unmount the file system, can read the file system, can not write
Hot backup; do not unmount the file system, can read and write to the file system
Snapshot volume creation;-s
Lvcreate-s-L size-n name VGname-p {r | rw} / path/to/LV
-s; create a snapshot volume
-L; specify the size of the snapshot volume
-n; command to specify snapshot volume
-p; specify snapshot volume permissions {r | rw}
/ path/to/LV; snapshot backup object (logical volume)
Snapshot volume is used; once the snapshot volume is created, the data of the specified logical volume will be automatically backed up after mounting
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.