ASMCMD執行ASM後設資料備份與還原

eric0435發表於2016-12-12

備份你的磁碟組通常來說是不需要的,因為可以簡單的重建它並且還原它的內容。使用者建立或定義大 量使用者模板,別名與目錄並且磁碟組需要重新建,你需要手動重新建立這些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.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2130307/,如需轉載,請註明出處,否則將追究法律責任。

相關文章