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 <<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';

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22741583/viewspace-683931/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22741583/viewspace-683931/

全自动 TSPITR--基于RMAN-LOGSEQ相关推荐

  1. 基于rman 全备+归档在线搭建DG

    主从两台主机hosts配置 192.168.1.197 oradb1(从) 192.168.1.198 oradb2(主) 二:搭建数据库 主库的操作: 1.确认主库参数 SQL> select ...

  2. QQ名片点赞全自动脚本,基于autojs的安卓免root脚本源码

    说明 本文提供的代码仅供参考.不建议用于生产环境. 可能有些地方在最新版本的Auto.js上面需要做修改,才能运行. Auto.js简介 Auto.js是利用安卓系统的"辅助功能" ...

  3. Oracle database TSPITR(TableSpace Point-In-Time Recovery) 表空间基于时间点的恢复

     主要用于恢复人为的错误 需要有之前的backup. 适用场景 (1)恢复错误的dml语句 (2)恢复错误的ddl语句,比如说更改了表结构,这个时候无法使用flashback table (3)恢复d ...

  4. Oracle 12c RMAN全攻略

    文章目录 1. RMAN命令 2. RMAN备份 2.1 控制RMAN备份 2.2 备份保留策略 2.3 快速恢复区(Fast Recovery Area) 2.4 backup...plus arc ...

  5. 【转】RMAN 高级恢复

    来源:http://blog.csdn.net/tianlesoftware/article/details/5722174 1. 不完全恢复 2. 基于RMAN 的恢复主题 3. 表空间时间点恢复 ...

  6. 19.Oracle10g服务器管理恢复--RMAN表空间恢复(练习33)

    在练习12-14中我们学习了如何将数据库中删除的表恢复到错误发生之前,而不需要恢复整个数据库.Oracle可以恢复数据库的一个表空间,此时还原表空间数据文件,然后应用归档日志文件直到失效前或错误发生处 ...

  7. 【RMAN】RMAN脚本中使用替换变量

    [RMAN]RMAN脚本中使用替换变量--windows 下rman全备脚本 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也 ...

  8. 【RMAN】RMAN脚本中使用替换变量--windows 下rman全备脚本

    [RMAN]RMAN脚本中使用替换变量--windows 下rman全备脚本 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也 ...

  9. Oracle RMAN篇(三)—— RMAN 维护与管理

    一. RMAN常用配置选项 1. 备份优化 优化备份开启后,会跳过以前备份过的文件,只读表空间和offline的表空间也会跳过. CONFIGURE BACKUP OPTIMIZATION OFF; ...

  10. oracle rman实时备份吗,ORACLE-RMAN自动备份和恢复

    以下介绍的是每周1-6增量备份,每周日全量备份. 通过系统启动自动化任务 [oracle@orcl ~]$ crontab -l 10 00 * * 0  /home/scripts/rmanleve ...

最新文章

  1. 编译Cocos2dx程序 (一)
  2. Face ID 上手体验信息汇总:面部解锁流畅,原理移植AR让人憧憬
  3. 60道Python面试题答案精选!找工作前必看
  4. 视频光端机各种视频接口的传输距离是多少?
  5. 在IBM服务器安装Windows server 2012的心得
  6. CocoaPods打包静态库
  7. java主类调用数组_用java编写在主函数中调用数组
  8. 使用zabbix监控mariadb性能状态
  9. 软件加入使用时间_2020年,加入“midi音乐制作讲堂”内部会员,学音乐制作变得更简单...
  10. 收藏一个Excel甘特图模板
  11. mac 程序员装机必备 一篇齐全
  12. 视频监控安防平台-国标35114(GB35114)A级检测
  13. 华为云查询弹性云服务器规格信息,查询规格详情和规格扩展信息列表
  14. 从10万到百亿营收的背后 | 同程旅游CTO V课堂实录
  15. django建议入门-FYI
  16. Mac安装虚拟机和CentOS
  17. linux打印机无法识别usb设备,佳能LBP2900打印机驱动安装使用 USB无法识别的解决方法步骤...
  18. 又是一道题拉开差距!IOI落幕,中国队三金一银,美国华人选手再获冠军
  19. 团体程序设计天梯赛--个人总结
  20. Hadoop(yarn)集群安装

热门文章

  1. 别人的计算机网络看不到,局域网内看不到别人的电脑怎么办
  2. 黑马程序员—写给各位同学,并致黑马各位老师的一封感谢信~~~~绝对给力
  3. java破解WIFI
  4. 权重推送 产品定位 直通车投放 关键词 直通车人群 创意标题 补单 新手上路,直通车烧钱没效果怎么办?
  5. 能带图最好的理解——克朗尼格-朋奈模型(Kronig-Penney模型)
  6. 爆火出圈的chatGPT
  7. cati服务器授权信息无效,cati安装
  8. 为什么自来水按立方米收费?
  9. 腾讯要放弃 TIM 了?
  10. 如何远程管理天翼云RDS数据库