【備份恢復】丟失所有控制檔案,利用RMAN進行恢復操作

不一樣的天空w發表於2016-10-20

丟失所有控制檔案之利用RMAN進行恢復操作(利用的是備份現在的控制檔案形式)
——準備工作:

SQL> show parameter control

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

control_file_record_keep_time        integer     7

control_files                        string      /u01/app/oracle/oradata/ORA11G

                                        R2/control01.ctl, /u01/app/ora

                                      cle/oradata/ORA11GR2/control02 .ctl

                                              

control_management_pack_access       string      DIAGNOSTIC+TUNING

SQL>

 

SQL> archive log list

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch

Oldest online log sequence     12

Current log sequence           14


——建立歸檔目錄:

[oracle@wang ~]$ cd /u01/app

[oracle@wang app]$ ls

oracle  oraInventory

[oracle@wang app]$ mkdir backup

[oracle@wang app]$ cd backup/

[oracle@wang backup]$ pwd

/u01/app/backup

——修改歸檔路徑:

SQL> alter system set log_archive_dest='/u01/app/backup';

 

System altered.

 

SQL> show parameter log_archive_dest

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest                     string      /u01/app/backup

log_archive_dest_1                   string

log_archive_dest_10                  string

log_archive_dest_11                  string

log_archive_dest_12                  string


——啟動歸檔:

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                  2257800 bytes

Variable Size             503319672 bytes

Database Buffers          322961408 bytes

Redo Buffers                2392064 bytes

Database mounted.

SQL> 

SQL> alter database archivelog;

 

Database altered.

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/backup

Oldest online log sequence     12

Next log sequence to archive   14

Current log sequence           14


——登入到目標資料庫備份:

[oracle@wang ORA11GR2]$ rman target /

 

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Sep 23 07:13:07 2016

 

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

 

connected to target database: ORA11GR2 (DBID=237843809, not open)

 

RMAN> alter database open;

 

using target database control file instead of recovery catalog

database opened

 

RMAN> configure channel device type disk format '/u01/app/backup/db_%U.rmn';

 

new RMAN configuration parameters:

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/backup/db_%U.rmn';

new RMAN configuration parameters are successfully stored

 

RMAN>  backup as backupset database include current controlfile plus archivelog format '/u01/app/backup/db_%U.rmn' delete all input;

 

Starting backup at 23-SEP-16

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=35 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=1 sequence=14 RECID=1 STAMP=923296567

channel ORA_DISK_1: starting piece 1 at 23-SEP-16

channel ORA_DISK_1: finished piece 1 at 23-SEP-16

piece handle=/u01/app/backup/db_01rggopo_1_1.rmn tag=TAG20160923T071607 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/backup/1_14_921272292.dbf RECID=1 STAMP=923296567

Finished backup at 23-SEP-16

 

Starting backup at 23-SEP-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=00001 name=/u01/app/oracle/oradata/ORA11GR2/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/ORA11GR2/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/ORA11GR2/users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-SEP-16

channel ORA_DISK_1: finished piece 1 at 23-SEP-16

piece handle=/u01/app/backup/db_02rggopp_1_1.rmn tag=TAG20160923T071609 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

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 23-SEP-16

channel ORA_DISK_1: finished piece 1 at 23-SEP-16

piece handle=/u01/app/backup/db_03rggoqs_1_1.rmn tag=TAG20160923T071609 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 23-SEP-16

 

Starting backup at 23-SEP-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=15 RECID=2 STAMP=923296606

channel ORA_DISK_1: starting piece 1 at 23-SEP-16

channel ORA_DISK_1: finished piece 1 at 23-SEP-16

piece handle=/u01/app/backup/db_04rggoqv_1_1.rmn tag=TAG20160923T071647 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/backup/1_15_921272292.dbf RECID=2 STAMP=923296606

Finished backup at 23-SEP-16

 

1)  本測試透過 RMAN 恢復控制檔案全部丟失

SQL> host

[oracle@wang ORA11GR2]$  ls cont*

control01.ctl  control02.ctl

[oracle@wang ORA11GR2]$ rm *.ctl

[oracle@wang ORA11GR2]$

[oracle@wang ORA11GR2]$ ls cont*

ls: cont*: No such file or directory

[oracle@wang ORA11GR2]$

 

2)  由於控制檔案已經全部丟失,所以一定無法一致性關閉,只能採取極端的手段 abort 選項關閉資料

[oracle@wang ORA11GR2]$ exit

exit

 

SQL> shutdown immediate;

ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/oradata/ORA11GR2/control01.ctl'

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

SQL>

SQL> shutdown abort;   

ORACLE instance shut down.

SQL>

 

3)  透過 RMAN 恢復控制檔案

RMAN> restore controlfile from '/u01/app/backup/db_03rggoqs_1_1.rmn';

 

Starting restore at 23-SEP-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=/u01/app/oracle/oradata/ORA11GR2/control01.ctl

output file name=/u01/app/oracle/oradata/ORA11GR2/control02.ctl

Finished restore at 23-SEP-16

 

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

說明控制檔案已經恢復回來了


RMAN> recover database;
(例項前滾,運用日誌恢復一致性狀態)

Starting recover at 23-SEP-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

 

starting media recovery

 

archived log for thread 1 with sequence 15 is already on disk as file /u01/app/oracle/oradata/ORA11GR2/redo03.log

archived log for thread 1 with sequence 16 is already on disk as file /u01/app/oracle/oradata/ORA11GR2/redo01.log

archived log file name=/u01/app/oracle/oradata/ORA11GR2/redo03.log thread=1 sequence=15

archived log file name=/u01/app/oracle/oradata/ORA11GR2/redo01.log thread=1 sequence=16

media recovery complete, elapsed time: 00:00:00

Finished recover at 23-SEP-16

 

RMAN> alter database open resetlogs;(因為備份時的日誌不是最新的,且是根據舊版控制檔案修復資料庫,所以要以resetlogs方式啟動資料庫)

 

database opened
完成!!!!!!!!!!
當然也可以將rman的永久配置項的控制檔案自動備份功能開啟,然後每次備份時控制檔案都自動備份一份,恢復是可以用自動控制檔案備份儲存的目錄內的控制檔案完成恢復控制檔案工作!!!!

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

相關文章