您的位置:首页 > 数据库 > Oracle

实验表时间点恢复(Oracle 12c新功能)

2017-01-13 22:11 357 查看
--实验表时间点恢复(Oracle 12c新功能)

--12c,备份归档均存在且可用

[oracle@luo ~]$ rlwrap sqlplus sys/oracle@luo:1524/pdbwyzc as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 13 20:05:22 2017

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2017-01-13 20:05:43

SQL>
SQL> truncate table scott.emp;

Table truncated.

RMAN> recover table scott.emp of pluggable database pdbwyzc
2> until time "to_date('2017-01-13 20:05:43','yyyy-mm-dd hh24:mi:ss')"
3> auxiliary destination '/tmp/'
4> datapump destination '/home/oracle/'
5> dump file 'emp.dmp';

Starting recover at 13-JAN-17
using target database control file instead of recovery catalog
current log archived
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/13/2017 20:09:56
RMAN-05063: Cannot recover specified tables
RMAN-05112: table "SCOTT"."EMP" already exists --由于EMP存在需要加参数NOTABLEIMPORT不导入表

RMAN> recover table scott.emp of pluggable database pdbwyzc
2> until time "to_date('2017-01-13 20:05:43','yyyy-mm-dd hh24:mi:ss')"
3> auxiliary destination '/tmp/'
4> datapump destination '/home/oracle/'
5> dump file 'emp.dmp'
6> notableimport;

Starting recover at 13-JAN-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=70 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='Axbr'

initialization parameters used for automatic instance:
db_name=WYZC
db_unique_name=Axbr_pitr_pdbwyzc_WYZC
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/oracle
_system_trig_enabled=FALSE
sga_target=1232M
processes=200
db_create_file_dest=/tmp/
log_archive_dest_1='location=/tmp/'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used

starting up automatic instance WYZC

Oracle instance started

Total System Global Area 1291845632 bytes

Fixed Size 2924016 bytes
Variable Size 352322064 bytes
Database Buffers 922746880 bytes
Redo Buffers 13852672 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until time "to_date('2017-01-13 20:05:43','yyyy-mm-dd hh24:mi:ss')";
# 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 restore at 13-JAN-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/recovery_area/WYZC/autobackup/2017_01_13/o1_mf_s_933192090_d7kjdvm7_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/recovery_area/WYZC/autobackup/2017_01_13/o1_mf_s_933192090_d7kjdvm7_.bkp tag=TAG20170113T200130
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/tmp/WYZC/controlfile/o1_mf_d7kjzyvr_.ctl
Finished restore at 13-JAN-17

sql statement: alter database mount clone database

sql statement: alter system archive log current

contents of Memory Script:
{
# set requested point in time
set until time "to_date('2017-01-13 20:05:43','yyyy-mm-dd hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 8 to new;
set newname for clone datafile 9 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 8, 9;

switch clone datafile all;
}
executing Memory Script

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

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /tmp/WYZC/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /tmp/WYZC/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 13-JAN-17
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /tmp/WYZC/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/WYZC/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/recovery_area/WYZC/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T192248_d7kg60cw_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/recovery_area/WYZC/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T192248_d7kg60cw_.bkp tag=TAG20170113T192248
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/WYZC/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/recovery_area/WYZC/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T192248_d7kg87o6_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/recovery_area/WYZC/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T192248_d7kg87o6_.bkp tag=TAG20170113T192248
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /tmp/WYZC/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /tmp/WYZC/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/recovery_area/WYZC/1C2F27358BAD7564E0530C9DA8C0C33C/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T200055_d7kjcqb6_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/recovery_area/WYZC/1C2F27358BAD7564E0530C9DA8C0C33C/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T200055_d7kjcqb6_.bkp tag=TAG20170113T200055
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 13-JAN-17

datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=933192787 file name=/tmp/WYZC/datafile/o1_mf_system_d7kk06dy_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=933192787 file name=/tmp/WYZC/datafile/o1_mf_undotbs1_d7kk1mq4_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=14 STAMP=933192787 file name=/tmp/WYZC/datafile/o1_mf_sysaux_d7kk06cw_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=15 STAMP=933192788 file name=/tmp/WYZC/datafile/o1_mf_system_d7kk1tvm_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=16 STAMP=933192788 file name=/tmp/WYZC/datafile/o1_mf_sysaux_d7kk1tto_.dbf

contents of Memory Script:
{
# set requested point in time
set until time "to_date('2017-01-13 20:05:43','yyyy-
4000
mm-dd hh24:mi:ss')";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 4 online";
sql clone "alter database datafile 3 online";
sql clone 'PDBWYZC' "alter database datafile
8 online";
sql clone 'PDBWYZC' "alter database datafile
9 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "PDBWYZC":"SYSTEM", "PDBWYZC":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile 1 online

sql statement: alter database datafile 4 online

sql statement: alter database datafile 3 online

sql statement: alter database datafile 8 online

sql statement: alter database datafile 9 online

Starting recover at 13-JAN-17
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 116 is already on disk as file /u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_116_d7kg8crj_.arc
archived log for thread 1 with sequence 117 is already on disk as file /u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_117_d7kgr78v_.arc
archived log for thread 1 with sequence 118 is already on disk as file /u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_118_d7kgsj33_.arc
archived log for thread 1 with sequence 119 is already on disk as file /u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_119_d7kh5tdh_.arc
archived log for thread 1 with sequence 120 is already on disk as file /u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_120_d7kjwn2w_.arc
archived log file name=/u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_116_d7kg8crj_.arc thread=1 sequence=116
archived log file name=/u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_117_d7kgr78v_.arc thread=1 sequence=117
archived log file name=/u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_118_d7kgsj33_.arc thread=1 sequence=118
archived log file name=/u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_119_d7kh5tdh_.arc thread=1 sequence=119
archived log file name=/u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_120_d7kjwn2w_.arc thread=1 sequence=120
media recovery complete, elapsed time: 00:00:11
Finished recover at 13-JAN-17

sql statement: alter database open read only

contents of Memory Script:
{
sql clone 'alter pluggable database PDBWYZC open read only';
}
executing Memory Script

sql statement: alter pluggable database PDBWYZC open read only

contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
''/tmp/WYZC/controlfile/o1_mf_d7kjzyvr_.ctl'' comment=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script

sql statement: create spfile from memory

database closed
database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 1291845632 bytes

Fixed Size 2924016 bytes
Variable Size 352322064 bytes
Database Buffers 922746880 bytes
Redo Buffers 13852672 bytes

sql statement: alter system set control_files = ''/tmp/WYZC/controlfile/o1_mf_d7kjzyvr_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 1291845632 bytes

Fixed Size 2924016 bytes
Variable Size 352322064 bytes
Database Buffers 922746880 bytes
Redo Buffers 13852672 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until time "to_date('2017-01-13 20:05:43','yyyy-mm-dd hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 15 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 15;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 13-JAN-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=29 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00015 to /tmp/AXBR_PITR_PDBWYZC_WYZC/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/recovery_area/WYZC/1C2F27358BAD7564E0530C9DA8C0C33C/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T200055_d7kjcqb6_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/oracle/recovery_area/WYZC/1C2F27358BAD7564E0530C9DA8C0C33C/backupset/2017_01_13/o1_mf_nnndf_TAG20170113T200055_d7kjcqb6_.bkp tag=TAG20170113T200055
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 13-JAN-17

datafile 15 switched to datafile copy
input datafile copy RECID=18 STAMP=933192877 file name=/tmp/AXBR_PITR_PDBWYZC_WYZC/datafile/o1_mf_users_d7kk5d2m_.dbf

contents of Memory Script:
{
# set requested point in time
set until time "to_date('2017-01-13 20:05:43','yyyy-mm-dd hh24:mi:ss')";
# online the datafiles restored or switched
sql clone 'PDBWYZC' "alter database datafile
15 online";
# recover and open resetlogs
recover clone database tablespace "PDBWYZC":"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX", "PDBWYZC":"SYSTEM", "PDBWYZC":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile 15 online

Starting recover at 13-JAN-17
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 120 is already on disk as file /u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_120_d7kjwn2w_.arc
archived log file name=/u01/oracle/recovery_area/WYZC/archivelog/2017_01_13/o1_mf_1_120_d7kjwn2w_.arc thread=1 sequence=120
media recovery complete, elapsed time: 00:00:00
Finished recover at 13-JAN-17

database opened

contents of Memory Script:
{
sql clone 'alter pluggable database PDBWYZC open';
}
executing Memory Script

sql statement: alter pluggable database PDBWYZC open

contents of Memory Script:
{
# create directory for datapump import
sql 'PDBWYZC' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/home/oracle/''";
# create directory for datapump export
sql clone 'PDBWYZC' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/home/oracle/''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle/''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle/''

Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_Axbr_czjB":
EXPDP> Estimate in progress using BLOCKS method...
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Total estimation using BLOCKS method: 64 KB
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
EXPDP> Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
EXPDP> Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
EXPDP> Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
EXPDP> ORA-39127: unexpected error from call to export_string :=SYS.DBMS_TRANSFORM_EXIMP.INSTANCE_INFO_EXP('AQ$_ORDERS_QUEUETABLE_S','IX',1,1,'12.01.00.02.00',newblock)
ORA-00376: file 11 cannot be read at this time
ORA-01110: data file 11: '/u01/oracle/oradata/wyzc/pdbwyzc/example01.dbf'
ORA-06512: at "SYS.DBMS_TRANSFORM_EXIMP", line 197
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_METADATA", line 10261
ORA-39127: unexpected error from call to export_string :=SYS.DBMS_TRANSFORM_EXIMP.INSTANCE_INFO_EXP('AQ$_STREAMS_QUEUE_TABLE_S','IX',1,1,'12.01.00.02.00',newblock)
ORA-00376: file 11 cannot be read at this time
ORA-01110: data file 11: '/u01/oracle/oradata/wyzc/pdbwyzc/example01.dbf'
ORA-06512: at "SYS.DBMS_TRANSFORM_EXIMP", line 197
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_METADATA", line 10261
EXPDP> . . exported "SCOTT"."EMP" 8.773 KB 14 rows
EXPDP> Master table "SYS"."TSPITR_EXP_Axbr_czjB" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_Axbr_czjB is:
EXPDP> /home/oracle/emp.dmp
EXPDP> Job "SYS"."TSPITR_EXP_Axbr_czjB" completed with 2 error(s) at Fri Jan 13 20:16:02 2017 elapsed 0 00:00:35
Export completed

Not performing table import after point-in-time recovery

Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /tmp/WYZC/datafile/o1_mf_temp_d7kk3nz6_.tmp deleted
auxiliary instance file /tmp/WYZC/datafile/o1_mf_temp_d7kk3b1l_.tmp deleted
auxiliary instance file /tmp/AXBR_PITR_PDBWYZC_WYZC/onlinelog/o1_mf_3_d7kk5hz3_.log deleted
auxiliary instance file /tmp/AXBR_PITR_PDBWYZC_WYZC/onlinelog/o1_mf_2_d7kk5gvq_.log deleted
auxiliary instance file /tmp/AXBR_PITR_PDBWYZC_WYZC/onlinelog/o1_mf_1_d7kk5g2q_.log deleted
auxiliary instance file /tmp/AXBR_PITR_PDBWYZC_WYZC/datafile/o1_mf_users_d7kk5d2m_.dbf deleted
auxiliary instance file /tmp/WYZC/datafile/o1_mf_sysaux_d7kk1tto_.dbf deleted
auxiliary instance file /tmp/WYZC/datafile/o1_mf_system_d7kk1tvm_.dbf deleted
auxiliary instance file /tmp/WYZC/datafile/o1_mf_sysaux_d7kk06cw_.dbf deleted
auxiliary instance file /tmp/WYZC/datafile/o1_mf_undotbs1_d7kk1mq4_.dbf deleted
auxiliary instance file /tmp/WYZC/datafile/o1_mf_system_d7kk06dy_.dbf deleted
auxiliary instance file /tmp/WYZC/controlfile/o1_mf_d7kjzyvr_.ctl deleted
Finished recover at 13-JAN-17

--随后导入emp.dmp即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rman 12c