RMAN> run{
2> set until sequence 57 thread 1;
3> set newname for datafile 1 to '/oradata/racdb/system01.dbf';
4> set newname for datafile 2 to '/oradata/racdb/undotbs01.dbf';
5> set newname for datafile 3 to '/oradata/racdb/sysaux01.dbf';
6> set newname for datafile 4 to '/oradata/racdb/users01.dbf';
7> set newname for datafile 5 to '/oradata/racdb/undotbs02.dbf';
8> restore database;
9> switch datafile all;
10> }
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 02-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/racdb/system01.dbf
restoring datafile 00004 to /oradata/racdb/users01.dbf
restoring datafile 00005 to /oradata/racdb/undotbs02.dbf
channel ORA_DISK_1: reading from backup piece /rmanset/racdb_full_RACDB669769770931
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/racdb_full_RACDB669769770931 tag=FULLBACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /oradata/racdb/undotbs01.dbf
restoring datafile 00003 to /oradata/racdb/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /rmanset/racdb_full_RACDB669769784941
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/racdb_full_RACDB669769784941 tag=FULLBACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 02-NOV-08
datafile 1 switched to datafile copy
input datafile copy recid=10 stamp=669738296 filename=/oradata/racdb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=11 stamp=669738296 filename=/oradata/racdb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=12 stamp=669738296 filename=/oradata/racdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=13 stamp=669738297 filename=/oradata/racdb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=14 stamp=669738297 filename=/oradata/racdb/undotbs02.dbf
RMAN>
--列出备份的archivelog:
RMAN> list backup of archivelog all;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
89 2.44M DISK 00:00:03 02-NOV-08
BP Key: 89 Status: AVAILABLE Compressed: NO Tag: TAG20081102T231211
Piece Name: /rmanset/RACDB_arch_98_1_2
List of Archived Logs in backup set 89
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 53 356353 02-NOV-08 396535 02-NOV-08
1 54 396535 02-NOV-08 398232 02-NOV-08
2 44 350717 02-NOV-08 356350 02-NOV-08
2 45 356350 02-NOV-08 376487 02-NOV-08
2 46 376487 02-NOV-08 396536 02-NOV-08
2 47 396536 02-NOV-08 397820 02-NOV-08
2 48 397820 02-NOV-08 398228 02-NOV-08
2 49 398228 02-NOV-08 398963 02-NOV-08
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
90 17.42M DISK 00:00:07 02-NOV-08
BP Key: 90 Status: AVAILABLE Compressed: NO Tag: TAG20081102T231211
Piece Name: /rmanset/RACDB_arch_97_1_1
List of Archived Logs in backup set 90
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 42 285767 01-NOV-08 285925 01-NOV-08
1 44 286441 01-NOV-08 286516 01-NOV-08
1 45 286516 01-NOV-08 308174 01-NOV-08
1 46 308174 01-NOV-08 312441 01-NOV-08
1 47 312441 01-NOV-08 324657 02-NOV-08
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
91 9.69M DISK 00:00:04 02-NOV-08
BP Key: 91 Status: AVAILABLE Compressed: NO Tag: TAG20081102T231211
Piece Name: /rmanset/RACDB_arch_99_1_1
List of Archived Logs in backup set 91
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 48 324657 02-NOV-08 324727 02-NOV-08
1 49 324727 02-NOV-08 325613 02-NOV-08
1 50 325613 02-NOV-08 349040 02-NOV-08
1 51 349040 02-NOV-08 350714 02-NOV-08
1 52 350714 02-NOV-08 356353 02-NOV-08
1 55 398232 02-NOV-08 398433 02-NOV-08
1 56 398433 02-NOV-08 398960 02-NOV-08
--restore archivelog and recover database.
RMAN>
RMAN> run{
2> set archivelog destination to '/racdb_arch';
3> restore archivelog from sequence 49 thread 2;
}4>
executing command: SET ARCHIVELOG DESTINATION
Starting restore at 02-NOV-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log restore to user-specified destination
archive log destination=/racdb_arch
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=49
channel ORA_DISK_1: reading from backup piece /rmanset/RACDB_arch_98_1_2
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/RACDB_arch_98_1_2 tag=TAG20081102T231211
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 02-NOV-08
RMAN>
RMAN>
RMAN> run{
2> set archivelog destination to '/racdb_arch';
3> restore archivelog from sequence 44 thread 2;
4> }
executing command: SET ARCHIVELOG DESTINATION
Starting restore at 02-NOV-08
using channel ORA_DISK_1
archive log thread 2 sequence 49 is already on disk as file /racdb_arch/2_49_669487401.dbf
channel ORA_DISK_1: starting archive log restore to user-specified destination
archive log destination=/racdb_arch
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=44
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=45
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=46
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=47
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=48
channel ORA_DISK_1: reading from backup piece /rmanset/RACDB_arch_98_1_2
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/RACDB_arch_98_1_2 tag=TAG20081102T231211
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 02-NOV-08
RMAN> run{
2> set until sequence 57 thread 1;
3> recover database;
4> }
executing command: SET until clause
Starting recover at 02-NOV-08
using channel ORA_DISK_1
starting media recovery
archive log thread 2 sequence 49 is already on disk as file /racdb_arch/2_49_669487401.dbf
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=56
channel ORA_DISK_1: reading from backup piece /rmanset/RACDB_arch_99_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/RACDB_arch_99_1_1 tag=TAG20081102T231211
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/racdb_arch/1_56_669487401.dbf thread=1 sequence=56
archive log filename=/racdb_arch/2_49_669487401.dbf thread=2 sequence=49
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-NOV-08
--对redo 作修改:
alter database rename file '+RACDATA/racdb/onlinelog/group_1.257.669487411' to '/oradata/racdb/redo1';
alter database rename file '+RACDATA/racdb/onlinelog/group_2.258.669487419' to '/oradata/racdb/redo2';
alter database rename file '+RACDATA/racdb/onlinelog/group_3.265.669489319' to '/oradata/racdb/redo3';
alter database rename file '+RACDATA/racdb/onlinelog/group_4.266.669489327' to '/oradata/racdb/redo4';
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+RACDATA/racdb/onlinelog/group_1.257.669487411
+RACDATA/racdb/onlinelog/group_2.258.669487419
+RACDATA/racdb/onlinelog/group_3.265.669489319
+RACDATA/racdb/onlinelog/group_4.266.669489327
SQL> alter database rename file '+RACDATA/racdb/onlinelog/group_1.257.669487411' to '/oradata/racdb/redo1';
Database altered.
SQL> alter database rename file '+RACDATA/racdb/onlinelog/group_2.258.669487419' to '/oradata/racdb/redo2';
alter database rename file '+RACDATA/racdb/onlinelog/group_3.265.669489319' to '/oradata/racdb/redo3';
alter database rename file '+RACDATA/racdb/onlinelog/group_4.266.669489327' to '/oradata/racdb/redo4';
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL> alter database open resetlogs;
Database altered.
SQL>
SQL>
SQL>
SQL> select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PUBLIC
SQL>
SQL> select group# from v$log where THREAD#=2;
GROUP#
----------
3
4
SQL> alter database disable thread 2;
Database altered.
SQL> alter database drop logfile group 4;
alter database drop logfile group 4
*
ERROR at line 1:
ORA-00350: log 4 of instance racdb2 (thread 2) needs to be archived
ORA-00312: online log 4 thread 2: '/oradata/racdb/redo4'
SQL> alter database clear unarchived logfile group 3;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database drop logfile group 4;
alter database drop logfile group 4
*
ERROR at line 1:
ORA-00350: log 4 of instance racdb2 (thread 2) needs to be archived
ORA-00312: online log 4 thread 2: '/oradata/racdb/redo4'
SQL> alter database clear unarchived logfile group 4;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.
SQL> select group#,member from v$logfile;
GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
1
/oradata/racdb/redo1
2
/oradata/racdb/redo2
SQL> select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
对undo 的处理:
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
UNDOTBS2
SQL> drop tablespace UNDOTBS2 including contents and datafiles;
Tablespace dropped.
SQL> select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
SQL>
对temp的处理:
create temporary tablespace TEMP1 tempfile '/oradata/racdb/temp01.dbf' size 50M autoextend off;
SQL> select name from v$tempfile;
NAME
---------------------------------------------------------------------------------------------------------------------------------------------
/oradata/racdb/RACDB/datafile/o1_mf_temp_4jtl9yfl_.tmp
SQL>
SQL>
SQL> select tablespace_name from dba_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME
------------------------------
TEMP
SQL> create temporary tablespace TEMP1
2 tempfile '/oradata/racdb/temp01.dbf'
3 size 50M autoextend off;
Tablespace created.
SQL> alter database default temporary tablespace TEMP1;
Database altered.
SQL> drop tablespace TEMP including contents and datafiles;
Tablespace dropped.
SQL>
再配上tnsnames.ora 及 listener.ora
#####参考metalink Note:415579.1