测试结论
1,历史相关旧文
20170611星期日之基于oracle 11.2.0.4 rman data file copy以及增量scn备份数据文件持续变化系列之一.js
2,在第一次增量SCN的DATA FILE RMAN备份之后的多次增量基于SCN的增量RMAN备份的起点SCN的来源为
SQL> conn /as sysdba
Connected.
SQL> select file#,checkpoint_change# from v$datafile where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5920877
SQL> select file#,checkpoint_change# from v$datafile_header where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5920877
3,结合如上,数据文件则可以一直基于初次的data file copy以及后续多次增量数据文件RMAN备份,把数据拉平,达到最大的数据一致性
测试明细
1,上次的v$backup_datafile信息
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
SQL> set linesize 300
SQL> select recid,file#,incremental_level,incremental_change#,checkpoint_change#,COMPLETION_TIME from v$backup_datafile where file#=9
2 ;
RECID FILE# INCREMENTAL_LEVEL INCREMENTAL_CHANGE# CHECKPOINT_CHANGE# COMPLETION_TIME
---------- ---------- ----------------- ------------------- ------------------ -------------------
11 9 1 5889250 5914431 2017-06-11 16:29:44
12 9 1 5914431 5914455 2017-06-11 16:30:25
SQL>
2,对数据文件9进行datafile copy
[oracle@mygirl ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jun 11 18:52:35 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: MYGIRL (DBID=2527996082)
RMAN> backup as copy datafile 9 tag 'datafile 9 copy note' format '/home/oracle/datafile_9_%u_%d.bak';
Starting backup at 11-JUN-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00009 name=/oracle/mygirl/tbs_obj01.dbf
output file name=/home/oracle/datafile_9_0qs6i1o4_MYGIRL.bak tag=DATAFILE 9 COPY NOTE RECID=13 STAMP=946407173
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-JUN-17
3,可见v$backup_datafile不记得对于datafile copy操作
SQL> select recid,file#,incremental_level,incremental_change#,checkpoint_change#,COMPLETION_TIME from v$backup_datafile where file#=9
2 ;
RECID FILE# INCREMENTAL_LEVEL INCREMENTAL_CHANGE# CHECKPOINT_CHANGE# COMPLETION_TIME
---------- ---------- ----------------- ------------------- ------------------ -------------------
11 9 1 5889250 5914431 2017-06-11 16:29:44
12 9 1 5914431 5914455 2017-06-11 16:30:25
SQL>
4,暂停下,先另启一个主题,研究下数据文件的scn可否在mount状态下查查看,可见在mount状态也可以查看数据文件的scn
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> select file#,checkpoint_change# from v$datafile where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5919972
SQL> select file#,checkpoint_change# from v$datafile_header where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5919972
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2137886720 bytes
Fixed Size 2254952 bytes
Variable Size 2080376728 bytes
Database Buffers 50331648 bytes
Redo Buffers 4923392 bytes
Database mounted.
SQL> select file#,checkpoint_change# from v$datafile where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5920457
SQL> select file#,checkpoint_change# from v$datafile_header where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5920457
5,回到原来的主题上,继续测试研究在首次基于v$datafile_copy确认之backup incremental from scn 5915956 datafile 9 format '/home/oracle/incr_bak_%u_%d.bak'所使用的scn后,之后每次增量备份的SCN从哪儿获取
RMAN> backup as copy datafile 9 format '/home/oracle/datafile_9_copy_first_%u_%d.bak' tag 'datafile9_copy_first_1';
Starting backup at 11-JUN-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00009 name=/oracle/mygirl/tbs_obj01.dbf
output file name=/home/oracle/datafile_9_copy_first_0rs6i2lb_MYGIRL.bak tag=DATAFILE9_COPY_FIRST_1 RECID=14 STAMP=946408107
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 11-JUN-17
SQL> conn user_obj/system
Connected.
SQL> create table t_facebook(a int);
Table created.
SQL> insert into t_facebook values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> set linesize 300
SQL> col name for a50
SQL> select recid,name,file#,incremental_level,checkpoint_time,checkpoint_change# from v$datafile_copy where file#=9;
RECID NAME FILE# INCREMENTAL_LEVEL CHECKPOIN CHECKPOINT_CHANGE#
---------- -------------------------------------------------- ---------- ----------------- --------- ------------------
10 /oracle/product/11.2.0/db_1/dbs/data_D-MYGIRL_I-25 9 11-JUN-17 5913749
27996082_TS-TBS_OBJ_FNO-9_0gs6hotj
11 9 11-JUN-17 5914455
12 /home/oracle/datafile_9_0ns6hr1i_MYGIRL.bak 9 11-JUN-17 5915956
13 /home/oracle/datafile_9_0qs6i1o4_MYGIRL.bak 9 11-JUN-17 5919972
14 /home/oracle/datafile_9_copy_first_0rs6i2lb_MYGIRL 9 11-JUN-17 5920457
.bak
[oracle@mygirl ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jun 11 19:15:07 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: MYGIRL (DBID=2527996082)
RMAN> backup incremental from scn 5920457 datafile 9 format '/home/oracle/incr_bak_5920457_%u_%d.bak';
Starting backup at 11-JUN-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oracle/mygirl/tbs_obj01.dbf
channel ORA_DISK_1: starting piece 1 at 11-JUN-17
channel ORA_DISK_1: finished piece 1 at 11-JUN-17
piece handle=/home/oracle/incr_bak_5920457_0ss6i31u_MYGIRL.bak tag=TAG20170611T191510 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 11-JUN-17
channel ORA_DISK_1: finished piece 1 at 11-JUN-17
piece handle=/home/oracle/incr_bak_5920457_0ts6i31v_MYGIRL.bak tag=TAG20170611T191510 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-JUN-17
SQL> conn user_obj/system
Connected.
SQL> create table t_newly(a int);
Table created.
SQL> insert into t_newly values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> conn /as sysdba
Connected.
SQL> select file#,checkpoint_change# from v$datafile where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5920877
SQL> select file#,checkpoint_change# from v$datafile_header where file#=9;
FILE# CHECKPOINT_CHANGE#
---------- ------------------
9 5920877
[oracle@mygirl ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jun 11 19:18:08 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: MYGIRL (DBID=2527996082)
RMAN> backup incremental from scn 5920877 datafile 9 format '/home/oracle/incr_bak_5920877_%u_%d.bak';
Starting backup at 11-JUN-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oracle/mygirl/tbs_obj01.dbf
channel ORA_DISK_1: starting piece 1 at 11-JUN-17
channel ORA_DISK_1: finished piece 1 at 11-JUN-17
piece handle=/home/oracle/incr_bak_5920877_0us6i39f_MYGIRL.bak tag=TAG20170611T191911 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 11-JUN-17
channel ORA_DISK_1: finished piece 1 at 11-JUN-17
piece handle=/home/oracle/incr_bak_5920877_0vs6i39h_MYGIRL.bak tag=TAG20170611T191911 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-JUN-17
SQL> host mv /oracle/mygirl/tbs_obj01.dbf /oracle/mygirl/tbs_obj01.dbf.origbak
SQL> conn user_obj/system
Connected.
SQL> create table t_mod1(a int);
Table created.
SQL> insert into t_mod1 values(1);
insert into t_mod1 values(1)
*
ERROR at line 1:
ORA-01116: error in opening database file 9
ORA-01110: data file 9: '/oracle/mygirl/tbs_obj01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
[oracle@mygirl ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jun 11 19:21:38 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: MYGIRL (DBID=2527996082)
RMAN> sql 'alter database datafile 9 offline';
using target database control file instead of recovery catalog
sql statement: alter database datafile 9 offline
RMAN> restore datafile 9 from tag 'datafile9_copy_first_1';
Starting restore at 11-JUN-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: restoring datafile 00009
input datafile copy RECID=14 STAMP=946408107 file name=/home/oracle/datafile_9_copy_first_0rs6i2lb_MYGIRL.bak
destination for restore of datafile 00009: /oracle/mygirl/tbs_obj01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00009
output file name=/oracle/mygirl/tbs_obj01.dbf RECID=0 STAMP=0
Finished restore at 11-JUN-17
RMAN> recover datafile 9 from tag 'TAG20170611T191510';
Starting recover at 11-JUN-17
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 11-JUN-17
RMAN> recover datafile 9 from tag 'TAG20170611T191911';
Starting recover at 11-JUN-17
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 11-JUN-17
RMAN> sql 'alter database datafile 9 online';
sql statement: alter database datafile 9 online
[oracle@mygirl ~]$ sqlplus user_obj/system
SQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 11 19:32:40 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from t_newly;
A
----------
1
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-2140591/
,如需转载,请注明出处,否则将追究法律责任。