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/01 Report--
How to analyze linux LVM, I believe that many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. Create and delete steps
1) create: linux partition-- > pv-- > vg-- > lv-- > fs-- > mount
2) Delete: umount-- > lv-- > vg-- > pv-- > linux partition
2.linux partition
In linux, we often partition disks by fdisk. But for disks above 2T, you have to use the parted command to partition.
1) GPT disk and MBR disk
Disks that use GUID partition tables are often called GPT disks. Unlike the original MBR disks, GPT disks do not have the limit of four primary partitions and can be set up to 128partitions. GPT disks are usually partitioned with the parted command.
2) Operation
-- View disk partitions
[root] # fdisk-l
-- partitioning sda
[root] # parted / dev/sda
-- rescan the partition
[root] # partprobe
-- after viewing the partition
[root] # fdisk-l
3 PV Management
1) create PV (pvcreate)
[root] # pvcreate / dev/sda3
2) View PV (pvs or pvscan)
[root] # pvs
[root] # pvscan
3) View PV details (pvdiskplay)
[root] # pvdisplay / dev/sda3
4) Delete PV (pvremove)
[root] # pvremove / dev/sda3
4.VG management
1) create VG (vgcreate)
Syntax: vgcreate [- s] vg0 / dev/sdb {1meme 2jue 3.}
-- among them:
-s: specify the size of the expansion block (PE). The default is 4MB. It can be 8m _ pr _ 16m _ 32m _ 32m _ 64m ·L _ 16G, but a LV can have up to 65532 expansion blocks.
Vg0: the newly created VG name.
/ dev/sdb {1 PV,PV 2pm 3.}: writable multiple CDs are separated by spaces.
[root] # vgcreate-s 16m testvg / dev/sda3
2) View VG (vgs or vgscan)
[root] # vgs
[root] # vgscan
3) View VG details (vgdisplay)
[root] # vgdisplay testvg
4) vg extension (vgextend)
-- using fdisk to create a new partition
[root] # fdisk / dev/sda
Command (m for help): n
Select (default e): e
Selected partition 4
First sector (117187501-209715199, default 117188608):
Last sector, + sectors or + size {KMagne Mpeng} (117188608-209715199, default 209715199):
Command (m for help): P
Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (117190656-209715199, default 117190656):
Using default value 117190656
Last sector, + sectors or + size {KMagne Mpeng} (117190656-209715199, default 209715199): + 20G
-- change partition type to lvm
Command (m for help): t
Partition number (1-5, default 5):
Hex code (type L to list all codes): 8e
Command (m for help): W
-- check partition again
[root] # fdisk-l
-- notify the system of core partition changes
[root] # partprobe
-- create a PV
[root] # pvcreate / dev/sda5
-- extended vg
[root] # vgextend testvg / dev/sda5
5) vg reduction
[root] # vgreduce testvg / dev/sda5
6) vg deletion
[root] # vgremove testvg
5 Management of LV
1) creation of LV (lvcreate)
Syntax 1:lvcreate-L 512m-n data testvg-L 512m
-- among them
Set the size of the LV to 512m.
-n data: set the name of LV to data.
[root] # lvcreate-L 510m-n date testvg
Syntax 2:lvcreate-l 32-n data testvg-l 32
-- among them
The resulting LV uses 32 extension blocks, and the LV size = 32*PE (default 4m) is 128m.
-the name of n data:LV. Vg0: the setting is the LV generated by that VG.
Vg0: the setting is the LV generated by that VG.
[root] # lvcreate-l 10-n data testvg
2) View LV (lvs or lvscan)
[root] # lvs
3) View LV details (lvdisplay)
[root] # lvdisplay testvg
4) format LV (mkfs.ext3)
[root] # mkfs.ext3 / dev/testvg/data
5) increase LV (lvextend)
[root] # lvextend-L + 160m / dev/testvg/data
-- among them
Resize2fs is required for it to take effect immediately.
[root] # resize2fs / dev/testvg/data
6) reduce LV size (lvreduce)
[root] # lvreduce-L 160m / dev/testvg/data
[root] # resize2fs / dev/testvg/data
7) Delete LV (lvremove/vg/lv)
[root] # lvremove / dev/testvg/date
6) Mount the file system
[root] # mkfs.ext3 / dev/testvg/data
[root] # mkdir / data
[root] # mount / dev/testvg/data / data
7 lvm Snapshot
1) create a snapshot
Syntax: lvcreate-l 64-s-n databackup / dev/testvg/data
-- among them
-l 64: specifies 64 extension blocks for the snapshot.
Total capacity = 64 * single expansion block size
-n databackup: the name of the snapshot generated.
/ dev/testvg/data: source LV name.
[root] # lvcreate-L 160m-s-n databackup / dev/testvg/data
2) View LVM Snapshot (lvscan)
[root] # lvscan
3) View snapshot details (lvdisplay)
[root] # lvdisplay / dev/testvg/data
4) deletion of snapshots (lvremove)
[root] # lvremove / dev/testvg/databackup
After reading the above, do you know how to parse linux LVM? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.