跳过归档日志的完全非常规恢复(一) http://blog.chinaunix.net/uid-22948773-id-3294762.html
跳过归档日志的完全非常规恢复(二) http://blog.chinaunix.net/uid-22948773-id-3294763.html
跳过归档日志的完全非常规恢复(三) http://blog.chinaunix.net/uid-22948773-id-3294767.html
跳过归档日志的完全非常规恢复(四) http://blog.chinaunix.net/uid-22948773-id-3294770.html
跳过归档日志的完全非常规恢复(五) http://blog.chinaunix.net/uid-22948773-id-3294773.html
步骤一、首先创建测试环境
点击(此处)折叠或打开
- SQL> select name from v$dbfile;
- NAME
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/huateng/users01.dbf
- /u01/app/oracle/oradata/huateng/undotbs01.dbf
- /u01/app/oracle/oradata/huateng/sysaux01.dbf
- /u01/app/oracle/oradata/huateng/system01.dbf
- /u01/app/oracle/oradata/huateng/example01.dbf
- SQL> create tablespace htyansp datafile '/u01/app/oracle/oradata/huateng/htyansp01.dbf' size 10m;
- Tablespace created.
- SQL> create user htyansp identified by htyansp;
- User created.
- SQL> alter user htyansp default tablespace htyansp;
- User altered.
- SQL> grant dba to htyansp;
- Grant succeeded.
- SQL> alter system switch logfile;
- System altered.
- SQL> archive log list
- Database log mode Archive Mode
- Automatic archival Enabled
- Archive destination /archivelog
- Oldest online log sequence 5
- Next log sequence to archive 7
- Current log sequence 7
上面创建了一个用户htyansp 及其相应的表空间htyansp,当前的日志序列号是7。
步骤二、对数据库做一个全备份
点击(此处)折叠或打开
- [oracle@db2server ~]$ rman target /
- Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jul 31 00:09:04 2012
- Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
- connected to target database: HUATENG (DBID=2134565240)
- RMAN> backup database;
- Starting backup at 2012-07-31 00:09:14
- using target database control file instead of recovery catalog
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=36 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=00001 name=/u01/app/oracle/oradata/huateng/system01.dbf
- input datafile file number=00002 name=/u01/app/oracle/oradata/huateng/sysaux01.dbf
- input datafile file number=00005 name=/u01/app/oracle/oradata/huateng/example01.dbf
- input datafile file number=00003 name=/u01/app/oracle/oradata/huateng/undotbs01.dbf
- input datafile file number=00006 name=/u01/app/oracle/oradata/huateng/htyansp01.dbf
- input datafile file number=00004 name=/u01/app/oracle/oradata/huateng/users01.dbf
- channel ORA_DISK_1: starting piece 1 at 2012-07-31 00:09:16
- channel ORA_DISK_1: finished piece 1 at 2012-07-31 00:10:41
- piece handle=/u01/app/oracle/flash_recovery_area/HUATENG/backupset/2012_07_31/o1_mf_nnndf_TAG20120731T000915_81fdfg00_.bkp tag=TAG20120731T000915 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:01: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 2012-07-31 00:10:45
- channel ORA_DISK_1: finished piece 1 at 2012-07-31 00:10:46
- piece handle=/u01/app/oracle/flash_recovery_area/HUATENG/backupset/2012_07_31/o1_mf_ncsnf_TAG20120731T000915_81fdj56h_.bkp tag=TAG20120731T000915 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
- Finished backup at 2012-07-31 00:10:46
- RMAN>
步骤三、创建测试数据
点击(此处)折叠或打开
- SQL> archive log list
- Database log mode Archive Mode
- Automatic archival Enabled
- Archive destination /archivelog
- Oldest online log sequence 5
- Next log sequence to archive 7
- Current log sequence 7
- SQL> conn htyansp/htyansp
- Connected.
- SQL> create table test(seq varchar2(20));
- Table created.
- SQL> insert into test values('sequence 7');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- 当前的日志文件序列号是7,:因此上面的记录将会存放到日志序列号为7的归档日志中。
- SQL> insert into test values('sequence 8');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- SQL> insert into test values('sequence 9');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- SQL> insert into test values('sequence 10');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- SQL> insert into test values('sequence 11');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- SQL> select * from htyansp.test;
- SEQ
- --------------------
- sequence 7
- sequence 8
- sequence 9
- sequence 10
- sequence 11
每次插入一条记录切换一次日志,上面的记录每条记录存放到一个日志文件中。
点击(此处)折叠或打开
- SQL> conn / as sysdba
- Connected.
- SQL> archive log list
- Database log mode Archive Mode
- Automatic archival Enabled
- Archive destination /archivelog
- Oldest online log sequence 10
- Next log sequence to archive 12
- Current log sequence 12
- SQL>