Disclaimer

Saturday 10 July 2021

ASM Backup and Restore Metadata

 ASMCMD md_backup and md_restore are used for ASM Backup and Restore. The md_backup command creates a backup file containing metadata for one or more disk groups. By default all the mounted disk groups are included in the backup file which is saved in the current working directory.

Create FRA

[root@oel5-asm ~]# oracleasm createdisk fra1 /dev/sdh1

[grid@oel5-asm ~]$ sqlplus  / as sysasm
SQL> create diskgroup FRA external redundancy disk 'ORCL:FRA1';
SQL> select max(free_mb) from v$asm_disk;

MAX(FREE_MB)

------------
      49101

SQL> alter system set db_recovery_file_dest='+FRA';

SQL> alter system set db_recovery_file_dest_size='49101M';

Create Backup of ASM Metadata

ASMCMD> help md_backup

       md_backup
       The md_backup command creates a backup file containing metadata
       for one or more disk groups.
       Volume and Oracle Automatic Storage Management Cluster File System
       (Oracle ACFS) file system information is not backed up.

       md_backup backup_file [-G diskgroup [,diskgroup,...]]

       The options for the md_backup command are described below.

       backup_file     - Specifies the backup file in which you want to

                         store the metadata.
       -G diskgroup    - Specifies the disk group name of the disk group
                         that must be backed up

       By default all the mounted disk groups are included in the backup file,
       which is saved in the current working directory.
       The first example shows the use of the backup command when you run it
       without the disk group option. This example backs up all of the mounted
       disk groups and creates the backup image in the current working

       directory. The second example creates a backup of disk group DATA and
       FRA. The backup that this example creates is saved in the
       /tmp/dgbackup20090716 file.

       ASMCMD [+] > md_backup /tmp/dgbackup20090716
       ASMCMD [+] > md_backup /tmp/dgbackup20090716 -G DATA,FRA
       Disk group metadata to be backed up: DATA
       Disk group metadata to be backed up: FRA
       Current alias directory path: ASM/ASMPARAMETERFILE
       Current alias directory path: ORCL/DATAFILE
       Current alias directory path: ORCL/TEMPFILE
       Current alias directory path: ORCL/CONTROLFILE
       Current alias directory path: ORCL/PARAMETERFILE

       Current alias directory path: ASM

       Current alias directory path: ORCL/ONLINELOG
       Current alias directory path: ORCL
       Current alias directory path: ORCL/CONTROLFILE
       Current alias directory path: ORCL/ARCHIVELOG/2009_07_13
       Current alias directory path: ORCL/BACKUPSET/2009_07_14
       Current alias directory path: ORCL/ARCHIVELOG/2009_07_14
       Current alias directory path: ORCL
       Current alias directory path: ORCL/DATAFILE
       Current alias directory path: ORCL/ARCHIVELOG

       Current alias directory path: ORCL/BACKUPSET

       Current alias directory path: ORCL/ONLINELOG
ASMCMD> md_backup /u01/asm_data.bkp -G 'DATA'
Disk group metadata to be backed up: DATA
Current alias directory path: ORCL_ASM/TEMPFILE
Current alias directory path: ORCL_ASM/CONTROLFILE
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: ORCL_ASM/PARAMETERFILE
Current alias directory path: ASM
Current alias directory path: ORCL_ASM/DATAFILE
Current alias directory path: ORCL_ASM
Current alias directory path: ORCL_ASM/ONLINELOG

Create RMAN Backup

RMAN> configure controlfile autobackup on;


new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored
RMAN> backup as compressed backupset database plus archivelog;


Starting backup at 26-MAR-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=15 RECID=1 STAMP=811083089
input archived log thread=1 sequence=16 RECID=2 STAMP=811083100
input archived log thread=1 sequence=17 RECID=3 STAMP=811083119
channel ORA_DISK_1: starting piece 1 at 26-MAR-13
channel ORA_DISK_1: finished piece 1 at 26-MAR-13
piece handle=+FRA/orcl_asm/backupset/2013_03_26/annnf0_tag20130326t125159_0.262.811083121 tag=TAG20130326T125159 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 26-MAR-13
Starting backup at 26-MAR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/orcl_asm/datafile/system.256.811010051
input datafile file number=00002 name=+DATA/orcl_asm/datafile/sysaux.257.811010053
input datafile file number=00005 name=+DATA/orcl_asm/datafile/example.269.811010553
input datafile file number=00003 name=+DATA/orcl_asm/datafile/undotbs1.258.811010055
input datafile file number=00004 name=+DATA/orcl_asm/datafile/users.259.811010055
channel ORA_DISK_1: starting piece 1 at 26-MAR-13
channel ORA_DISK_1: finished piece 1 at 26-MAR-13
piece handle=+FRA/orcl_asm/backupset/2013_03_26/nnndf0_tag20130326t125204_0.263.811083127 tag=TAG20130326T125204 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
Finished backup at 26-MAR-13

Starting backup at 26-MAR-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=18 RECID=4 STAMP=811083240
channel ORA_DISK_1: starting piece 1 at 26-MAR-13
channel ORA_DISK_1: finished piece 1 at 26-MAR-13
piece handle=+FRA/orcl_asm/backupset/2013_03_26/annnf0_tag20130326t125400_0.265.811083241 tag=TAG20130326T125400 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-MAR-13
Starting Control File and SPFILE Autobackup at 26-MAR-13
piece handle=+FRA/orcl_asm/autobackup/2013_03_26/s_811083241.266.811083245 comment=NONE
Finished Control File and SPFILE Autobackup at 26-MAR-13

Simulate Failover of ASM Diskgroup

--For Testing
SQL>  alter diskgroup DATA DISMOUNT FORCE;

Diskgroup altered.

SQL> drop diskgroup DATA FORCE INCLUDING CONTENTS;
Diskgroup dropped.

SQL>

Restore ASM Metadata

ASMCMD> help md_restore

       md_restore
       This command restores a disk group metadata backup.
       md_restore backup_file [--silent][--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]'][-S sql_script_file] [-G 'diskgroup [,diskgroup...]']

       The options for the md_restore command are described below.
       backup_file             - Reads the metadata information from
                                 backup_file.
       --silent                - Ignore errors. Normally, if md_restore
                                 encounters an error, it will stop.

                                 Specifying this flag ignores any errors.
       --full                  - Specifies to create a disk group and restore
                                 metadata.
       --nodg                  - Specifies to restore metadata only.
       --newdg -o old_diskgroup:new_diskgroup  - Specifies to create a disk
                                 group with a different name when restoring
                                 metadata. The -o option is required
                                 with --newdg.
       -S sql_script_file      - Write SQL commands to the specified SQL
                                 script file instead of executing the commands.
       -G diskgroup            - Select the disk groups to be restored.
                                 If no disk groups are defined, then all
                                 disk groups will be restored.


       The first example restores the disk group DATA from the backup script

       and creates a copy. The second example takes an existing disk group
       DATA and restores its metadata. The third example restores disk group
       DATA completely but the new disk group that is created is called DATA2.
       The fourth example restores from the backup file after applying the
       overrides defined in the override.sql script file
       ASMCMD [+] > md_restore --full -G data --silent /tmp/dgbackup20090714

       ASMCMD [+] > md_restore --nodg -G data --silent /tmp/dgbackup20090714
       ASMCMD [+] > md_restore --newdg -o 'data:data2' --silent /tmp/dgbackup20090714
       ASMCMD [+] > md_restore -S override.sql --silent /tmp/dgbackup20090714
ASMCMD> md_restore /u01/asm_data.bkp --full

Current Diskgroup metadata being restored: DATA
Diskgroup DATA created!
System template XTRANSPORT modified!
System template ONLINELOG modified!
System template DATAGUARDCONFIG modified!
System template AUTOBACKUP modified!
System template TEMPFILE modified!
System template OCRFILE modified!
System template ARCHIVELOG modified!
System template DUMPSET modified!
System template CONTROLFILE modified!
System template BACKUPSET modified!
System template ASMPARAMETERFILE modified!
System template FLASHBACK modified!
System template PARAMETERFILE modified!
System template FLASHFILE modified!
System template DATAFILE modified!
System template CHANGETRACKING modified!
Directory +DATA/ASM re-created!
Directory +DATA/ORCL_ASM re-created!
Directory +DATA/ASM/ASMPARAMETERFILE re-created!
Directory +DATA/ORCL_ASM/PARAMETERFILE re-created!
Directory +DATA/ORCL_ASM/CONTROLFILE re-created!

Directory +DATA/ORCL_ASM/ONLINELOG re-created!
Directory +DATA/ORCL_ASM/TEMPFILE re-created!
Directory +DATA/ORCL_ASM/DATAFILE re-created!

Restore Database

[grid@oel5-asm ~]$ srvctl stop database -d orcl_asm

RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters

ORA-01565: error in identifying file '+DATA/orcl_asm/spfileorcl.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl_asm/spfileorcl.ora
ORA-15056: additional error message
ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl_asm/spfileorcl.ora
ORA-15173: entry 'spfileorcl.ora' does not exist in directory 'orcl_asm'
ORA-06512: at line 4
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area     158662656 bytes

Fixed Size                     2226456 bytes
Variable Size                117442280 bytes
Database Buffers              33554432 bytes
Redo Buffers                   5439488 bytes

RMAN> restore spfile from '+FRA/orcl_asm/autobackup/2013_03_26/s_811083241.266.811083245';


Starting restore at 26-MAR-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +FRA/orcl_asm/autobackup/2013_03_26/s_811083241.266.811083245
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 26-MAR-13

RMAN> shutdown abort;
Oracle instance shut down
RMAN> exit

[oracle@oel5-asm ~]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Tue Mar 26 13:33:07 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database (not started)

RMAN> startup mount;

Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 03/26/2013 13:33:16
ORA-00205: error in identifying control file, check alert log for more info


RMAN> restore controlfile from '+FRA/orcl_asm/autobackup/2013_03_26/s_811083241.266.811083245';


Starting restore at 26-MAR-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=178 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output file name=+DATA/orcl_asm/controlfile/current.257.811085687
output file name=+DATA/orcl_asm/controlfile/current.258.811085689
Finished restore at 26-MAR-13

RMAN> alter database mount;

RMAN> run { restore database; recover database; };
RMAN> sql ‘ alter database open resetlogs’;


No comments:

Post a Comment

100 Oracle DBA Interview Questions and Answers

  Here are 100 tricky interview questions tailored for a Senior Oracle DBA role. These questions span a wide range of topics, including perf...