溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

基于scn的恢復是怎樣的

發(fā)布時間:2021-11-12 15:13:11 來源:億速云 閱讀:117 作者:柒染 欄目:關(guān)系型數(shù)據(jù)庫

今天就跟大家聊聊有關(guān)基于scn的恢復是怎樣的,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

--先背備份:(熱備)

[oracle@wang ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 8 19:35:11 2017

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

connected to target database: DBDB (DBID=3282897732)

RMAN> backup database;

Starting backup at 08-DEC-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/DBdb/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/DBdb/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/DBdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 08-DEC-17
channel ORA_DISK_1: finished piece 1 at 08-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnndf_TAG20171208T193949_f2nyj5gy_.bkp tag=TAG20171208T193949 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
input datafile file number=00002 name=/u01/app/oracle/oradata/DBdb/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/DBdb/example01.dbf
channel ORA_DISK_1: starting piece 1 at 08-DEC-17
 channel ORA_DISK_1: finished piece 1 at 08-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnndf_TAG20171208T193949_f2nykwl2_.bkp tag=TAG20171208T193949 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
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 08-DEC-17
channel ORA_DISK_1: finished piece 1 at 08-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_ncsnf_TAG20171208T193949_f2nylpqk_.bkp tag=TAG20171208T193949 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-DEC-17

RMAN>     


二、模擬操作:
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3960846

SQL>  
SQL> create table scott.scn_a as select * from dba_objects;

Table created.

SQL> select count(*) from scott.scn_a;

  COUNT(*)
----------
     87053

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3960968

SQL>
SQL> create table hr.scn_b as select * from dba_objects;

Table created.

SQL> select count(*) from hr.scn_b;

  COUNT(*)
----------
     87054

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3961042

SQL>        
SQL> alter system switch logfile;

System altered.

SQL>
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3961063

SQL>
SQL> alter system checkpoint;

System altered.

SQL>
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3961088

--刪除表scn_a/scn_b:
SQL> drop table scott.scn_a purge;

Table dropped.

SQL> drop table hr.scn_b purge;

Table dropped.


--進行恢復:
--關(guān)庫,啟動到mount狀態(tài):
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2257840 bytes
Variable Size             549456976 bytes
Database Buffers          281018368 bytes
Redo Buffers                2371584 bytes
Database mounted.
SQL>

啟用rman進行恢復:
[oracle@wang ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 8 19:49:38 2017

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

connected to target database: DBDB (DBID=3282897732, not open)

RMAN>      

RMAN> run {  
    set until scn =3960968;  
    restore database;  
    recover database;  
    alter database open resetlogs; }

executing command: SET until clause

Starting restore at 08-DEC-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/DBdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/DBdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/DBdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnndf_TAG20171208T193949_f2nyj5gy_.bkp
  channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnndf_TAG20171208T193949_f2nyj5gy_.bkp tag=TAG20171208T193949
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:15
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/DBdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/DBdb/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnndf_TAG20171208T193949_f2nykwl2_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnndf_TAG20171208T193949_f2nykwl2_.bkp tag=TAG20171208T193949
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 08-DEC-17

Starting recover at 08-DEC-17
using channel ORA_DISK_1

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

Finished recover at 08-DEC-17

database opened

RMAN>   

--驗證:
SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select count(*) from scott.scn_a;

  COUNT(*)
----------
     87053

SQL>
SQL> select count(*) from hr.scn_b;
select count(*) from hr.scn_b
                        *
ERROR at line 1:
ORA-00942: table or view does not exist

因為恢復時只是恢復到創(chuàng)建scn_a表后查詢到的current_scn,此時表scn_b還沒有創(chuàng)建。

看完上述內(nèi)容,你們對基于scn的恢復是怎樣的有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

scn
AI