1、创建测试表空间user02。这里我就不写创建语句了。
2、创建测试表
SQL>create table test (id number(5),name varchar2(5)) tablespace user02;
SQL>insert into test values(1,'jason');
SQL>commit;
3、sqlplus / as sysdba
SQL>alter system switch logfile;
4、rman target/
RMAN> backup database format '/oracle/databak/20110111/%U' plus archivelog format '/oracle/databak/20110111/%U' delete input;
RMAN>backup current controlfile format='/oracle/databak/20110111/%d.ctl' REUSE;
5、sqlplus / as sysdba
SQL>select * from test;
ID NAME
--------- -----
1 jason
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 58
Next log sequence to archive 60
Current log sequence 60
SQL>drop table test;
SQL>alter system switch logfile;
6、rman target/
RMAN> recover tablespace user02 until logseq 60 auxiliary destination '/oracle/auxi/';
Starting recover at 05-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time
List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1
Creating automatic instance, with SID='olqD'
initialization parameters used for automatic instance:
db_name=ORCL
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ORCL_olqD
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=/oracle/auxi/
control_files=/oracle/auxi//cntrl_tspitr_ORCL_olqD.f
starting up automatic instance ORCL
Oracle instance started
Total System Global Area 205520896 bytes
Fixed Size 1218508 bytes
Variable Size 146802740 bytes
Database Buffers 50331648 bytes
Redo Buffers 7168000 bytes
Automatic instance created
contents of Memory Script:
{
# set the until clause
set until logseq 60 thread 1;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause
Starting restore at 05-JAN-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=37 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /oracle/databak/20110111/16m1b65f_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/oracle/databak/20110111/16m1b65f_1_1 tag=TAG20110105T075902
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/oracle/auxi/cntrl_tspitr_ORCL_olqD.f
Finished restore at 05-JAN-11
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until logseq 60 thread 1;
plsql <<<-- tspitr_2
declare
sqlstatement varchar2(512);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
sqlstatement := 'alter tablespace '|| 'USER02' ||' offline for recover';
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement);
exception
when offline_not_needed then
null;
end; >>>;
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination tempfile
set newname for clone tempfile 1 to new;
# set a destination filename for restore
set newname for datafile 9 to
"/oracle/product/10.2.0/oradata/orcl/user02.dbf";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 9;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 9 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "USER02", "SYSTEM", "UNDOTBS1" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script
executing command: SET until clause
sql statement: alter tablespace USER02 offline for recover
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed temporary file 1 to /oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 05-JAN-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=39 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_system_%u_.dbf
restoring datafile 00002 to /oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_undotbs1_%u_.dbf
restoring datafile 00009 to /oracle/product/10.2.0/oradata/orcl/user02.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oracle/databak/20110111/15m1b626_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/oracle/databak/20110111/15m1b626_1_1 tag=TAG20110105T075902
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:37
Finished restore at 05-JAN-11
datafile 1 switched to datafile copy
input datafile copy recid=16 stamp=739613074 filename=/oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_system_6l7fch1l_.dbf
datafile 2 switched to datafile copy
input datafile copy recid=17 stamp=739613074 filename=/oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_undotbs1_6l7fch56_.dbf
sql statement: alter database datafile 1 online
sql statement: alter database datafile 2 online
sql statement: alter database datafile 9 online
Starting recover at 05-JAN-11
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=59
channel ORA_AUX_DISK_1: reading from backup piece /oracle/databak/20110111/17m1b65i_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/oracle/databak/20110111/17m1b65i_1_1 tag=TAG20110105T080050
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archive log filename=/oracle/product/10.2.0/db_1/dbs/arch1_59_738400851.dbf thread=1 sequence=59
channel clone_default: deleting archive log(s)
archive log filename=/oracle/product/10.2.0/db_1/dbs/arch1_59_738400851.dbf recid=58 stamp=739613077
media recovery complete, elapsed time: 00:00:01
Finished recover at 05-JAN-11
database opened
contents of Memory Script:
{
# export the tablespaces in the recovery set
host 'exp userid =\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/oracle/product/10.2.0/db_1/bin/oracle\)\(ARGV0=oracleolqD\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=olqD^'\)\)\(CONNECT_DATA=\(SID=olqD\)\)\) as sysdba\" point_in_time_recover=y tablespaces=
USER02 file=
tspitr_a.dmp';
# shutdown clone before import
shutdown clone immediate
# import the tablespaces in the recovery set
host 'imp userid =\"/@ as sysdba\" point_in_time_recover=y file=
tspitr_a.dmp';
# online/offline the tablespace imported
sql "alter tablespace USER02 online";
sql "alter tablespace USER02 offline";
# enable autobackups in case user does open resetlogs from RMAN after TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script
Export: Release 10.2.0.1.0 - Production on Wed Jan 5 08:04:48 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export Tablespace Point-in-time Recovery objects...
For tablespace USER02 ...
. exporting cluster definitions
. exporting table definitions
. . exporting table TEST
. . exporting table SALES
EXP-00091: Exporting questionable statistics.
. exporting referential integrity constraints
. exporting triggers
. end point-in-time recovery
Export terminated successfully with warnings.
host command complete
database closed
database dismounted
Oracle instance shut down
Import: Release 10.2.0.1.0 - Production on Wed Jan 5 08:05:00 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
About to import Tablespace Point-in-time Recovery objects...
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
. importing SYS's objects into SYS
. . importing table "TEST"
. importing SCOTT's objects into SCOTT
. . importing table "SALES"
. importing SYS's objects into SYS
Import terminated successfully without warnings.
host command complete
sql statement: alter tablespace USER02 online
sql statement: alter tablespace USER02 offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
Removing automatic instance
Automatic instance removed
auxiliary instance file /oracle/auxi/cntrl_tspitr_ORCL_olqD.f deleted
auxiliary instance file /oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_system_6l7fch1l_.dbf deleted
auxiliary instance file /oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_undotbs1_6l7fch56_.dbf deleted
auxiliary instance file /oracle/auxi/TSPITR_ORCL_OLQD/datafile/o1_mf_temp_6l7fdvko_.tmp deleted
auxiliary instance file /oracle/auxi/TSPITR_ORCL_OLQD/onlinelog/o1_mf_1_6l7fdr4r_.log deleted
auxiliary instance file /oracle/auxi/TSPITR_ORCL_OLQD/onlinelog/o1_mf_2_6l7fdrys_.log deleted
auxiliary instance file /oracle/auxi/TSPITR_ORCL_OLQD/onlinelog/o1_mf_3_6l7fdt05_.log deleted
Finished recover at 05-JAN-11
7、将表空间置于online
RMAN> sql 'alter tablespace user02 online';
测试:
SQL>selerct * from test;
ID NAME
--------- -----
1 jason
备份表空间user02。
RMAN> backup tablespace user02 format='/oracle/databak/20110111/%d_%s.dbf';
阅读(1827) | 评论(1) | 转发(0) |