在Oracle Linux系統進行操作的時候,不小心將VG給刪除了,相信不少朋友有遇到這種情況,誤刪的VG其實是可以恢復的,下面小編就給大家介紹下Oracle Linux 6.4刪除VG的解決方法,一起來了解下吧。
一、項目背景描述
1、OSS現網測試數據庫因大量小事物頻繁提交運行非常緩慢。經分析為DS3950存儲所在磁盤I/O存在瓶頸,大量等待事件,性能受限。另外,開發同事沒有優化意識,沒將小事物做成批量提交方式。
2、在DS3950上,9塊600G硬盤(8塊+1塊熱備)做了RAID5陣列,lun01,lun02,lun03,lun04,均為200G,映射給OSS數據庫服務器使用。
3、在操作系統上,lun01,lun02構成了vg_ossdb卷組,vg_ossdb下只有一個LV--lvoradata掛載在/oradata上。最近因數據增長過快,又將lun03,lun04以vgextend方式擴到了vg_ossdb卷組中去,但尚未擴大lvoradata。
4、在數據庫上,Oracle軟件安裝在本地磁盤/oracle上,數據庫安裝在/oradata上。
二、項目改造計劃及步驟
1、停掉數據庫,將/oradata目錄全備份到另一台備用PC機器上。
2、由於DS3950存儲空閒空很大,可修改其陣列級別從RAID5變為RAID10。
3、由於lun03,lun04尚未使用,領導要求先從vg_ossdb中移除lun03,lun04,並在存儲上unmap掉,便於陣列級別變更。
4、由DBA優化SQL,將小事物盡量做到批量提交方式。
三、系統環境及數據版本說明
[root@ol64 /]# cat /etc/issue
Oracle Linux Server release 6.4
Kernel \r on an \m
[root@ol64 /]# uname -a
Linux ol64.com 2.6.39-400.17.1.el6uek.x86_64 #1 SMP Fri Feb 22 18:16:18 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
SQL》 select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
四、改造過程中因誤用vgremove將vg_ossdb卷組刪除,而其本意是想用vgreduce移除/dev/sdd,/dev/sde的。
[root@ol64 /]# umount /oradata/ #卸載文件系統
[root@ol64 /]# vgchange -an /dev/vg_ossdb #將卷組置於非激活狀態
0 logical volume(s) in volume group “vg_ossdb” now active
[root@ol64 /]# vgremove vg_ossdb /dev/sdb /dev/sdc /dev/sdd /dev/sde #誤用vgremove命令刪除了vg_ossdb
Do you really want to remove volume group “vg_ossdb” containing 1 logical volumes? [y/n]: y
Do you really want to remove active logical volume lvoradata? [y/n]: y
Logical volume “lvoradata” successfully removed
Volume group “vg_ossdb” successfully removed
Volume group “sdb” not found
Volume group “sdc” not found
Volume group “sdd” not found
Volume group “sde” not found
##################################################################
正確的操作應該是用vgreduce命令從vg_ossdb中移除/dev/sdd和/dev/sde
[root@ol64 /]# vgreduce vg_ossdb /dev/sdd
Removed “/dev/sdd” from volume group “vg_ossdb”
[root@ol64 /]# vgreduce vg_ossdb /dev/sde
Removed “/dev/sde” from volume group “vg_ossdb”
#################################################################
再用pvremove命令移除/dev/sdd和/dev/sde
[root@ol64 ~]# pvremove /dev/sdd
Labels on physical volume “/dev/sdd” successfully wiped
[root@ol64 ~]# pvremove /dev/sde
Labels on physical volume “/dev/sde” successfully wiped
[root@ol64 ~]# pvdisplay #發現/dev/sdb和/dev/sdc所在VG Name為空,冒汗ing.
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_ol64
PV Size 199.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 51074
Free PE 33660
Allocated PE 17414
PV UUID 0dyB8L-p7ZM-Mkcw-76ae-DXPh-U6zg-9kIQ8z
“/dev/sdb” is a new physical volume of “200.00 GiB”
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 200.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Ui9wea-II1q-KOx0-96pA-4epf-9hlc-4NFDJF
“/dev/sdc” is a new physical volume of “200.00 GiB”
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 200.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 4VKCJ9-G6kL-QJgg-Titf-UNA8-d3QZ-ZTES3P
[root@ol64 ~]# vgscan #vgscan時找不到vg_ossdb信息
Reading all physical volumes. This may take a while.。。
Found volume group “vg_ol64” using metadata type lvm2
[root@ol64 ~]# lvscan #lvscan時找不到lvoradata信息。
ACTIVE ‘/dev/vg_ol64/lvopt’ [10.01 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvroot’ [40.01 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvswap’ [8.00 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvhome’ [10.01 GiB] inherit
五、VG恢復思路
1、在/etc/lvm/存放著LVM的配置、歸檔、備份等信息。
[root@ol64 ~]# ls -l /etc/lvm
total 52
drwx------。 2 root root 4096 Nov 18 08:30 archive
drwx------。 2 root root 4096 Nov 18 08:30 backup
drwx------。 2 root root 4096 Feb 24 2013 cache
-rw-r--r--。 1 root root 37554 Feb 24 2013 lvm.conf
2、在/etc/lvm/backup/下存放著vg的備份信息,但我在操作vg_ossdb之前沒有備份其信息到其它目錄。
[root@ol64 lvm]# ls /etc/lvm/backup/
total 4
-rw-------。 1 root root 2575 Nov 12 09:09 vg_ol64
3、在 /etc/lvm/archive/下存放著VG及LV調整前的歸檔信息,即VG變更或LV變更前均會備份當前信息。
[root@ol64 ~]# ls -l /etc/lvm/archive/
total 32
-rw-------。 1 root root 2576 Nov 12 09:09 vg_ol64_00000-1722993391.vg
-rw-------。 1 root root 883 Nov 18 08:03 vg_ossdb_00000-2033719300.vg
-rw-------。 1 root root 883 Nov 18 08:04 vg_ossdb_00001-1635801039.vg
-rw-------。 1 root root 1122 Nov 18 08:05 vg_ossdb_00002-1283186973.vg
-rw-------。 1 root root 883 Nov 18 08:05 vg_ossdb_00003-1708919759.vg
-rw-------。 1 root root 1139 Nov 18 08:05 vg_ossdb_00004-18964421.vg
-rw-------。 1 root root 1728 Nov 18 08:30 vg_ossdb_00005-533258090.vg
-rw-------。 1 root root 1131 Nov 18 08:30 vg_ossdb_00006-1987723911.vg
備注:使用vgcreate、vgreduce、vgremove、lvcreate、lvreduce、lvremove等命令時均會生成新的歸檔信息
4、利用vgcfgrestore命令恢復誤刪除的VG
[root@ol64 archive]# vgcfgrestore -f /etc/lvm/archive/vg_ossdb_00001-1635801039.vg vg_ossdb
Restored volume group vg_ossdb
[root@ol64 archive]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb
VG Name vg_ossdb
PV Size 200.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 51199
Free PE 51199
Allocated PE 0
PV UUID Ui9wea-II1q-KOx0-96pA-4epf-9hlc-4NFDJF
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_ol64
PV Size 199.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 51074
Free PE 33660
Allocated PE 17414
PV UUID 0dyB8L-p7ZM-Mkcw-76ae-DXPh-U6zg-9kIQ8z
“/dev/sdc” is a new physical volume of “200.00 GiB”
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 200.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 4VKCJ9-G6kL-QJgg-Titf-UNA8-d3QZ-ZTES3P
上述操作發現只有/dev/sdb在vg_ossdb卷組中了,而/dev/sdc仍然不在vg_ossdb卷組中。這說明/etc/lvm/archive/vg_ossdb_00001-1635801039.vg歸檔文件較舊,還沒有包括/dev/sdc在vg_ossdb卷組中,繼續使用下一個歸檔文件恢復,直到/dev/sdb、/dev/sdc均在vg_ossdb卷組中,並且卷組中包含的LV個數正確。
[root@ol64 archive]# vgcfgrestore -f /etc/lvm/archive/vg_ossdb_00005-533258090.vg vg_ossdb
Restored volume group vg_ossdb
[root@ol64 archive]# vgchange -ay /dev/vg_ossdb
1 logical volume(s) in volume group “vg_ossdb” now active
[root@ol64 archive]# lvscan
ACTIVE ‘/dev/vg_ossdb/lvoradata’ [200.00 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvopt’ [10.01 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvroot’ [40.01 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvswap’ [8.00 GiB] inherit
ACTIVE ‘/dev/vg_ol64/lvhome’ [10.01 GiB] inherit
[root@ol64 archive]# mount /dev/vg_ossdb/lvoradata /oradata/
[root@ol64 archive]# ls -l /oradata/ossdb/
total 1698340
-rwxrwxr-x. 1 Oracle oinstall 9748480 Nov 18 08:29 control01.ctl
-rwxrwxr-x. 1 oracle oinstall 1073742336 Nov 18 08:11 redo01.log
-rwxrwxr-x. 1 oracle oinstall 1073742336 Nov 18 08:11 redo02.log
-rwxrwxr-x. 1 oracle oinstall 1073742336 Nov 18 08:29 redo03.log
-rwxrwxr-x. 1 oracle oinstall 2147516416 Nov 18 08:29 sysaux01.dbf
-rwxrwxr-x. 1 oracle oinstall 2147516416 Nov 18 08:29 system01.dbf
-rwxrwxr-x. 1 oracle oinstall 8388640768 Nov 18 06:38 temp01.dbf
-rwxrwxr-x. 1 oracle oinstall 17179901952 Nov 18 08:29 undotbs01.dbf
-rwxrwxr-x. 1 oracle oinstall 17179901952 Nov 18 08:29 users01.dbf
//省略。。。。
啟動數據庫,一切正常。
[root@ol64 /]# vgcfgbackup -f /home/vg_ossdb.backup vg_ossdb
上面就是Oracle Linux 6.4不小心刪除VG的解決方法的介紹了,為了避免下次再誤刪VG,記得對VG數據做個備份。