设为首页 加入收藏

TOP

RMANTablePointInTimeRecovery(PITR)inPDBs(一)
2015-07-24 10:44:05 来源: 作者: 【 】 浏览:6
Tags:RMANTablePointInTimeRecovery PITR inPDBs

1.首先使用RMAN做一次备份(必需有次备份)

rman target /

backup database;

or

backup database root;

backup pluggable database pdb;


2.在pdb中创建test用户并授权

sqlplus / as sysdba

alter session set container=pdb;

create user test identified by redhat quota unlimited on users;

grant connect,create table to test;


3.用测试用户创建测试表并查询当前scn

create table t1 (id int);

insert into t1 values(1);

commit;

SQL> select * from t1;

ID

----------

1


conn / as sysdba

SQL> SELECT DBMS_FLASHBACK.get_system_change_number FROM dual;

GET_SYSTEM_CHANGE_NUMBER

------------------------

1970004


4.再往t1表中插入一条数据

sqlplus test/redhat@pdb

SQL> insert into t1 values(2);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t1;

ID

----------

1

2


5.使用RMAN来恢复

rman target /

RECOVER TABLE 'TEST'.'T1' OF PLUGGABLE DATABASE pdb

UNTIL SCN 1970004

AUXILIARY DESTINATION '/u01/aux'

REMAP TABLE 'TEST'.'T1':'T1_old';

or

RECOVER TABLE 'TEST'.'T1' OF PLUGGABLE DATABASE pdb

UNTIL SCN 1970004

AUXILIARY DESTINATION '/u01/aux'

DATAPUMP DESTINATION '/u01/export'

DUMP FILE 'test_t1_old.dmp'--将以前的数据expdp出来

NOTABLEIMPORT;--不会将之前的数据导入


6.查询恢复过来的表t1_old验证恢复的内容

sqlplus test/redhat@pdb

SQL> select * from t1_old;

ID

----------

1

SQL> select * from t1;

ID

----------

1

2

7.总结

此功能效果和flashback table差不多

alter table t1 enable row movement;

先将t1备份

create table t1_bak as select * from t1;

flashback table t1 to scn 1970004;--基于SCN闪回

flashback table t1 to timestamp to_timestamp('2014-06-07 14:41:19','yyyy-mm-dd hh24:mi:ss'); --基于时间戳闪回


8.下面是日志

[oracle@source admin]$ rman target /

Recovery Manager: Release 12.1.0.1.0 - Production on Sat Jun 7 14:42:27 2014

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CDB1 (DBID=823327692)

RMAN> RECOVER TABLE 'TEST'.'T1' OF PLUGGABLE DATABASE pdb
  UNTIL SCN 1970004
  AUXILIARY DESTINATION '/u01/aux'  
  REMAP TABLE 'TEST'.'T1':'T1_OLD';2> 3> 4> 

Starting recover at 07-JUN-14
using target database control file instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=269 device type=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='peCr'

initialization parameters used for automatic instance:
db_name=CDB1
db_unique_name=peCr_pitr_pdb_CDB1
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/u01/app/oracle
db_create_file_dest=/u01/aux
log_archive_dest_1='location=/u01/aux'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used


starting up automatic instance CDB1

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                281019648 bytes
Database Buffers             780140544 bytes
Redo Buffers                   5480448 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  scn 1970004;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log 
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET until clause

Starting
首页 上一页 1 2 3 4 5 下一页 尾页 1/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇GoldenGateLagForHugeInsert 下一篇跳过丢失归档进行恢复

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·HyperText Transfer (2025-12-26 07:20:48)
·半小时搞懂 HTTP、HT (2025-12-26 07:20:42)
·CPython是什么?PyPy (2025-12-26 06:50:09)
·Python|如何安装seab (2025-12-26 06:50:06)
·python要学习数据分 (2025-12-26 06:50:03)