Automatic TSPITR in 10G RMAN -A walk Through (Doc ID 335851.1)
Automatic TSPITR in 10G RMAN -A walk Through (Doc ID 335851.1)
Applies to:
Oracle Database - Enterprise Edition - Version 10.1.0.2 to 10.2.0.1 [Release 10.1 to 10.2]
Information in this document applies to any platform.
***Checked for relevance on 16-Apr-2014***
Purpose
This Article contains an example of Automated TSPITR in 10G using RMAN
Scope
RMAN automatic Tablespace Point-In-Time Recovery (TSPITR) enables you to quickly recover one or more tablespaces in an Oracle database to an earlier time, without affecting the state of the rest of the tablespaces and other objects in the database.
Details
When performing fully automated TSPITR, letting RMAN manage the entire process. There are only two requirements which we need to specify manually.
1. Auxiliary destination for RMAN to use for the auxiliary set datafiles and other files for the auxiliary instance.
2. Configure any channels required for the TSPITR on the target instance.
Note: The auxiliary instance will use the same channel configuration as the target instance when performing the TSPITR.
3. Use TS_PITR_CHECK view for identifying and resolving dependencies within the recovery set tablespaces.
Refer to:
https://docs.oracle.com/cd/B19306_01/backup.102/b14191/rcmtspit.htm#i1015064
Case Studies
The following case studies give the audience detailed steps in building a test environment and in practicing the procedure.
Setting up the environment:
1. Created a tablespace test and a table in that tablespace
SQL> CREATE TABLE TEST001 (id number) TABLESPACE TEST;
SQL> INSERT INTO TEST001 VALUES(100);
1 row created.
SQL> COMMIT;
SQL> SELECT * FROM TEST001;
ID
----------
100
2. Checked the CURRENT LOG Sequence
SEQUENCE#
----------
135
Sequence# 135 is my current log sequence3. Take a backup of the database and current controlfile using RMAN.
4. Do a few log switches and drop the table.
SQL> SELECT SEQUENCE# FROM V$LOG
WHERE STATUS='CURRENT';
SEQUENCE
----------
139
Table was dropped in log sequence 139. So TSPITR until log sequence 138 will give the table back.
Note: UNTIL TIME TSPITR syntax is :
True test starts
1. Connect to RMAN
2. Now run TSPITR until log sequence 138. Auxiliary destination is D:\Backup\temp.
Starting recover at 20-SEP-05
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=26 devtype=DISK
Creating automatic instance, with SID='ljsA'
initialization parameters used for automatic instance:
db_name=AMAR
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_AMAR_ljsA
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=D:\BAckup\temp
control_files=D:\BAckup\temp/cntrl_tspitr_AMAR_ljsA.f
starting up automatic instance AMAR
Oracle instance started
Total System Global Area 201326592 bytes
Fixed Size 1247044 bytes
Variable Size 146802876 bytes
Database Buffers 50331648 bytes
Redo Buffers 2945024 bytes
Automatic instance created
contents of Memory Script:
{
# set the until clause
set until logseq 138 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;';
# resync catalog after controlfile restore
resync catalog;
}
executing Memory Script
executing command: SET until clause
Starting restore at 20-SEP-05
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 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
+DATA/amar/backupset/2005_09_20/ncnnf0_tag20050920t105610_0.291.569501773
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=+DATA/amar/backupset/2005_09_20/ncnnf0_tag20050920t105610_0.291.569501773
tag=TAG20050920T105610
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
output filename=D:\BACKUP\TEMP\CNTRL_TSPITR_AMAR_LJSA.F
Finished restore at 20-SEP-05
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
starting full resync of recovery catalog
full resync complete
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 138 thread 1;
plsql
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
sqlstatement := 'alter tablespace '|| 'TEST' ||' 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 6 to
"D:\BACKUP\TEST.DBF";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 6;
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 6 online";
# make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TEST", "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 TEST offline for recover executing command:
SET NEWNAME executing command:
SET NEWNAME executing command:
SET NEWNAME executing command:
SET NEWNAME renamed temporary file 1 to D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_TEMP_%U_.TMP in control file
Starting restore at 20-SEP-05 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 D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_SYSTEM_%U_.DBF
restoring datafile 00002 to D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_UNDOTBS1_%U_.DBF
restoring datafile 00006 to D:\BACKUP\TEST.DBF channel ORA_AUX_DISK_1:
reading from backup piece +DATA/amar/backupset/2005_09_20/nnndf0_tag20050920t105434_0.295.569501677 channel ORA_AUX_DISK_1:
restored backup piece 1 piece handle=+DATA/amar/backupset/2005_09_20/nnndf0_tag20050920t105434_0.295.569501677 tag=TAG20050920T105434 channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:01:06
Finished restore at 20-SEP-05
datafile 1 switched to datafile copy input datafile copy recid=4 stamp=569503256 filename=D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_SYSTEM_1LZ8QZF1_.DBF
datafile 2 switched to datafile copy input datafile copy recid=5 stamp=569503256 filename=D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_UNDOTBS1_1LZ8QZN7_.DBF
sql statement:
alter database datafile 1 online sql statement:
alter database datafile 2 online sql statement:
alter database datafile 6 online
Starting recover at 20-SEP-05 using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 134 is already on disk as file +DATA/amar/archivelog/2005_09_20/thread_1_seq_134.292.569501807
archive log thread 1 sequence 135 is already on disk as file +DATA/amar/archivelog/2005_09_20/thread_1_seq_135.280.569501919
archive log thread 1 sequence 136 is already on disk as file +DATA/amar/archivelog/2005_09_20/thread_1_seq_136.283.569501925
archive log thread 1 sequence 137 is already on disk as file +DATA/amar/archivelog/2005_09_20/thread_1_seq_137.297.569501931 archive log filename=+DATA/amar/archivelog/2005_09_20/thread_1_seq_134.292.569501807 thread=1 sequence=134
archive log filename=+DATA/amar/archivelog/2005_09_20/thread_1_seq_135.280.569501919 thread=1 sequence=135
archive log filename=+DATA/amar/archivelog/2005_09_20/thread_1_seq_136.283.569501925 thread=1 sequence=136
archive log filename=+DATA/amar/archivelog/2005_09_20/thread_1_seq_137.297.569501931 thread=1 sequence=137
media recovery complete, elapsed time: 00:00:06
Finished recover at 20-SEP-05
database opened contents of Memory Script:
{
# export the tablespaces in the recovery set host 'exp userid =\"/@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=oracle)(ARGV0=oracleljsA)(ARGS=^'(DESCRIPTION=(LO AL=YES)(ADDRESS=(PROTOCOL=beq)))^')(ENVS=^'ORACLE_SID=ljsA^'))(CONNECT_DATA=(SID=ljsA))) as sysdba\" point_in_time_recover=y tablespaces= TEST 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 TEST online"; sql "alter tablespace TEST offline";
# enable autobackups in case user does open resetlogs from RMAN after TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
# resync catalog after tspitr finished resync catalog;
}
executing Memory Script Export: Release 10.2.0.1.0 - Production on Tue Sep 20 11:21:40 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc tion With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character
set server uses AL32UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export Tablespace Point-in-time Recovery objects...
For tablespace TEST ... .
exporting cluster definitions .
exporting table definitions . .
exporting table TEST001 .
exporting referential integrity constraints .
exporting triggers .
end point-in-time recovery
Export terminated successfully without warnings.
host command complete
database closed
database dismounted
Oracle instance shut down
Import: Release 10.2.0.1.0 - Production on Tue Sep 20 11:22:17 2005
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 WE8MSWIN1252 character set and AL16UTF16 NCHAR character
set import server uses AL32UTF8 character set (possible charset conversion) .
importing SYS's objects into SYS . .
importing table "TEST001"
Import terminated successfully without warnings.
host command complete
sql statement: alter tablespace TEST online
sql statement: alter tablespace TEST offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
starting full resync of recovery catalog full resync complete
Removing automatic instance
Automatic instance removed
auxiliary instance file D:\BACKUP\TEMP\CNTRL_TSPITR_AMAR_LJSA.F deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_SYSTEM_1LZ8QZF1_.DBF deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_UNDOTBS1_1LZ8QZN7_.DBF deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_TEMP_1LZ8TSLB_.TMP deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\ONLINELOG\O1_MF_1_1LZ8TM4X_.LOG deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\ONLINELOG\O1_MF_2_1LZ8TMSL_.LOG deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\ONLINELOG\O1_MF_3_1LZ8TNCV_.LOG deleted
Finished recover at 20-SEP-05
TSPITR recovery completed sucessfully.
3. Connect to target database using SQLPLUS, put tablespace test online and check contents:
SQL> SELECT * FROM TEST001;
ID
----------
100
Recovered the lost table using TSPITR.
References
NOTE:304305.1 - Limitations of RMAN TSPITR
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1160613/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- xmlrpc walk throughXMLRPC
- Interview-Harry Potter walk through matrix.View
- 實戰10g新特性之RMAN TSPITR特性
- 利用RMAN做TSPITR
- Backup And Recovery User's Guide-RMAN TSPITR模型GUIIDE模型
- RMAN全自動TSPITR
- RMAN: Tablespace Point In Time Recovery (TSPITR)
- RMAN : Consistent Backup, Restore and Recovery using RMAN (Doc ID 162855.1)REST
- Oracle10G RMAN Database Duplication (Doc ID 259694.1)OracleDatabase
- RMAN Backup Shell Script Example (Doc ID 137181.1)
- RMAN 11g Import catalog fails RMAN-6429 (Doc ID 457392.1)ImportAI
- Backup And Recovery User's Guide-RMAN TSPITR的基本概念GUIIDE
- Rman Backup Failed With Error Rman-00600 [8201] (Doc ID 412786.1)AIError
- Performing duplicate database with ASM/OMF/RMAN (Doc ID 340848.1)ORMDatabaseASM
- RMAN Restore Performance from Tape is Very Poor (Doc ID 850988.1)RESTORM
- Can Tapes Be Used For RMAN Convert Database (Doc ID 563816.1)Database
- RMAN10g: backup copy of database (Doc ID 266980.1)Database
- Oracle 10g, Export problem through OEM(轉)Oracle 10gExport
- Backup And Recovery User's Guide-執行完全自動的RMAN TSPITRGUIIDE
- 【RMAN】表空間基於時間點的RMAN恢復-TSPITR
- Rman Enhancements In Oracle 11g. (Doc ID 1115423.1)Oracle
- Managing multiple archive log destinations with RMAN (Doc ID 443814.1)Hive
- Placeholder for AMDU binaries and using with ASM 10g (Doc ID 553639.1)ASM
- RMAN RAC Archivelog Restore Fails with RMAN-20242 (Doc ID 180169.1)HiveRESTAI
- Disable the automatic funciton of collecting statistics in 10G
- Hide RMAN Passwords when Connecting to a Target Database (Doc ID 183377.1)IDEDatabase
- Oracle RMAN實現“一鍵式”表空間TSPITROracle
- 利用rman的TSPITR技術找回刪除的表!
- Oracle 10g Automatic Undo Retention Tuning (zt)Oracle 10g
- Restore Controlfile from SBT Tape Fails RMAN-6172 (Doc ID 1314134.1)RESTAI
- oracle 10g RMAN管理Oracle 10g
- Through the NBA, clubs players and fans paid their respectsAI
- os.walk 和os.path.walk的區別
- 10g RAC rman tips
- oracle 10g rman 指令碼Oracle 10g指令碼
- 修改vip (Doc ID 276434.1)
- Backup And Recovery User's Guide-TSPITR 約束、特定情形、限制-TSPITR的限制GUIIDE
- rman總結(包含10g rman中的新特性)