7 恢复控制文件
RMAN> list backup of controlfile;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
24 Incr 0 9.67M DISK 00:00:04 2014-02-09 18:31:19
BP Key: 24 Status: AVAILABLE Compressed: NO Tag: TAG20140209T182835
Piece Name: /backup/crm/full-20140209-0op076nj_1_1.bak
Control File Included: Ckp SCN: 3891837 Ckp time: 2014-02-09 18:31:15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
34 Full 9.64M DISK 00:00:02 2014-02-09 18:31:38
BP Key: 34 Status: AVAILABLE Compressed: NO Tag: TAG20140209T183136
Piece Name: /backup/crm/ctl-20140209-12p076o8_1_1.bak
Control File Included: Ckp SCN: 3891864 Ckp time: 2014-02-09 18:31:36
RMAN> list backup of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
23 Incr 0 2.04G DISK 00:02:29 2014-02-09 18:31:05
BP Key: 23 Status: AVAILABLE Compressed: NO Tag: TAG20140209T182835
Piece Name: /backup/crm/full-20140209-0np076ik_1_1.bak
List of Datafiles in backup set 23
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 0 Incr 3891775 2014-02-09 18:28:36 /Oracle/CRM/CRM/system01.dbf
2 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/sysaux01.dbf
3 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/undotbs01.dbf
4 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/users01.dbf
5 0 Incr 3891775 2014-02-09 18:28:36
6 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/pos.dbf
7 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/user01.dbf
8 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/erp.dbf
9 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/undotbs03.dbf
12 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/crm.dbf
RMAN> startup force nomount;
Oracle instance started
Total System Global Area 952020992 bytes
Fixed Size 2232208 bytes
Variable Size 633340016 bytes
Database Buffers 310378496 bytes
Redo Buffers 6070272 bytes
RMAN> restore controlfile to '/oracle/CRM/CRM/control01.ctl' from '/backup/crm/ctl-20140209-12p076o8_1_1.bak';
Starting restore at 2014-02-09 18:56:10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2014-02-09 18:56:13
RMAN> exit
Recovery Manager complete.
[oracle@dest bak]$ cd /oracle/CRM/CRM
[oracle@dest CRM]$ ls -lt
total 3325464
-rw-r----- 1 oracle oinstall 10076160 Feb 9 18:56 control01.ctl
-rw-r----- 1 oracle oinstall 10076160 Feb 9 18:53 control02.ctl
-rw-r----- 1 oracle oinstall 555753472 Feb 9 18:42 sysaux01.dbf
-rw-r----- 1 oracle oinstall 828383232 Feb 9 18:42 system01.dbf
-rw-r----- 1 oracle oinstall 115351552 Feb 9 18:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 1251745792 Feb 9 18:42 users01.dbf
-rw-r----- 1 oracle oinstall 209715712 Feb 9 18:38 redo01.log
-rw-r----- 1 oracle oinstall 209715712 Feb 9 18:35 redo03.log
-rw-r----- 1 oracle oinstall 209715712 Feb 9 18:34 redo02.log
-rw-r----- 1 oracle oinstall 30416896 Feb 9 15:00 temp01.dbf
[oracle@dest CRM]$ cp control01.ctl control02.ctl
[oracle@dest CRM]$ ls
control01.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
control02.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
[oracle@dest CRM]$ rman target /
Recovery Manager: Release 11.2.0.2.0 - Production on Sun Feb 9 18:57:57 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: CRM (not mounted)
RMAN> alter database mount;
using target database control file instead of recovery catalog
database mounted
RMAN> list backup of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
23 Incr 0 2.04G DISK 00:02:29 2014-02-09 18:31:05
BP Key: 23 Status: AVAILABLE Compressed: NO Tag: TAG20140209T182835
Piece Name: /backup/crm/full-20140209-0np076ik_1_1.bak
List of Datafiles in backup set 23
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/system01.dbf
2 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/sysaux01.dbf
3 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/undotbs01.dbf
4 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/CRM/users01.dbf
5 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/jxc.dbf
6 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/pos.dbf
7 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/user01.dbf
8 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/erp.dbf
9 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/undotbs03.dbf
12 0 Incr 3891775 2014-02-09 18:28:36 /oracle/CRM/crm.dbf
8 执行基于数据库的时间点恢复回退整个数据库至2014-02-09 18:35:05
RMAN> run{
2> set until time "to_date('2014-02-09 18:35:05','YYYY-MM-DD HH24:MI:SS')";
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 2014-02-09 18:59:02
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
skipping datafile 6; already restored to file /oracle/CRM/pos.dbf
skipping datafile 7; already restored to file /oracle/CRM/user01.dbf
skipping datafile 8; already restored to file /oracle/CRM/erp.dbf
skipping datafile 9; already restored to file /oracle/CRM/undotbs03.dbf
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 /oracle/CRM/CRM/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oracle/CRM/CRM/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oracle/CRM/CRM/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oracle/CRM/CRM/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /oracle/CRM/jxc.dbf
channel ORA_DISK_1: restoring datafile 00012 to /oracle/CRM/crm.dbf
channel ORA_DISK_1: reading from backup piece /backup/crm/full-20140209-0np076ik_1_1.bak
channel ORA_DISK_1: piece handle=/backup/crm/full-20140209-0np076ik_1_1.bak tag=TAG20140209T182835
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:28
Finished restore at 2014-02-09 19:01:32
Starting recover at 2014-02-09 19:01:33
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 4 is already on disk as file /oracle/archivelog/arch_1_4_839094460.arch
archived log for thread 1 with sequence 5 is already on disk as file /oracle/CRM/CRM/redo02.log
archived log for thread 1 with sequence 6 is already on disk as file /oracle/CRM/CRM/redo03.log
archived log file name=/oracle/archivelog/arch_1_4_839094460.arch thread=1 sequence=4
archived log file name=/oracle/CRM/CRM/redo02.log thread=1 sequence=5
archived log file name=/oracle/CRM/CRM/redo03.log thread=1 sequence=6
media recovery complete, elapsed time: 00:00:04
Finished recover at 2014-02-09 19:01:46
RMAN> report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 790 SYSTEM *** /oracle/CRM/CRM/system01.dbf
2 530 SYSAUX *** /oracle/CRM/CRM/sysaux01.dbf
3 110 UNDOTBS1 *** /oracle/CRM/CRM/undotbs01.dbf
4 1193 USERS *** /oracle/CRM/CRM/users01.dbf
5 10 JXC *** /oracle/CRM/jxc.dbf
6 100 POS *** /oracle/CRM/pos.dbf
7 5 USER01 *** /oracle/CRM/user01.dbf
8 100 ERP *** /oracle/CRM/erp.dbf
9 100 UNDOTBS3 *** /oracle/CRM/undotbs03.dbf
12 10 CRM *** /oracle/CRM/crm.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 29 /oracle/CRM/CRM/temp01.dbf
RMAN> exit
9 以resetlogs方式打开数据库
[oracle@dest CRM]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sun Feb 9 19:02:10 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database open resetlogs;
Database altered.
10 验证数据是否恢复
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
JXC ONLINE
POS ONLINE
USER01 ONLINE
ERP ONLINE
UNDOTBS3 ONLINE
CRM ONLINE
11 rows selected.
SQL> col file_name for a50
SQL> set linesize 400
SQL> select file_name,tablespace_name,status from dba_data_files;
FILE_NAME TABLESPACE_NAME STATUS
---------------------------------- ------------------------------ ---------
/oracle/CRM/crm.dbf CRM AVAILABLE
/oracle/CRM/undotbs03.dbf UNDOTBS3 AVAILABLE
/oracle/CRM/erp.dbf ERP AVAILABLE
/oracle/CRM/user01.dbf USER01 AVAILABLE
/oracle/CRM/pos.dbf POS AVAILABLE
/oracle/CRM/CRM/users01.dbf USERS AVAILABLE
/oracle/CRM/CRM/undotbs01.dbf UNDOTBS1 AVAILABLE
/oracle/CRM/CRM/sysaux01.dbf SYSAUX AVAILABLE
/oracle/CRM/CRM/system01.dbf SYSTEM AVAILABLE
/oracle/CRM/jxc.dbf JXC AVAILABLE
10 rows selected.
SQL> select * from zx.test1;
I
----------
1
2
3
4
5
6
7
8
9
10
11
I
----------
12
13
14
15
16
17
18
19
20
20 rows selected.
