Oracle基于RMAN的不完全恢复

基于SCN

[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:40:49 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd

SQL> insert into t_rec values(5,'eee');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@zwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 5 10:41:32 2013

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

connected to target database: ZWC (DBID=561451333)

RMAN> run{
2> allocate channel c1 device type disk;
3> backup full database format '/u01/backup/db_full_%u_%s_%p' tag 'fullbak'
4> include current controlfile;
5> sql 'alter system archive log current';
6> release channel c1;
7> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=40 device type=DISK

Starting backup at 05-FEB-2013 10:43:37
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/ZWC/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ZWC/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ZWC/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ZWC/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ZWC/users01.dbf
channel c1: starting piece 1 at 05-FEB-2013 10:43:37
channel c1: finished piece 1 at 05-FEB-2013 10:44:33
piece handle=/u01/backup/db_full_01o16uap_1_1 tag=FULLBAK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:56
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 05-FEB-2013 10:44:34
channel c1: finished piece 1 at 05-FEB-2013 10:44:35
piece handle=/u01/backup/db_full_02o16uch_2_1 tag=FULLBAK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-FEB-2013 10:44:35

sql statement: alter system archive log current

released channel: c1

RMAN> exit


Recovery Manager complete.
[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:49:39 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> insert into t_rec values(6,'fff');

1 row created.

SQL> commit;

Commit complete.

SQL> conn / as sysdba
Connected.
SQL> alter system switch logfile;

System altered.

SQL> select * from zhongwc.t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff

6 rows selected.

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3404460

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3404461

SQL> conn zhongwc/zhongwc
Connected.
SQL> drop table t_rec purge;

Table dropped.

SQL> show recyclebin;
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exir
SP2-0042: unknown command "exir" - rest of line ignored.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@zwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 5 10:52:53 2013

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

connected to target database (not started)

RMAN> startup mount;

Oracle instance started
database mounted

Total System Global Area    1653518336 bytes

Fixed Size                     2228904 bytes
Variable Size               1140854104 bytes
Database Buffers             503316480 bytes
Redo Buffers                   7118848 bytes

RMAN> run{
2> allocate channel c1 device type disk;
3> restore database;
4> recover database until scn 3404460;
5> sql 'alter database open resetlogs';
6> release channel c1;
7> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=18 device type=DISK

Starting restore at 05-FEB-2013 10:55:50

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/ZWC/system01.dbf
channel c1: restoring datafile 00002 to /u01/app/oracle/oradata/ZWC/sysaux01.dbf
channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/ZWC/undotbs01.dbf
channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/ZWC/users01.dbf
channel c1: restoring datafile 00005 to /u01/app/oracle/oradata/ZWC/example01.dbf
channel c1: reading from backup piece /u01/backup/db_full_01o16uap_1_1
channel c1: piece handle=/u01/backup/db_full_01o16uap_1_1 tag=FULLBAK
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:55
Finished restore at 05-FEB-2013 10:56:45

Starting recover at 05-FEB-2013 10:56:46

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

Finished recover at 05-FEB-2013 10:56:48

sql statement: alter database open resetlogs

released channel: c1

RMAN> exit


Recovery Manager complete.
[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:57:28 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff

6 rows selected.

基于log seq

[oracle@zwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 5 13:57:53 2013

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

connected to target database: ZWC (DBID=561451333)

run{
allocate channel c1 device type disk;
backup full database format '/u01/backup/db_full_%U' tag 'fullbak2'
include current controlfile;
sql 'alter system archive log current';
release channel c1;
4> 5> 6> 7> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=18 device type=DISK

Starting backup at 05-FEB-2013 13:58:12
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/ZWC/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ZWC/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ZWC/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ZWC/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ZWC/users01.dbf
channel c1: starting piece 1 at 05-FEB-2013 13:58:13
channel c1: finished piece 1 at 05-FEB-2013 13:59:08
piece handle=/u01/backup/db_full_03o179nl_1_1 tag=FULLBAK2 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:55
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 05-FEB-2013 13:59:09
channel c1: finished piece 1 at 05-FEB-2013 13:59:10
piece handle=/u01/backup/db_full_04o179pc_1_1 tag=FULLBAK2 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-FEB-2013 13:59:11

sql statement: alter system archive log current

released channel: c1

RMAN> exit


Recovery Manager complete.
[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 14:00:07 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show user
USER is "ZHONGWC"
SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff

6 rows selected.

SQL> archive log list
ORA-01031: insufficient privileges
SQL> conn / as sysdba
Connected.
SQL> archive log list
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /u01/app/oracle/oradata/ZWC/arch
Oldest online log sequence     4
Next log sequence to archive   6
Current log sequence	       6
SQL> insert into zhongwc.t_rec values(7,'ggg');

1 row created.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /u01/app/oracle/oradata/ZWC/arch
Oldest online log sequence     5
Next log sequence to archive   7
Current log sequence	       7
SQL> insert into zhongwc.t_rec values(8,'hhh');

1 row created.

SQL> commit
  2  ;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /u01/app/oracle/oradata/ZWC/arch
Oldest online log sequence     6
Next log sequence to archive   8
Current log sequence	       8
SQL> select * from zhongwc.t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff
	 7 ggg
	 8 hhh

8 rows selected.

SQL> set linesize v$log;
SP2-0268: linesize option not a valid number
SQL> set linesize 300
SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE	  MEMBERS ARC STATUS	       FIRST_CHANGE# FIRST_TIME 	     NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------------------- ------------ -----------------------
	 1	    1	       7   52428800	   512		1 YES ACTIVE		     3409862 05-FEB-2013 14:00:59	  3409878 05-FEB-2013 14:01:19
	 2	    1	       8   52428800	   512		1 NO  CURRENT		     3409878 05-FEB-2013 14:01:19      2.8147E+14
	 3	    1	       6   52428800	   512		1 YES ACTIVE		     3409682 05-FEB-2013 13:59:11	  3409862 05-FEB-2013 14:00:59

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@zwc ~]$ conn / as sysdba
-bash: conn: command not found
[oracle@zwc ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 14:06:02 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@zwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 5 14:06:17 2013

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

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area    1653518336 bytes

Fixed Size                     2228904 bytes
Variable Size               1140854104 bytes
Database Buffers             503316480 bytes
Redo Buffers                   7118848 bytes

RMAN> run{
2> allocate channel c1 device type disk;
3> set until logseq 6 thread 1;
4> restore database;
5> recover database;
6> sql 'alter database open resetlogs';
7> release channel c1;
8> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=18 device type=DISK

executing command: SET until clause

Starting restore at 05-FEB-2013 14:08:40

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/ZWC/system01.dbf
channel c1: restoring datafile 00002 to /u01/app/oracle/oradata/ZWC/sysaux01.dbf
channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/ZWC/undotbs01.dbf
channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/ZWC/users01.dbf
channel c1: restoring datafile 00005 to /u01/app/oracle/oradata/ZWC/example01.dbf
channel c1: reading from backup piece /u01/backup/db_full_03o179nl_1_1
channel c1: piece handle=/u01/backup/db_full_03o179nl_1_1 tag=FULLBAK2
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:55
Finished restore at 05-FEB-2013 14:09:36

Starting recover at 05-FEB-2013 14:09:36

starting media recovery

archived log for thread 1 with sequence 5 is already on disk as file /u01/app/oracle/oradata/ZWC/arch/1_5_806583408.dbf
archived log file name=/u01/app/oracle/oradata/ZWC/arch/1_5_806583408.dbf thread=1 sequence=5
media recovery complete, elapsed time: 00:00:00
Finished recover at 05-FEB-2013 14:09:37

sql statement: alter database open resetlogs

released channel: c1

RMAN> exit


Recovery Manager complete.
[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 14:10:02 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff

6 rows selected.

基于time

[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 14:13:38 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff

6 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@zwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 5 14:13:43 2013

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

connected to target database: ZWC (DBID=561451333)

run{
allocate channel c1 device type disk;
backup full database format '/u01/backup/db_full_%U' tag 'fullbak3'
include current controlfile;
sql 'alter system archive log current';
release channel c1;
7> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=36 device type=DISK

Starting backup at 05-FEB-2013 14:13:52
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/ZWC/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ZWC/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ZWC/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ZWC/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ZWC/users01.dbf
channel c1: starting piece 1 at 05-FEB-2013 14:13:52
channel c1: finished piece 1 at 05-FEB-2013 14:14:57
piece handle=/u01/backup/db_full_05o17al0_1_1 tag=FULLBAK3 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:05
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 05-FEB-2013 14:14:58
channel c1: finished piece 1 at 05-FEB-2013 14:14:59
piece handle=/u01/backup/db_full_06o17an1_1_1 tag=FULLBAK3 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-FEB-2013 14:14:59

sql statement: alter system archive log current

released channel: c1

RMAN> exit


Recovery Manager complete.
[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 14:15:12 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> insert into t_rec values(7,'ggg');

1 row created.

SQL> commit;

Commit complete.

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> select sysdate from dual;

SYSDATE
-------------------
2013-02-05 14:16:33

SQL> insert into t_rec values(8,'hhh');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff
	 7 ggg
	 8 hhh

8 rows selected.

SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@zwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 5 14:19:44 2013

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

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area    1653518336 bytes

Fixed Size                     2228904 bytes
Variable Size               1140854104 bytes
Database Buffers             503316480 bytes
Redo Buffers                   7118848 bytes

RMAN> run{
2> allocate channel c1 device type disk;
3> restore database;
4> recover database until time "to_date('2013-02-05 14:16:33','yyyy-mm-dd hh24:mi:ss')";
5> sql 'alter database open resetlogs';
6> release channel c1;
7> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=18 device type=DISK

Starting restore at 05-FEB-2013 14:22:08

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/ZWC/system01.dbf
channel c1: restoring datafile 00002 to /u01/app/oracle/oradata/ZWC/sysaux01.dbf
channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/ZWC/undotbs01.dbf
channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/ZWC/users01.dbf
channel c1: restoring datafile 00005 to /u01/app/oracle/oradata/ZWC/example01.dbf
channel c1: reading from backup piece /u01/backup/db_full_05o17al0_1_1
channel c1: piece handle=/u01/backup/db_full_05o17al0_1_1 tag=FULLBAK3
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:54
Finished restore at 05-FEB-2013 14:23:02

Starting recover at 05-FEB-2013 14:23:02

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

Finished recover at 05-FEB-2013 14:23:03

sql statement: alter database open resetlogs

released channel: c1

RMAN> exit


Recovery Manager complete.
[oracle@zwc ~]$ sqlplus zhongwc/zhongwc

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 14:23:19 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from t_rec;

	ID NAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc
	 4 ddd
	 5 eee
	 6 fff
	 7 ggg

7 rows selected.


你可能感兴趣的:(Oracle)