In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article Xiaobian for you to introduce in detail "LVM how to restore the deleted logical volume", the content is detailed, the steps are clear, and the details are handled properly. I hope this "LVM how to restore the deleted logical volume" article can help you solve your doubts, following the editor's ideas slowly in depth, let's learn new knowledge.
System environment
Centos8
Existing file system
Before starting this article, you have created a logical volume with some files in it.
[root@localhost ~] # pvs PV VG Fmt Attr PSize PFree / dev/nvme0n1p2 cl lvm2 Amuri-# vgs VG # PV # LV # SN Attr VSize VFree cl 120 wz--n- # 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 lv_data vg_data-wi-ao---- 39.99g [root@localhost] # df-h / dataFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_ Data-lv_data 40G 318m 40G 1% / data
The files in the / data directory are as follows:
Accidentally delete logical volume
For demonstration purposes, delete the logical volume lv_data.
[root@localhost ~] # umount / data [root@localhost ~] # lvremove-v / dev/vg_data/lv_dataDo you really want to remove active logical volume vg_data/lv_data? Y Accepted input: [y] Removing vg_data-lv_data (253 vg_data 2) Archiving volume group "vg_data" metadata (seqno 2). Releasing logical volume "lv_data" Creating volume group backup "/ etc/lvm/backup/vg_data" (seqno 3). Logical volume "lv_data" successfully removed
Use the lvs command to print and confirm that we have deleted the logical volume LV _ data:
Because the lv_data volume has been deleted, you can see that the remaining space for the volume group vg_data is 40G.
[root@localhost ~] # vgs VG # PV # LV # SN Attr VSize VFree cl 1 20 wz--n- starts to recover logical volumes
Now, let's look at how to restore deleted logical volumes. Whenever we perform any task related to LVM, everything will be recorded in / etc/lvm/archive. Down. Use the vgcfgbackup command to back up the volume group configuration and store it under / etc/lvm/backup.
[root@localhost] # ll / etc/lvm/backup/total 8 RWMI. 1 root root 1746 Mar 9 16:27 cl-rw-. 1 root root 1147 Apr 8 10:20 vg_ data [root @ localhost ~] # ll / etc/lvm/archive/total 24 RWMI. 1 root root 1740 Dec 29 2019 cl_00000-1531402016.vgMel RWMI. 1 root root 1740 Mar 9 16:27 cl_00001-790744555 VG Murray RWMI. 1 root root 1747 Mar 9 16:27 cl_00002-1369752011.vgMurrwmuri. 1 root root 1150 Apr 8 09:52 vg_data_00000-919482485.vg Murray RWMI. 1 root root 1155 Apr 8 09:54 vg_data_00001-1289102393.vg Murray RWMI. 1 root root 1763 Apr 8 10:20 vg_data_00002-1932879749.vg
In the steps above to delete the logical volume, you can see the details of the output, including archiving and create backup, when you use the lvremove-v / dev/vg_data/lv_data command.
The following lists and checks how many volume group metadata backups are available:
[root@localhost] # vgcfgrestore-- list vg_data File: / etc/lvm/archive/vg_data_00000-919482485.vg Couldn't find device with uuid l5rSrt-SRfc-KQNw-Tm29-gx4D-ihBw-Xzum3L. Couldn't find device with uuid v6wYGZ-0dGA-8ecB-kec8-r2zv-gCJi-gulSAD. VG name: vg_data Description: Created * before* executing 'vgcreate vg_data / dev/sda / dev/sdb' Backup Time: Thu Apr 8 09:52:49 2021 File: / etc/lvm/archive/vg_data_00001-1289102393.vg VG name: vg_data Description: Created * before* executing'lvcreate-l 100%FREE-n lv_data vg_data' Backup Time: Thu Apr 8 09:54:45 2021 File: / etc/lvm/archive/vg_data_00002-1932879749 VG VG name: vg_data Description: Created * before* executing 'lvremove-v / dev/vg_data/lv_data' Backup Time: Thu Apr 8 10:20:53 2021 File: / etc/lvm/backup/vg_data VG name: vg_data Description: Created * after* executing' lvremove-v / dev/vg_data/lv_data' Backup Time: Thu Apr 8 10:20:53 2021
The-- list option lists metadata backup and archive files related to VG. The thing we want to restore deletes the archive before the volume group, so select the / etc/lvm/archive/vg_data_00002-1932879749.vg file circled below.
Before restoring, use the-- test option to try it out:
[root@localhost] # vgcfgrestore vg_data-f / etc/lvm/archive/vg_data_00002-1932879749.vg-- test TEST MODE: Metadata will NOT be updated and volumes will not be (de) activated. Restored volume group vg_data.
After the trial run is all right, remove the-- test option and execute it again:
[root@localhost] # vgcfgrestore vg_data-f / etc/lvm/archive/vg_data_00002-1932879749.vg Restored volume group vg_data.
You can see that the volume group vg_data was successfully restored.
The-f option reads the metadata file created by vgcfgbackup.
Use lvs to see if the lv_data logical volume has been restored, and use lvscan to see if the logical volume is active:
[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 Lv_data vg_data-wi- 39.99g [root@localhost ~] # lvscan ACTIVE'/ dev/cl/swap' [2.00 GiB] inherit ACTIVE'/ dev/cl/root' [15.00 GiB] inherit inactive'/ dev/vg_data/lv_data' [39.99 GiB] inherit
You can see that lv_data has been restored, but the state is inactive. The next step is to activate logical volumes.
Activate logical Volume
Use the lvchange command to activate the logical volume:
[root@localhost ~] # lvchange-ay / dev/vg_data/lv_ data [root @ localhost ~] # lvscan ACTIVE'/ dev/cl/swap' [2.00 GiB] inherit ACTIVE'/ dev/cl/root' [15.00 GiB] inherit ACTIVE'/ dev/vg_data/lv_data' [39.99 GiB] inherit [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 lv_data vg_data-wi-a- 39.99g
In the figure above, you can see that the "/ dev/vg_data/lv_data" logical volume is activated.
Mount and check
Mount the file system:
[root@localhost ~] # mount / dev/vg_data/lv_data / data/ [root@localhost ~] # df-h / dataFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_data-lv_data 40G 318M 40G 1% / data
You can see that the files already exist.
After reading this, the article "how to restore deleted logical volumes by LVM" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow 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.