Sunday, September 18, 2016

Oracle12C - Three ways you can re-create the lost ASM diskgroup and restore the data.

You use RMAN to back up the database and the MD_BACKUP command to
back up the ASM metadata regularly.

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

The first example shows the use of the backup command when run without the disk group option. This example backs up all the mounted disk groups and creates the backup image in the /backup/allDGs_bkp file. The second example creates a backup of the data disk group. The metadata backup that this example creates is saved in the /backup/allDGs_bkp file.
ASMCMD [+] > md_backup /backup/allDGs_bkp
Disk group metadata to be backed up: DATA
Disk group metadata to be backed up: FRA
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ORCL/PARAMETERFILE
Current alias directory path: ORCL
Current alias directory path: ASM
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: ORCL/TEMPFILE
Current alias directory path: ORCL/ARCHIVELOG/2010_04_20
Current alias directory path: ORCL
Current alias directory path: ORCL/BACKUPSET/2010_04_21
Current alias directory path: ORCL/ARCHIVELOG/2010_04_19
Current alias directory path: ORCL/BACKUPSET/2010_04_22
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ORCL/BACKUPSET/2010_04_20
Current alias directory path: ORCL/ARCHIVELOG
Current alias directory path: ORCL/BACKUPSET
Current alias directory path: ORCL/ARCHIVELOG/2010_04_22
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/ARCHIVELOG/2010_04_21

ASMCMD [+] > md_backup /backup/allDGs_bkp/data20100422 -G data
Disk group metadata to be backed up: DATA
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ASM
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: ORCL/PARAMETERFILE
Current alias directory path: ORCL
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/TEMPFILE

You lost an ASM disk group DG1 due to hardware failure.  You can  use the below method to restore ans recover the ASM diskgroup

1. Use the MD_RESTORE command to restore the disk group with the changed disk group specification, failure group specification, name, and other attributes
and use RMAN to restore the data.

md_restore  backup_file [--silent]
     [--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]']
     [-S sql_script_file] [-G 'diskgroup [,diskgroup...]']
The first example restores the disk group data from the backup script and creates a copy.
ASMCMD [+] > md_restore –-full –G data –-silent /backup/allDGs_bkp


The second example takes an existing disk group data and restores its metadata.
ASMCMD [+] > md_restore –-nodg –G data –-silent /backup/allDGs_bkp

The third example restores disk group data completely but the new disk group that is created is named data2.
ASMCMD [+] > md_restore –-newdg -o 'data:data2' --silent /backup/data20100422

The fourth example restores from the backup file after applying the overrides defined in the override.sql script file.
ASMCMD [+] > md_restore -S override.sql --silent /backup/data20100422


2. Use the MKDG command to restore the disk group with the same configuration as the backed- up disk group name and same set of disks and failure group configuration, and use RMAN to restore the data.

3. Use the MKDG command to add a new disk group DG1 with the same or different specifications for failure group and other attributes and use RMAN to restore the data.

mkdg { config_file.xml | 'contents_of_xml_file' }
OptionDescription
config_file
Name of the XML file that contains the configuration for the new disk group. mkdg searches for the XML file in the directory where ASMCMD was started unless a path is specified.

contents_of_xml_file
The XML script enclosed in single quotations.

Below example shows the basic structure and the valid tags with their respective attributes for the mkdg XML configuration file.
<dg>  disk group
      name         disk group name
      redundancy   normal, external, high
 
<fg>  failure group
      name         failure group name
</fg>

<dsk> disk
      name         disk name
      string       disk path
      size         size of the disk to add
      force        true specifies to use the force option
</dsk>

<a>   attribute
      name         attribute name
      value        attribute value
</a>

</dg>


The following is an example of an XML configuration file for mkdg. The configuration file creates a disk group named data with normal redundancy. Two failure groups, fg1 and fg2, are created, each with two disks identified by associated disk strings. The disk group compatibility attributes are all set to 11.2.
Example mkdg sample XML configuration file
<dg name="data" redundancy="normal">
  <fg name="fg1">
    <dsk string="/dev/disk1"/>
    <dsk string="/dev/disk2"/>
  </fg>
  <fg name="fg2">
    <dsk string="/dev/disk3"/>
    <dsk string="/dev/disk4"/>
  </fg>
  <a name="compatible.asm" value="11.2"/>
  <a name="compatible.rdbms" value="11.2"/>
  <a name="compatible.advm" value="11.2"/>
</dg>










No comments:

Post a Comment