ASMCMD执行ASM元数据备份与还原

备份你的磁盘组通常来说是不需要的,因为可以简单的重建它并且还原它的内容。用户创建或定义大 量用户模板,别名与目录并且磁盘组需要重新建,你需要手动重新创建这些ASM用户对象。这了完成 这个任务,Oracle 11g引入了新的工具来备份ASM对象的元数据。新的工具, ASM Metadata Backup adn Restore(AMBR),它是ASMCMD的一个子组件。AMBR提供了使用完全相同模板,属性与别名目录结 构来重新创建之前创建过的ASM磁盘组,因此保护磁盘组结构。AMBR有两种模式:备份与还原。

备份模式
使用备份模式,关于ASM磁盘,磁盘组与故障磁盘组配置,模板,属性与别名目录结构等信息会被收 集。这此虎将被转换成SQL命令并以存储在用户定义的元数据备份(MDB)文件中,在执行磁盘组还原时供md_restore命令使用。这个文件包含还原操作可以重建与还原整个磁盘组的所需要的元数据信息 。下面是备份元数据的语法:

[grid@jyrac1 ~]$ 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

md_backup命令在每次执行时都会创建一个备份文件。用户可以控制创建的脚本存储目录以及需要备 份的磁盘组列表。缺省情况下,MDB文件存储在当前执行命令的目录中并且生成名叫 ambr_backup_intermediate_file。

MDB文件,缺省情况下,它有用来创建所有mount磁盘组的元数据。因为MDB文件是一个文本文件,如 果只需要还原特定的ASM对象而不是整个磁盘组,用户可以手动编辑存储的这些信息。然而,当编辑文 件时需要注意,在编辑之前总是要对MDB文件创建一个备份。在编辑出现的错误会造成还原操作的失 败。注意md_restore命令在处理之前对输入文件不执行任何语法或语义检查。

下面的列表重复查看MDB文件中的每个段。每一部分通过唯一标签/section ID来进行标识。还原模式 将使用这个标签来定位备份文件中的section。如果对于期待的标签没有找到精确的匹配,md_backup 命令会继续搜索下一个有效的标签。编辑错误可能会造成section被跳过。对于备份模式,md_backup 命令将连接到ASM实例来收集以下信息:
1.磁盘组信息(对于每个将要备份的磁盘):它是文件中的第一个部分并且包含了创建磁盘组的SQL语句
1.1磁盘组名
1.2冗余类型
1.3ASM与DB的兼容性
1.4AU大小

2.磁盘信息(对于要备份的磁盘组所包含的每个磁盘)
2.1磁盘组名
2.2磁盘标签(name),如果用户指定
2.3磁盘路径
2.4操作系统大小与磁盘的ASM大小
2.5故障磁盘组,如果用户指定

3.别名目录信息(对于每个用户创建目录)
3.1磁盘组名
3.2不使用磁盘组名的别名条目的完整路径

4.属性目录

5.模板目录信息。对于每个磁盘组模式有一个条目。
5.1基于系统模板的改变来编辑缺省/系统模板
5.2创建用户定义模式
对于每个模板,构建以下信息:
5.2.1磁盘组名
5.2.2模板名
5.2.3冗余
5.2.4条带
5.2.5系统

还原模式
AMBR还原模式最基本的任务就是将元数据还原到磁盘组中,这是通过执行ASMCMD的子命令md_restore 来完成的。它假设对于磁盘组的数据库文件有一份良好的备份存在。在成功还原磁盘组之后需要通过 RMAN来还原数据库备份。

还原模式可以重新创建磁盘组(基于MDB文件中的设置列表)或使用任何请求的修改来还原磁盘组到现有磁盘组中,比如改变磁盘组名。

md_restore命令重建所有用户定义模板与改变。

[grid@jyrac1 ~]$ 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

备份与还原例子
下面将介绍md_backup与md_restore的使用方法:
1.创建一些用户定义ASM目录,别名与模板
2.执行md_backup命令来创建MDB文件
3.使用RMAN来备份数据库并存储在磁盘组中
4.模拟完整磁盘组故障,删除磁盘组
5.使用md_restore还原磁盘组
6.使用RMAN还原与恢复数据库

1.创建用户定义的ASM对象

SQL> alter diskgroup datadg add template temp_unprot attributes(fine unprotected);

Diskgroup altered.

SQL> alter diskgroup datadg add template important_data attributes(fine mirror);

Diskgroup altered.

SQL> alter diskgroup datadg add alias  '+DATADG/jyrac/users_01.dbf'  for'+DATADG/jyrac/datafile/users.259.928610631';

Diskgroup altered.

SQL> alter diskgroup datadg add directory '+DATADG/jyrac/oradata';

Diskgroup altered.

SQL> alter diskgroup datadg add alias '+DATADG/jyrac/oradata/sysaux_01.dbf' for  '+DATADG/jyrac/datafile/sysaux.257.928610631';

Diskgroup altered.

SQL> alter diskgroup datadg add directory '+DATADG/jyrac/temp_files';

Diskgroup altered.

SQL> alter diskgroup datadg add alias '+DATADG/jyrac/temp_files/temp_01.dbf' for  '+DATADG/jyrac/tempfile/temp.263.928610813';

Diskgroup altered.


SQL> select name,redundancy,stripe from v$asm_template where system='N';

NAME                           REDUND STRIPE
------------------------------ ------ ------
TEMP_UNPROT                    UNPROT FINE
IMPORTANT_DATA                 MIRROR FINE
NONCRITCAL_FILES               UNPROT COARSE

SQL> select name,file_number,alias_directory from v$asm_alias where system_created='N'  and alias_directory='Y';

NAME                                                                   FILE_NUMBER A
---------------------------------------------------------------------- ----------- -
asmparameterfile                                                        4294967295 Y
oradata                                                                 4294967295 Y
temp_files                                                              4294967295 Y
yoda                                                                    4294967295 Y
data                                                                    4294967295 Y

2.使用md_backup命令来对磁盘组进行备份

[grid@jyrac1 ~]$ asmcmd md_backup  /home/grid/datadg_backup_20161212 -G datadg
Disk group metadata to be backed up: DATADG
Current alias directory path: JYRAC/PARAMETERFILE
Current alias directory path: JYRAC/ONLINELOG
Current alias directory path: JYRAC
Current alias directory path: JYRAC/temp_files
Current alias directory path: JYRAC/DATAFILE
Current alias directory path: JYRAC/oradata
Current alias directory path: JYRAC/CONTROLFILE
Current alias directory path: JYRAC/TEMPFILE

datadg_backup_20161212文件包含以下内容(系统生成的模板,比如datafile与controlfile)

[grid@jyrac1 ~]$ cat datadg_backup_20161212
@diskgroup_set = (
                   {
                     'ATTRINFO' => {
                                     '_._DIRVERSION' => '11.2.0.0.0',
                                     'COMPATIBLE.ASM' => '11.2.0.0.0',
                                     'COMPATIBLE.RDBMS' => '10.1.0.0.0'
                                   },
                     'DISKSINFO' => {
                                      'DATADG_0001' => {
                                                         'DATADG_0001' => {
                                                                            'TOTAL_MB'  => '5120',
                                                                            'FAILGROUP'  => 'DATADG_0001',
                                                                            'NAME' =>  'DATADG_0001',
                                                                            'DGNAME' =>  'DATADG',
                                                                            'PATH' =>  '/dev/raw/raw11'
                                                                          }
                                                       },
                                      'DATADG_0002' => {
                                                         'DATADG_0002' => {
                                                                            'TOTAL_MB'  => '5120',
                                                                            'FAILGROUP'  => 'DATADG_0002',
                                                                            'NAME' =>  'DATADG_0002',
                                                                            'DGNAME' =>  'DATADG',
                                                                            'PATH' =>  '/dev/raw/raw3'
                                                                          }
                                                       },
                                      'DATADG_0003' => {
                                                         'DATADG_0003' => {
                                                                            'TOTAL_MB'  => '5120',
                                                                            'FAILGROUP'  => 'DATADG_0003',
                                                                            'NAME' =>  'DATADG_0003',
                                                                            'DGNAME' =>  'DATADG',
                                                                            'PATH' =>  '/dev/raw/raw4'
                                                                          }
                                                       },
                                      'DATADG_0000' => {
                                                         'DATADG_0000' => {
                                                                            'TOTAL_MB'  => '5120',
                                                                            'FAILGROUP'  => 'DATADG_0000',
                                                                            'NAME' =>  'DATADG_0000',
                                                                            'DGNAME' =>  'DATADG',
                                                                            'PATH' =>  '/dev/raw/raw10'
                                                                          }
                                                       }
                                    },
                     'DGINFO' => {
                                   'DGTORESTORE' => 0,
                                   'DGCOMPAT' => '11.2.0.0.0',
                                   'DGNAME' => 'DATADG',
                                   'DGDBCOMPAT' => '10.1.0.0.0',
                                   'DGTYPE' => 'NORMAL',
                                   'DGAUSZ' => '1048576'
                                 },
                     'ALIASINFO' => {
                                      '6' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/PARAMETERFILE',
                                               'REFERENCE_INDEX' => '50331966'
                                             },
                                      '1' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/DATAFILE',
                                               'REFERENCE_INDEX' => '50331754'
                                             },
                                      '4' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/ONLINELOG',
                                               'REFERENCE_INDEX' => '50331860'
                                             },
                                      '0' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 0,
                                               'ALIASNAME' => 'JYRAC',
                                               'REFERENCE_INDEX' => '50331701'
                                             },
                                      '3' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/temp_files',
                                               'REFERENCE_INDEX' => '50332072'
                                             },
                                      '7' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/oradata',
                                               'REFERENCE_INDEX' => '50332019'
                                             },
                                      '2' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/CONTROLFILE',
                                               'REFERENCE_INDEX' => '50331807'
                                             },
                                      '5' => {
                                               'DGNAME' => 'DATADG',
                                               'LEVEL' => 1,
                                               'ALIASNAME' => 'JYRAC/TEMPFILE',
                                               'REFERENCE_INDEX' => '50331913'
                                             }
                                    },
                     'TEMPLATEINFO' => {
                                         '11' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'AUTOBACKUP',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '7' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'DATAFILE',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '2' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'DUMPSET',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '17' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'FINE',
                                                   'TEMPNAME' => 'TEMP_UNPROT',
                                                   'REDUNDANCY' => 'UNPROT',
                                                   'SYSTEM' => 'N'
                                                 },
                                         '1' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'ASMPARAMETERFILE',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '18' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'FINE',
                                                   'TEMPNAME' => 'IMPORTANT_DATA',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'N'
                                                 },
                                         '0' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'PARAMETERFILE',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '16' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'OCRFILE',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '13' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'CHANGETRACKING',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '6' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'ONLINELOG',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '3' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'FINE',
                                                  'TEMPNAME' => 'CONTROLFILE',
                                                  'REDUNDANCY' => 'HIGH',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '9' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'BACKUPSET',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '12' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'XTRANSPORT',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '14' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'FLASHBACK',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '15' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'DATAGUARDCONFIG',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '8' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'TEMPFILE',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '4' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'FLASHFILE',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                },
                                         '10' => {
                                                   'DGNAME' => 'DATADG',
                                                   'STRIPE' => 'COARSE',
                                                   'TEMPNAME' => 'XTRANSPORT BACKUPSET',
                                                   'REDUNDANCY' => 'MIRROR',
                                                   'SYSTEM' => 'Y'
                                                 },
                                         '5' => {
                                                  'DGNAME' => 'DATADG',
                                                  'STRIPE' => 'COARSE',
                                                  'TEMPNAME' => 'ARCHIVELOG',
                                                  'REDUNDANCY' => 'MIRROR',
                                                  'SYSTEM' => 'Y'
                                                }
                                       }
                   }
                 );


3.使用RMAN对数据库进行备份:

[oracle@jyrac1 ~]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Dec 12 15:24:25 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: JYRAC (DBID=2655496871)

RMAN> backup database plus archivelog;


Starting backup at 12-DEC-16
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 instance=jyrac1 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=2 sequence=115 RECID=2 STAMP=930409949
input archived log thread=1 sequence=53 RECID=1 STAMP=930409946
input archived log thread=1 sequence=54 RECID=3 STAMP=930410023
input archived log thread=2 sequence=116 RECID=4 STAMP=930410024
input archived log thread=1 sequence=55 RECID=5 STAMP=930410686
input archived log thread=2 sequence=117 RECID=6 STAMP=930410688
channel ORA_DISK_1: starting piece 1 at 12-DEC-16
channel ORA_DISK_1: finished piece 1 at 12-DEC-16
piece handle=/rman_backup/backup_09rn9s66_1_1 tag=TAG20161212T152454 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-DEC-16

Starting backup at 12-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=+DATADG/jyrac/datafile/sysaux.257.928610631
input datafile file number=00001 name=+DATADG/jyrac/datafile/system.256.928610629
input datafile file number=00005 name=+DATADG/jyrac/datafile/example.264.928610823
input datafile file number=00006 name=+DATADG/jyrac/datafile/undotbs2.265.928611101
input datafile file number=00003 name=+DATADG/jyrac/datafile/undotbs1.258.928610631
input datafile file number=00004 name=+DATADG/jyrac/datafile/users.259.928610631
channel ORA_DISK_1: starting piece 1 at 12-DEC-16
channel ORA_DISK_1: finished piece 1 at 12-DEC-16
piece handle=/rman_backup/backup_0arn9s68_1_1 tag=TAG20161212T152456 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 12-DEC-16
channel ORA_DISK_1: finished piece 1 at 12-DEC-16
piece handle=/rman_backup/backup_0brn9s80_1_1 tag=TAG20161212T152456 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 12-DEC-16

Starting backup at 12-DEC-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=56 RECID=8 STAMP=930410761
input archived log thread=2 sequence=118 RECID=7 STAMP=930410760
channel ORA_DISK_1: starting piece 1 at 12-DEC-16
channel ORA_DISK_1: finished piece 1 at 12-DEC-16
piece handle=/rman_backup/backup_0crn9s8a_1_1 tag=TAG20161212T152602 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-DEC-16

4.模拟磁盘组丢失,删除磁盘组:
在所有节点执行以下命令:

SQL>  alter diskgroup datadg dismount;

Diskgroup altered.

在任意节点执行以下命令来删除磁盘组:

SQL> drop diskgroup datadg force including contents;

Diskgroup dropped.

5.使用md_restore命令来还原磁盘组:

[grid@jyrac1 ~]$ asmcmd md_restore --full -G DATADG  /home/grid/datadg_backup_20161212
Current Diskgroup metadata being restored: DATADG
Diskgroup DATADG created!
System template AUTOBACKUP modified!
System template DATAFILE modified!
User template TEMP_UNPROT created!
System template DUMPSET modified!
System template ASMPARAMETERFILE modified!
User template IMPORTANT_DATA created!
System template PARAMETERFILE modified!
System template OCRFILE modified!
System template CHANGETRACKING modified!
System template ONLINELOG modified!
System template CONTROLFILE modified!
System template BACKUPSET modified!
System template XTRANSPORT modified!
System template FLASHBACK modified!
System template DATAGUARDCONFIG modified!
System template TEMPFILE modified!
System template FLASHFILE modified!
System template XTRANSPORT BACKUPSET modified!
System template ARCHIVELOG modified!
Directory +DATADG/JYRAC re-created!
Directory +DATADG/JYRAC/DATAFILE re-created!
Directory +DATADG/JYRAC/CONTROLFILE re-created!
Directory +DATADG/JYRAC/temp_files re-created!
Directory +DATADG/JYRAC/ONLINELOG re-created!
Directory +DATADG/JYRAC/TEMPFILE re-created!
Directory +DATADG/JYRAC/PARAMETERFILE re-created!
Directory +DATADG/JYRAC/oradata re-created!

md_restore命令只会在执行该命令的节点mount所还原的磁盘组。因此在RAC环境中,对于其它节点需 要手动mount还原的磁盘组

SQL> alter diskgroup datadg mount;

Diskgroup altered.

6.还原恢复数据库:

[oracle@jyrac1 ~]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Dec 12 15:41:59 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)


RMAN> set DBID 2655496871

executing command: SET DBID

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
ORA-01565: error in identifying file '+DATADG/jyrac/spfilejyrac.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATADG/jyrac/spfilejyrac.ora
ORA-15056: additional error message
ORA-17503: ksfdopn:2 Failed to open file +DATADG/jyrac/spfilejyrac.ora
ORA-15173: entry 'spfilejyrac.ora' does not exist in directory 'jyrac'
ORA-06512: at line 4

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes
Variable Size                285213576 bytes
Database Buffers             775946240 bytes
Redo Buffers                   5517312 bytes


RMAN> restore spfile from '/rman_backup/backup_0brn9s80_1_1';

Starting restore at 12-DEC-16
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /rman_backup/backup_0brn9s80_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 12-DEC-16


RMAN> restore controlfile to '+datadg' from '/rman_backup/backup_0brn9s80_1_1';

Starting restore at 12-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=194 instance=jyrac1 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 12-DEC-16

SQL> alter system set control_files='+DATADG/jyrac/controlfile/current.257.930412709'  scope=spfile sid='*';

System altered.

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 2505338880 bytes
Fixed Size                  2255832 bytes
Variable Size             687866920 bytes
Database Buffers         1795162112 bytes
Redo Buffers               20054016 bytes
Database mounted.



RMAN> recover database;

Starting recover at 12-DEC-16
using channel ORA_DISK_1

starting media recovery

archived log file name=+ARCHDG/jyrac/1_56_928610797.dbf thread=1 sequence=56
archived log file name=+ARCHDG/jyrac/2_118_928610797.dbf thread=2 sequence=118
media recovery complete, elapsed time: 00:00:16
Finished recover at 2012-12-12 22:25:25


SQL> alter database open resetlogs;

Database altered.

发表评论

电子邮件地址不会被公开。