备份和恢复ASM磁盘组元数据测试
——————————————————————————————————————————
ASMCMD中提供命令MD_BACKUP 和MD_RESTORE命令用于ASM磁盘组元数据的备份和恢复。
还提供了MKDG命令通过XML配置文件来创建磁盘组。
测试如下:
-----------------------------------------------------------------------
1.查看当前磁盘组
ASMCMD> lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 1048576 8188 2668 0 2668 0 N DATA/
MOUNTED EXTERN N 512 512 4096 1048576 2047 1994 0 1994 0 N DATA01/
MOUNTED EXTERN N 512 512 4096 1048576 4094 702 0 702 0 N FRA/
ASMCMD>
2.备份磁盘组data01元数据
ASMCMD> md_backup /tmp/data01_meta_bak
Disk group metadata to be backed up: DATA01
Disk group metadata to be backed up: DATA
Disk group metadata to be backed up: FRA
Current alias directory path: ORCL/PASSWORD
Current alias directory path: ASM
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/TEMPFILE
Current alias directory path: ORCL/PARAMETERFILE
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ORCL/ARCHIVELOG/2020_06_08
Current alias directory path: ORCL/FLASHBACK
Current alias directory path: ORCL/ARCHIVELOG/2020_06_07
Current alias directory path: ORCL/AUTOBACKUP/2020_06_07
Current alias directory path: ORCL/AUTOBACKUP
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/ARCHIVELOG/2020_06_05
Current alias directory path: ORCL/AUTOBACKUP/2020_06_08
Current alias directory path: ORCL
Current alias directory path: ORCL/BACKUPSET/2020_06_05
Current alias directory path: ORCL/BACKUPSET/2020_06_08
Current alias directory path: ORCL/BACKUPSET
Current alias directory path: ORCL/ARCHIVELOG
ASMCMD>
3.检查数据库
尤其是放置在DATA01上的相关数据文件,这里只有表空间tbs_test放在DATA01上的。
RMAN> list backup of tablespace tbs_test;
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
25 Full 11.41M DISK 00:00:00 08-JUN-20
BP Key: 25 Status: AVAILABLE Compressed: NO Tag: TAG20200608T175134
Piece Name: /home/oracle/full_0rv28ji5_1_1.bak
List of Datafiles in backup set 25
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
7 Full 3562272 08-JUN-20 NO +DATA/ORCL/DATAFILE/tbs_test.268.1042564737
4.模拟磁盘组故障
我这里直接删除磁盘组。
ASMCMD> dropdg -r data01
ASMCMD>
ASMCMD> lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 1048576 8188 2668 0 2668 0 N DATA/
MOUNTED EXTERN N 512 512 4096 1048576 4094 702 0 702 0 N FRA/
ASMCMD>
此时查看磁盘组DATA01已经被删除
5.还原磁盘组元数据
方法①通过备份还原
ASMCMD> md_restore /tmp/data01_meta_bak -G data01
Current Diskgroup metadata being restored: DATA01
Diskgroup DATA01 created!
System template ONLINELOG modified!
System template AUTOLOGIN_KEY_STORE modified!
System template INCR XTRANSPORT BACKUPSET modified!
System template DATAFILE modified!
System template BACKUPSET modified!
System template FLASHBACK modified!
System template KEY_STORE modified!
System template DATAGUARDCONFIG modified!
System template ARCHIVELOG modified!
System template CHANGETRACKING modified!
System template TEMPFILE modified!
System template VOTINGFILE modified!
System template ASMPARAMETERFILE modified!
System template PARAMETERFILE modified!
System template OCRFILE modified!
System template XTRANSPORT modified!
System template CONTROLFILE modified!
System template AUTOBACKUP modified!
System template DUMPSET modified!
System template FLASHFILE modified!
System template AUDIT_SPILLFILES modified!
System template XTRANSPORT BACKUPSET modified!
方法②通过MKDG来创建
准备一份XML配置文件:
[grid@dbserver ~]$ more /home/grid/mkdg.xml
<dg name='data01' redundancy="external">
<dsk string="ORCL:DATA07">
</dsk>
<a name="compatible.asm" value="12.1"/>
<a name="compatible.rdbms" value="10.1"/>
</dg>
通过MKDG来创建DATA01:
ASMCMD> mkdg /home/grid/mkdg.xml
查看结果:
ASMCMD> lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 512 4096 1048576 8188 2668 0 2668 0 N DATA/
MOUNTED EXTERN N 512 512 4096 1048576 2047 1994 0 1994 0 N DATA01/
MOUNTED EXTERN N 512 512 4096 1048576 4094 702 0 702 0 N FRA/
ASMCMD>
6.RMAN还原数据文件
如果数据库实例关闭的话需要在MOUNT状态来恢复表空间,如果没有关闭,直接恢复。
RMAN> restore tablespace tbs_test;
Starting restore at 08-JUN-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=265 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to +DATA/ORCL/DATAFILE/tbs_test.268.1042564737
channel ORA_DISK_1: reading from backup piece /home/oracle/full_0rv28ji5_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/full_0rv28ji5_1_1.bak tag=TAG20200608T175134
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 08-JUN-20
RMAN> recover tablespace tbs_test;
Starting recover at 08-JUN-20
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 08-JUN-20
OK,完成磁盘组和数据文件的恢复。
--THE END
|