[20170616]no copy of datafile 6 found to recover.txt
--//最近几天一直被这个问题纠缠,我虽然不知道问题在哪来,还是找到简单的解决方法,做1个记录:
--//链接:http://www.itpub.net/thread-2088843-1-1.html
1.环境:
SYS@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
RMAN> show CONTROLFILE AUTOBACKUP ;
RMAN configuration parameters for database with db_unique_name BOOK are:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
RMAN> report schema ;
Report of database schema for database with db_unique_name BOOK
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 760 SYSTEM *** /mnt/ramdisk/book/system01.dbf
2 940 SYSAUX *** /mnt/ramdisk/book/sysaux01.dbf
3 865 UNDOTBS1 *** /mnt/ramdisk/book/undotbs01.dbf
4 146 USERS *** /mnt/ramdisk/book/users01.dbf
5 346 EXAMPLE *** /mnt/ramdisk/book/example01.dbf
6 40 TEA *** /mnt/ramdisk/book/tea01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 414 TEMP 32767 /mnt/ramdisk/book/temp01.dbf
--//我的目的很简单是否可以给1个copy的数据文件做增量scn.
2.测试:
RMAN> list backup ;
specification does not match any backup in the repository
RMAN> list copy of database ;
specification does not match any datafile copy in the repository
--//测试前我把以前的全部备份删除.
RMAN> backup as copy datafile 6 format '/home/oracle/backup/tea01.dbf';
Starting backup at 2017-06-16 17:18:26
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/home/oracle/backup/tea01.dbf tag=TAG20170616T171826 RECID=52 STAMP=946833506
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-06-16 17:18:27
RMAN> list copy of datafile 6;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
52 6 A 2017-06-16 17:18:26 13277281436 2017-06-16 17:18:26
Name: /home/oracle/backup/tea01.dbf
Tag: TAG20170616T171826
--//备份记录的Ckp SCN=13277281436.如果我执行如下
RMAN> recover copy of datafile 6 ;
Starting recover at 2017-06-16 17:19:31
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
no copy of datafile 6 found to recover
Finished recover at 2017-06-16 17:19:31
--//可以发现没有应用.必须做一个关于这个数据文件的增量备份.
RMAN> backup incremental from scn 13277281500 datafile 6 format '/home/oracle/backup/%U';
Starting backup at 2017-06-16 17:21:11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
RMAN-06755: WARNING: datafile 6: incremental-start SCN is too recent; using checkpoint SCN 13277281436 instead
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
channel ORA_DISK_1: starting piece 1 at 2017-06-16 17:21:11
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
channel ORA_DISK_1: finished piece 1 at 2017-06-16 17:21:12
piece handle=/home/oracle/backup/jes6v287_1_1 tag=TAG20170616T172111 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
including current control file in backup set
channel ORA_DISK_2: starting piece 1 at 2017-06-16 17:21:12
channel ORA_DISK_2: finished piece 1 at 2017-06-16 17:21:13
piece handle=/home/oracle/backup/jfs6v287_1_1 tag=TAG20170616T172111 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-06-16 17:21:13
--//说明一下,正常应该执行 from scn 13277281436,我选择从13277281500,备份程序自动纠正我的错误,选择正确的scn=13277281436
--//RMAN-06755: WARNING: datafile 6: incremental-start SCN is too recent; using checkpoint SCN 13277281436 instead.
--//接着增量恢复:
RMAN> recover copy of datafile 6 ;
Starting recover at 2017-06-16 17:22:48
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
no copy of datafile 6 found to recover
Finished recover at 2017-06-16 17:22:48
--//提示no copy of datafile 6 found to recover,很明显rman什么事情都没有做.
3.分析:
--//实际上我做了rman的跟踪:
$ rman target / debug recover,sql level=10 trace=tracefile.trc
DBGSQL: TARGET>
DECLARE
allCopies BOOLEAN;
BEGIN
dbms_rcvman.resetthisBackupAge;
IF ( :allCopies > 0)
THEN
allCopies := TRUE;
ELSE
allCopies := FALSE;
END IF;
:rc :=
dbms_rcvman.computeRecoveryActions
(
fno => :fno
,crescn => :crescn
,df_rlgscn => :rlgscn
,df_rlgtime => :rlgtime
,df_ckpscn => :ckpscn
,offlscn => :offlscn
,onlscn => :onlscn
,onltime => :onltime
,cleanscn => :cleanscn
,clean2scn => :clean2scn
,clean2time => :clean2time
,allowfuzzy => FALSE
,partial_rcv => FALSE
,cf_scn => :cfscn
,cf_cretime => :cfcretime
,cf_offrrid => :cfoffrrid
,allCopies => allCopies
,df_cretime => :cretime
,rmanCmd => :rmanCmd
,foreignDbid => :foreignDbid
,pluggedRonly => :pluggedRonly
,pluginSCN => :pluginSCN
,pluginRlgSCN => :pluginRlgSCN
,pluginRlgTime => :pluginRlgTime
,creation_thread => :creation_thread
,creation_size => :creation_size
);
IF ( :maxact > 0)
THEN
dbms_rcvman.trimRecoveryActions
(
maxActions => :maxact
,containerMask => dbms_rcvman.proxyCopy_con_t
+ dbms_rcvman.imageCopy_con_t
+ dbms_rcvman.backupSet_con_t
,actionMask => dbms_rcvman.full_act_t
);
END IF;
END;
DBGSQL: sqlcode = 0
DBGSQL: B :rc = 1
DBGSQL: B :allCopies = 0
DBGSQL: B :fno = 6
DBGSQL: B :crescn = 13276257767
DBGSQL: B :rlgscn = NULL
DBGSQL: B :rlgtime = NULL
DBGSQL: B :ckpscn = NULL
DBGSQL: B :offlscn = 0
DBGSQL: B :onlscn = 0
DBGSQL: B :onltime = "1988-01-01 00:01:01"
DBGSQL: B :cleanscn = 0
DBGSQL: B :clean2scn = 0
DBGSQL: B :clean2time = "1988-01-01 00:00:00"
DBGSQL: B :cfscn = 13277242031
DBGSQL: B :cfcretime = "2015-11-24 09:11:10"
DBGSQL: B :cfoffrrid = 0
DBGSQL: B :cretime = "2017-02-13 15:09:58"
DBGSQL: B :rmanCmd = 2
DBGSQL: B :maxact = 0
DBGSQL: B :foreignDbid = 0
DBGSQL: B :pluggedRonly = 0
DBGSQL: B :pluginSCN = 0
DBGSQL: B :pluginRlgSCN = 0
DBGSQL: B :pluginRlgTime = NULL
DBGSQL: B :creation_thread = 1
DBGSQL: B :creation_size = 5120
RMAN-05017: no copy of datafile 6 found to recover
RMAN-03091: Finished recover at 2017-06-15 16:53:13
--//target那行语句太长,我在toad下做了格式化处理.语句我也没看,明显增量备份没有记录.
RMAN> list backup ;
specification does not match any backup in the repository
--//从这里也说明问题,不知道为什么增量备份在控制文件中没有记录.catalog看看结果如何?
$ ls -l /home/oracle/backup/j*
-rw-r----- 1 oracle oinstall 40960 2017-06-16 17:21:11 /home/oracle/backup/jes6v287_1_1
-rw-r----- 1 oracle oinstall 11042816 2017-06-16 17:21:12 /home/oracle/backup/jfs6v287_1_1
RMAN> catalog backuppiece '/home/oracle/backup/jes6v287_1_1';
using target database control file instead of recovery catalog
cataloged backup piece
backup piece handle=/home/oracle/backup/jes6v287_1_1 RECID=253 STAMP=946834214
RMAN> catalog backuppiece '/home/oracle/backup/jfs6v287_1_1';
cataloged backup piece
backup piece handle=/home/oracle/backup/jfs6v287_1_1 RECID=254 STAMP=946834225
RMAN> list backup ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
252 Incr 32.00K DISK 00:00:00 2017-06-16 17:21:11
BP Key: 253 Status: AVAILABLE Compressed: NO Tag: TAG20170616T172111
Piece Name: /home/oracle/backup/jes6v287_1_1
List of Datafiles in backup set 252
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
6 Incr 13277281639 2017-06-16 17:21:11 /mnt/ramdisk/book/tea01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
253 Incr 10.52M DISK 00:00:00 2017-06-16 17:21:11
BP Key: 254 Status: AVAILABLE Compressed: NO Tag: TAG20170616T172111
Piece Name: /home/oracle/backup/jfs6v287_1_1
Control File Included: Ckp SCN: 13277281639 Ckp time: 2017-06-16 17:21:11
--//很明显做增量时还做了控制文件的备份.
RMAN> recover copy of datafile 6 until scn 13277281500;
Starting recover at 2017-06-16 17:32:49
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=101 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=123 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=134 device type=DISK
no copy of datafile 6 found to recover
Finished recover at 2017-06-16 17:32:50
--//执行没报错,但是还是no copy of datafile 6 found to recover,去掉until scn 13277281500;参数看看.
--//我本来的想法就是通过这样的方式恢复到特定的scn,看来不行.这也是我最初的目的..
RMAN> recover copy of datafile 6 ;
Starting recover at 2017-06-16 17:34:26
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00006 name=/home/oracle/backup/tea01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/jes6v287_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/jes6v287_1_1 tag=TAG20170616T172111
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2017-06-16 17:34:28
--//OK,成功!!
RMAN> list copy of datafile 6;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
53 6 A 2017-06-16 17:34:27 13277281639 2017-06-16 17:21:11
Name: /home/oracle/backup/tea01.dbf
Tag: TAG20170616T171826
--//我现在备份的数据文件scn=13277281639,也与前面做的增量一致.
4.总结:
--//感觉这个是bug,我在11.2.0.3也做了类似测试,没有问题.
--//不知道有什么好方法恢复到特定的scn,必须要通过辅助实例吗?这是我测试的目的....