备份与恢复:用rman方式基于日志序列的不完全恢复

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:45

备份与恢复:用rman方式基于日志序列的不完全恢复

RMAN> run{
2> allocate channel c1 type disk;
3> backup full tag 'dbfull' format 'd:\backup\full%u_%s_%p' database
4> include current controlfile;
5> sql 'alter system archive log current';
6> release channel c1;
7> }
sql> insert into test values (16);
commit;
sql>alter system switch logfile;
sql> insert into test values (17);
commit;
sql>alter system switch logfile;
SQL> select * from test;
A
----------
1
2
3
4
5
6
7
8
9
10
11
A
----------
12
13
14 --这之前数据是14号日志前产生的
16
17 --这之后数据是14号日志后产生的
16 rows selected.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination D:\oracle\ora92\RDBMS
Oldest online log sequence 14
Next log sequence to archive 16
Current log sequence 16

SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- -------------------
1 1 16 104857600 1 YES ACTIVE
84134 2008-04-10 11:39:19
2 1 17 104857600 1 NO CURRENT
84150 2008-04-10 11:40:00
3 1 15 104857600 1 YES ACTIVE
84128 2008-04-10 11:39:10

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
RMAN> shutdown immediate;
using target database controlfile instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 101785252 bytes
Fixed Size 454308 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
RMAN> alter database mount;
database mounted
RMAN> run{
2> allocate channel c1 type disk;
3> set until logseq 14 thread 1; --基于日志序列号的不完全恢复
4> restore database;
5> recover database;
6> sql 'alter database open resetlogs';
7> }
allocated channel: c1
channel c1: sid=11 devtype=DISK
executing command: SET until clause
Starting restore at 2008-04-10 11:50:05
datafile 4 not processed because file is read-only
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to D:\ORACLE\ORADATA\PUBTEST\SYSTEM01.DBF
restoring datafile 00002 to D:\ORACLE\ORADATA\PUBTEST\UNDOTBS01.DBF
restoring datafile 00003 to D:\ORACLE\ORADATA\PUBTEST\INDX01.DBF
restoring datafile 00005 to D:\ORACLE\ORADATA\PUBTEST\USERS01.DBF
channel c1: restored backup piece 1
piece handle=D:\ORACLE\ORA92\DATABASE\04JDFCP3_1_1 tag=TAG20080410T113100 params
=NULL
channel c1: restore complete
Finished restore at 2008-04-10 11:50:42
Starting recover at 2008-04-10 11:50:42
datafile 4 not processed because file is read-only
starting media recovery
archive log thread 1 sequence 9 is already on disk as file D:\ORACLE\ORA92\RDBMS
\ARC00009.001
archive log thread 1 sequence 10 is already on disk as file D:\ORACLE\ORA92\RDBM
S\ARC00010.001
archive log thread 1 sequence 11 is already on disk as file D:\ORACLE\ORA92\RDBM
S\ARC00011.001
archive log thread 1 sequence 12 is already on disk as file D:\ORACLE\ORA92\RDBM
S\ARC00012.001
archive log thread 1 sequence 13 is already on disk as file D:\ORACLE\ORA92\RDBM
S\ARC00013.001
archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00009.001 thread=1 sequence=9
archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00010.001 thread=1 sequence=10
archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00011.001 thread=1 sequence=11
archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00012.001 thread=1 sequence=12
archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00013.001 thread=1 sequence=13
media recovery complete
Finished recover at 2008-04-10 11:50:43
sql statement: alter database open resetlogs
released channel: c1
RMAN> exit

Recovery Manager complete.
C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Thu Apr 10 11:52:12 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> select * from test;
A
----------
1
2
3
4
5
6
7
8
9
10
11
A
----------
12
13
14
14 rows selected.
SQL>
看结果只恢复到14号日志前的数据

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】