rman 非歸檔模式下停庫備份與恢復

chenoracle發表於2015-07-08
rman 非歸檔模式下停庫備份與恢復


一 非歸檔模式
SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     31
Current log sequence           33


二 關閉資料庫,掛載資料庫進行一致性備份
RMAN> shutdown immediate;    
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    1252663296 bytes

Fixed Size                     2212936 bytes
Variable Size                805309368 bytes
Database Buffers             436207616 bytes
Redo Buffers                   8933376 bytes


RMAN> run{
2> allocate channel c1 type disk format '/home/oracle/rman/chen_%U';
3> backup database include current controlfile;
4> }

allocated channel: c1
channel c1: SID=133 device type=DISK

Starting backup at 07-JUL-15
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ogg1/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ogg1/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ogg1/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ogg1/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ogg1/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/ogg1/chen01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ogg1/test01.dbf
channel c1: starting piece 1 at 07-JUL-15
channel c1: finished piece 1 at 07-JUL-15
piece handle=/home/oracle/rman/chen_0gqbf543_1_1 tag=TAG20150707T153219 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:35
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 07-JUL-15
channel c1: finished piece 1 at 07-JUL-15
piece handle=/home/oracle/rman/chen_0hqbf557_1_1 tag=TAG20150707T153219 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-JUL-15

Starting Control File and SPFILE Autobackup at 07-JUL-15
piece handle=/u01/app/oracle/flash_recovery_area/OGG1/autobackup/2015_07_07/o1_mf_s_884446096_bsq059ok_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-JUL-15
released channel: c1

三 備份結束後開啟資料庫,生成測試表,插入資料
RMAN> startup

database is already started
database opened

SQL> conn chen/chen
Connected.

SQL> insert into t1 values(20000);
SQL> commit;

SQL> select * from t1;
        ID
----------
     10000
     10000
     20000


四  剪下資料庫檔案到其他目錄,模擬資料庫故障
SQL> shutdown immediate

[oracle@ogg1 ~]$ cd /u01/app/oracle/oradata/ogg1/

[oracle@ogg1 ogg1]$ cd ..

[oracle@ogg1 oradata]$ mv ogg1/ /home/oracle/

五 啟動資料庫失敗
SQL> startup nomount
ORACLE instance started.


Total System Global Area 1252663296 bytes
Fixed Size                  2212936 bytes
Variable Size             805309368 bytes
Database Buffers          436207616 bytes
Redo Buffers                8933376 bytes


資料庫掛載失敗(找不到控制檔案)
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info


檢視警告日誌檔案
[oracle@ogg1 ~]$ vim /u01/app/oracle/diag/rdbms/ogg1/ogg1/trace/alert_ogg1.log 
Tue Jul 07 15:41:46 2015
alter database mount
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/ogg1/control01.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Jul 07 15:41:46 2015
Checker run found 1 new persistent data failures
ORA-205 signalled during: alter database mount...


六 關閉資料庫,rman恢復
[oracle@ogg1 ~]$ cd /u01/app/oracle/oradata/

[oracle@ogg1 oradata]$ mkdir ogg1

RMAN> shutdown immediate

Oracle instance shut down

RMAN> startup nomount

connected to target database (not started)
Oracle instance started

Total System Global Area    1252663296 bytes

Fixed Size                     2212936 bytes
Variable Size                805309368 bytes
Database Buffers             436207616 bytes
Redo Buffers                   8933376 bytes

先將控制檔案恢復出來
RMAN> restore controlfile from autobackup;

Starting restore at 07-JUL-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: OGG1
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/OGG1/autobackup/2015_07_07/o1_mf_s_884446096_bsq059ok_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/flash_recovery_area/OGG1/autobackup/2015_07_07/o1_mf_s_884446096_bsq059ok_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/ogg1/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/ogg1/control02.ctl
Finished restore at 07-JUL-15

掛載資料庫,進行資料庫恢復
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> run{
2> restore database;
3> recover database;
4> }

......
starting media recovery
RMAN-08187: WARNING: media recovery until SCN 1590816 complete
Finished recover at 07-JUL-15

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 07/07/2015 15:56:43
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlogs;

database opened

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1
Current log sequence           1

SQL> conn chen/chen
Connected.

恢復成功,丟失一部分資料
SQL> select * from t1;

        ID
----------
     10000
     10000
 

歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!

rman 非歸檔模式下停庫備份與恢復

rman 非歸檔模式下停庫備份與恢復



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

相關文章