In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to create a reduced logic volume of LVM in Centos8". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
LVM's thin logical volumes, which create logical volumes that are larger than the available extents. Thin pools can be dynamically extended when needed, and storage administrators can overuse physical storage to allocate storage space in a cost-effective manner.
System environment
Centos8
Create a thin pool
Let's add a hard drive. Create a physical volume, and then create a volume group:
[root@localhost ~] # pvcreate / dev/sda Physical volume "/ dev/sda" successfully created. [root@localhost ~] # vgcreate vg_thin / dev/sda Volume group "vg_thin" successfully created [root@localhost ~] # vgs VG # PV # LV # SN Attr VSize VFree cl 1 20 wz--n-
A new volume group has been created above, named vg_thin. Then create a thin pool in the existing volume group:
[root@localhost] # lvcreate-L 1G-T vg_thin/thin_pool Thin pool volume with chunk size 64.00 KiB can address at most 15.81 TiB of data. Logical volume "thin_pool" created. [root@localhost ~] # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl-wi-ao---- 15.00g swap cl-wi-ao---- 2.00g Thin_pool vg_thin twi-a-tz-- 1.00g 0.00 10.94 create a thin volume
After creating a thin pool, we can create thin volumes from the thin pool. In this lab, four thin volumes were created, each with a size of 200 MB.
[root@localhost] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user1 Logical volume "tp_lv_user1" created. [root@localhost ~] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user2 Logical volume "tp_lv_user2" created. [root@localhost ~] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user3 Logical volume "tp_lv_user3" created. [root@localhost ~] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user4 Logical volume "tp_lv_user4" created. Format and mount thin volumes
Format the four thin volumes created above into xfs format:
[root@localhost ~] # mkfs.xfs / dev/vg_thin/tp_lv_ user1 [root @ localhost ~] # mkfs.xfs / dev/vg_thin/tp_lv_ user2 [root @ localhost ~] # mkfs.xfs / dev/vg_thin/tp_lv_ user3 [root @ localhost ~] # mkfs.xfs / dev/vg_thin/tp_lv_user4
Create a mount point and mount:
[root@localhost ~] # mkdir-p / mnt/user {1.. 4} [root@localhost ~] # mount / dev/vg_thin/tp_lv_user1 / mnt/user1 [root@localhost ~] # mount / dev/vg_thin/tp_lv_user2 / mnt/user2 [root@localhost ~] # mount / dev/vg_thin/tp_lv_user3 / mnt/user3 [root@localhost ~] # mount / dev/vg_thin/tp_lv_user4 / mnt/user4
Write some files to these four directories:
[root@localhost ~] # dd if=/dev/zero of=/mnt/user1/test.img bs=1M count=100 [root@localhost ~] # dd if=/dev/zero of=/mnt/user2/test.img bs=1M count=100 [root@localhost ~] # dd if=/dev/zero of=/mnt/user3/test.img bs=1M count=100 [root@localhost ~] # dd if=/dev/zero of=/mnt/user4/test.img bs=1M count=100
Then run the following command to view the following usage space:
[root@localhost ~] # lvs
We can notice that the utilization of the thin pool is 41.41%.
Turn on protection against space exhaustion in the thin pool
Create two more 200 MB thin volumes. You can find that the creation of these two thin volumes exceeds the size of the set thin pool, and although it can be created successfully, there is a greater risk and some warnings of excess.
[root@localhost] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user5 Logical volume "tp_lv_user5" created. [root@localhost] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user6 WARNING: Sum of all thin volume sizes (1.17 GiB) exceeds the size of thin pool vg_thin/thin_pool (1.00 GiB). WARNING: You have not turned on protection against thin pools running out of space. WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full. Logical volume "tp_lv_user6" created.
Let's delete the tp_lv_user5 and tp_lv_user6 just created, turn on overprotection in the lvm.conf configuration file, and recreate the two thin volumes:
[root@localhost] # lvremove-f / dev/vg_thin/tp_lv_user5 Logical volume "tp_lv_user5" successfully removed [root@localhost ~] # lvremove-f / dev/vg_thin/tp_lv_user6 Logical volume "tp_lv_user6" successfully removed
Edit the / etc/lvm/lvm.conf configuration file and modify the values of the next two parameters:
# when the utilization of a thin pool exceeds this percentage, the pool is automatically extended, and changing it to 100 disables automatic extension. The minimum acceptable value is 50. Thin_pool_autoextend_threshold = 8 percent increases this percentage of extra space by automatically expanding the thin pool. The amount of extra space added to the thin pool is a percentage of its current size. Thin_pool_autoextend_percent = 20
Let's create two thin volumes, tp_lv_user5 and tp_lv_user6:
[root@localhost ~] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user5 Logical volume "tp_lv_user5" created. [root@localhost ~] # lvcreate-V 200m-T vg_thin/thin_pool-n tp_lv_user6 Logical volume "tp_lv_user6" created. [root@localhost ~] # mkfs.xfs / dev/vg_thin/tp_lv_ user5 [root @ localhost ~] # mkfs.xfs / dev/vg_thin/tp_lv_user6 [root@localhost ~] # mkdir-p / mnt/user {5.. 6} [root@localhost ~] # mount / dev/vg_thin/tp_lv_user5 / mnt/user5 [root@localhost ~] # mount / dev/vg_thin/tp_lv_user6 / mnt/user6
Take a look at the usage:
Next, we populate / mnt/user5 and / mnt/user6 until the utilization of the thin_pool thin pool exceeds 80%. We can see the capacity expansion of the thin pool.
[root@localhost] # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl-wi-ao---- 15.00g swap cl-wi-ao---- 2.00g Thin_pool vg_thin twi-aotz-- 1.20g 75.94 22.66 tp_lv_user1 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user2 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user3 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user4 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user5 vg_thin Vwi-aotz-- 200. 00m thin_pool 77.97 tp_lv_user6 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97
As you can see above, the capacity of the thin_pool thin pool has increased by 200m, which means that when the utilization of the thin pool exceeds 80%, the capacity will be increased by 20%.
How to expand the thin pool
When expanding the thin pool, we need to follow two steps:
\ 1. Expand the metadata of the thin pool\ 2. Then expand the thin pool.
To expand the thin pool, we should not continue to expand the thin pool immediately. First, check the size of existing metadata usage by running lvs-a.
[root@localhost] # lvs-a LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl-wi-ao---- 15.00g swap cl-wi-ao---- 2.00g [lvol0_pmspare] vg_thin ewi- 4.00m thin_pool vg_thin twi-aotz-- 1.20g 75.94 22.66 [thin_pool_tdata] vg_thin Twi-ao---- 1.20g [thin_pool_tmeta] vg_thin ewi-ao---- 4.00m tp_lv_user1 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user2 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user3 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user4 Vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user5 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 tp_lv_user6 vg_thin Vwi-aotz-- 200.00m thin_pool 77.97 extended thin pool metadata size
The current size of metadata is only 4 MB. Let's add 4MB to the current size.
[root@localhost] # lvextend-- poolmetadatasize + 4m vg_thin/thin_pool
You can see that [thin_pool_tmeta] has become 8m.
Expand the size of the thin pool
After you have finished extending the metadata, start expanding the thin pool to the desired size. Expand the capacity of the thin pool and add 1G capacity.
[root@localhost] # lvextend-L + 1G / dev/vg_thin/thin_pool
Now the size has become 2.2 gigabytes.
Expand thin Volum
Extending a thin volume is similar to extending a thin pool:
[root@localhost ~] # lvextend-L + 200m / dev/vg_thin/tp_lv_user1 delete thin volumes, thin pools
To delete a thin pool, you first need to unmount all file systems, then delete all thin volumes, and finally delete the thin pool.
# unmount partition [root@localhost ~] # umount / mnt/user {1.. 6} # delete thin volume [root@localhost ~] # lvremove-y / dev/vg_thin/tp_lv_user [1-6] Logical volume "tp_lv_user1" successfully removed Logical volume "tp_lv_user2" successfully removed Logical volume "successfully removed Logical volume" tp_lv_user4 "successfully removed Logical volume" tp_lv_user5 "successfully removed Logical volume" tp_lv_ User6 "successfully removed# Delete thin Pool [root@localhost] # lvremove-y / dev/vg_thin/thin_pool Logical volume" thin_pool "successfully removed
Use the lvs command to see if the following has been deleted:
[root@localhost] # lvs-a LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl-wi-ao---- 15.00g swap cl-wi-ao---- 2.00g "how to create a reduced logic volume for LVM in Centos8" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.