In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to quickly create LVM under CentOS7. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
LVM is a logic layer added between the hard disk partition and the file system, shielding the underlying hard disk partition layout for the file system, and providing an abstract disk volume to establish the file system on the disk volume. The administrator can use LVM to dynamically resize the file system without repartitioning the hard disk, and the file system managed by LVM can span the physical hard disk.
Environment: CentOS7 virtual machine with a 2G hard disk mounted
2. Configuration process:
2. Configuration process:
1. Partition the hard disk:
Create three partitions, the first two 512m, the last one has a default size of more than 1G, and the last one specifies the size by default, depending on your environment. It would be nice to change the partitions to Linux LVM format.
Command (m for help): P / / View partition table
Disk / dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbe89015f
Device Boot Start End Blocks Id System
Command (m for help): n / / create a partition
Partition type:
P primary (0 primary, 0 extended, 4 free)
E extended
Select (default p): P / / primary partition
Partition number (1-4, default 1): 1
First sector (2048-4194303, default 2048):
Using default value 2048
Last sector, + sectors or + size {Kjens Mpeng G} (2048-4194303, default 4194303): + 512m / / specified size
Partition 1 of type Linux and of size 512 MiB is set
Command (m for help): n
Partition type:
P primary (1 primary, 0 extended, 3 free)
E extended
Select (default p): P
Partition number (2-4, default 2): 2
First sector (1050624-4194303, default 1050624):
Using default value 1050624
Last sector, + sectors or + size {KMagneMMagneG} (1050624-4194303, default 4194303): + 512m
Partition 2 of type Linux and of size 512 MiB is set
Command (m for help): n
Partition type:
P primary (2 primary, 0 extended, 2 free)
E extended
Select (default p): P
Partition number (3pr 4, default 3):
First sector (2099200-4194303, default 2099200):
Using default value 2099200
Last sector, + sectors or + size {KMagneMje G} (2099200-4194303, default 4194303): / / all sizes left by default
Using default value 4194303
Partition 3 of type Linux and of size 1023 MiB is set
Command (m for help): W / / Save exit
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.
[root@localhost ~] # fdisk / dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): P
Disk / dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbe89015f
Device Boot Start End Blocks Id System
/ dev/sdb1 2048 1050623 524288 83 Linux
/ dev/sdb2 1050624 2099199 524288 83 Linux
/ dev/sdb3 2099200 4194303 1047552 83 Linux
Command (m for help): t / / modify partition type
Partition number (1-3, default 3): 1 / / Select partition
Hex code (type L to list all codes): 8e / / change to Linux LVM type partition, 8e is the partition code, l can see
Changed type of partition 'Linux' to' Linux LVM'
Command (m for help): t
Partition number (1-3, default 3): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to' Linux LVM'
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to' Linux LVM'
Command (m for help): P
Disk / dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbe89015f
Device Boot Start End Blocks Id System
/ dev/sdb1 2048 1050623 524288 8e Linux LVM
/ dev/sdb2 1050624 2099199 524288 8e Linux LVM
/ dev/sdb3 2099200 4194303 1047552 8e Linux LVM
Command (m for help): W
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.
2. Create a physical volume:
Commands: pv series command
Root@localhost ~] # pv
Pvchange pvcreate pvmove pvresize pvscan
Pvck pvdisplay pvremove pvs
Create physical volumes: select the partition you want to create
[root@localhost ~] # pvcreate / dev/sdb {1J 2pm 3} / / use three sdb1,sdb2,sdb3 partitions to create physical volumes
Physical volume "/ dev/sdb1" successfully created.
Physical volume "/ dev/sdb2" successfully created.
Physical volume "/ dev/sdb3" successfully created.
Simply view the physical volume:
[root@localhost ~] # pvs
PV VG Fmt Attr PSize PFree
/ dev/sdb1 lvm2-512.00m 512.00m
/ dev/sdb2 lvm2-512.00m 512.00m
/ dev/sdb3 lvm2-1023.00m 1023.00m
View in detail:
[root@localhost ~] # pvdisplay
"/ dev/sdb1" is a new physical volume of "512.00 MiB"
-NEW Physical volume-
PV Name / dev/sdb1
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 413TpT-NC3F-ch4r-3xsy-TW10-P3Rr-qT6dm5
"/ dev/sdb3" is a new physical volume of "1023.00 MiB"
-NEW Physical volume-
PV Name / dev/sdb3
VG Name
PV Size 1023.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID DDu25l-PBlg-sRJY-qgl1-Io3s-ezmj-KVuZCT
"/ dev/sdb2" is a new physical volume of "512.00 MiB"
-NEW Physical volume-
PV Name / dev/sdb2
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Z5QKKi-RoKG-MZ1b-ed3s-Ibgg-eyAr-PDK0kV
PE (physical extent): the physical area is the smallest storage unit available for allocation in the physical volume. The physical area size is specified when the volume group is established. Once it is determined that the physical area size of all physical volumes in the same volume group cannot be changed, the physical area size of all physical volumes in the same volume group needs to be the same. After the new pv is added to the vg, the size of the pe automatically changes to the pe size defined in the vg.
LE (logical extent): a logical region is the smallest storage unit in a logical volume that can be allocated, and the size of the logical area depends on the size of the physical area in the volume group in which the logical volume resides.
Volume group description area: the volume group description area exists in each physical volume and is used to describe all the information such as the physical volume itself, the volume group to which the physical volume belongs, the logical volume in the volume group, the allocation of physical areas in the logical volume, and so on. It is established when the physical volume is established using pvcreate.
3. Create a volume group: vg series command
[root@localhost ~] # vg
Vgcfgbackup vgconvert vgextend vgmknodes vgs
Vgcfgrestore vgcreate vgimport vgreduce vgscan
Vgchange vgdisplay vgimportclone vgremove vgsplit
Vgck vgexport vgmerge vgrename
Create a volume group with an optional name
[root@localhost ~] # vgremove myvg
Volume group "myvg" successfully removed
[root@localhost ~] # vgcreate-s 16m myvg / dev/sdb {1rem 2pm 3}
Volume group "myvg" successfully created
[root@localhost ~] # vgs
VG # PV # LV # SN Attr VSize VFree
Myvg 3 0 0 wz-n- 1.95g 1.95g
[root@localhost ~] # vgdisplay
-Volume group-
VG Name myvg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 1.95 GiB
PE Size 16.00 MiB
Total PE 125
Alloc PE / Size 0 / 0
Free PE / Size 125 / 1.95 GiB
VG UUID 3Eu9GX-U4ip-mxSF-zibe-7802-8Suh-38b4dG
Create a logical volume
[root@localhost ~] # lvcreate-L 1.4G-n mylv myvg / dev/sdb {1pm 3} / /-L specifies the size,-n specifies the name
Rounding up size to full physical extent 1.41 GiB
Logical volume "mylv" created.
[root@localhost ~] # lvs / / simply view information
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
Mylv myvg-wi-a-- 1.41g
[root@localhost ~] # lvdisplay / / View more information
-Logical volume-
LV Path / dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID coMhuV-ywOe-FEbm-SkQd-upfQ-0era-cCfqHy
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-05-17 16:30:37 + 0800
LV Status available
Open 0
LV Size 1.41 GiB
Current LE 90
Segments 2
Allocation inherit
Read ahead sectors auto
Currently set to 8192
Block device 253:0
Format:
[root@localhost ~] # mkfs.ext4 / dev/myvg/mylv
Mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
92160 inodes, 368640 blocks
18432 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=377487360
12 block groups
32768 blocks per group, 32768 fragments per group
7680 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
3. Mounting and using
View the physical location:
[root@localhost ~] # ll / dev/myvg/mylv
Lrwxrwxrwx 1 root root 7 May 17 16:30 / dev/myvg/mylv->.. / dm-0
Mount to a directory and read and write:
[root@localhost ~] # mount / dev/myvg/mylv / mnt
[root@localhost ~] # mkdir / mnt/test
[root@localhost ~] # ls / mnt/ > / mnt/test/test.txt
[root@localhost ~] # cat / mnt/test/test.txt
Lost+found
Test
These are all the contents of the article "how to quickly create LVM under CentOS7". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.