What is the recovery based on scn?
Today, I will talk to you about what scn-based recovery is like. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.
-- back up first: (hot backup)
[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 >
Second, simulation operation:
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
-- Delete table scn_a/scn_b:
SQL > drop table scott.scn_a purge
Table dropped.
SQL > drop table hr.scn_b purge
Table dropped.
-- restore:
-- close the library and start to mount status:
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 >
Enable rman for recovery:
[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 >
-- verify:
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
Because the restore is only to the current_scn queried after the creation of the scn_a table, the table scn_b has not yet been created.
After reading the above, do you have any further understanding of scn-based recovery? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.