ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 增量合并的用法

增量合并的用法

原创 Linux操作系统 作者:ZALBB 时间:2019-06-20 07:39:05 0 删除 编辑
本文初步解释了10G的新特性,合并增量的用法

环境 windows 2000, oracle10104

1 RMAN里必须先存在数据文件的IMAGE COPY,

F:ORACLEbin>rman target /

Recovery Manager: Release 10.1.0.4.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

connected to target database: MARKET2 (DBID=2894056775)

RMAN> list copy;

specification does not match any archive log in the recovery catalog

RMAN> list backup;

RMAN> run
2> {allocate channel d1 type disk maxpiecesize = 2000m;
3> backup incremental level=1 for recover of copy with tag WEEKLY database
4> format 'H:rmanbacklevellevel_0_1';
5> sql 'alter system archive log current';
6> release channel d1;
7> }

released channel: ORA_DISK_1
allocated channel: d1
channel d1: sid=160 devtype=DISK

Starting backup at 2006-10-16 17:19:06
no parent backup or copy of datafile 2 found -- RMAN发现没有数据文件的IMAGE COPY后,
no parent backup or copy of datafile 1 found -- 自动为各个文件创建IMAGE COPY,同时按照
no parent backup or copy of datafile 6 found -- 命令命名该COPY的TAG=WEEKLY,
no parent backup or copy of datafile 9 found
no parent backup or copy of datafile 5 found
no parent backup or copy of datafile 4 found
no parent backup or copy of datafile 3 found
channel d1: starting datafile copy
input datafile fno=00002 name=H:ORADATAPSI3UNDOTBS01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_UNDOTBS1_2M6MNHD6_.DBF tag=WEEKLY recid=21
3 stamp=603998384
channel d1: datafile copy complete, elapsed time: 00:00:46
channel d1: starting datafile copy
input datafile fno=00001 name=H:ORADATAPSI3SYSTEM01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSTEM_2M6MOWN0_.DBF tag=WEEKLY recid=214
stamp=603998428
channel d1: datafile copy complete, elapsed time: 00:00:35
channel d1: starting datafile copy
input datafile fno=00006 name=H:ORADATAPSI3DB_CUMANDOC_TS01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_BD_CUMAN_2M6MQ4HN_.DBF tag=WEEKLY recid=21
5 stamp=603998467
channel d1: datafile copy complete, elapsed time: 00:00:47
channel d1: starting datafile copy
input datafile fno=00009 name=H:ORADATAPSI3SYSAUX01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSAUX_2M6MRH7B_.DBF tag=WEEKLY recid=216
stamp=603998508
channel d1: datafile copy complete, elapsed time: 00:00:36
channel d1: starting datafile copy
input datafile fno=00005 name=H:ORADATAPSI3TOOLS01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_TOOLS_2M6MSLPG_.DBF tag=WEEKLY recid=217 s
tamp=603998520
channel d1: datafile copy complete, elapsed time: 00:00:15
channel d1: starting datafile copy
input datafile fno=00004 name=H:ORADATAPSI3INDX01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_INDX_2M6MT2C7_.DBF tag=WEEKLY recid=218 st
amp=603998532
channel d1: datafile copy complete, elapsed time: 00:00:07
channel d1: starting datafile copy
input datafile fno=00003 name=H:ORADATAPSI3DRSYS01.DBF
output filename=H:ORACLELOGASMMARKET2DATAFILEO1_MF_DRSYS_2M6MTB1Y_.DBF tag=WEEKLY recid=219 s
tamp=603998539
channel d1: datafile copy complete, elapsed time: 00:00:04
Finished backup at 2006-10-16 17:22:20

Starting Control File and SPFILE Autobackup at 2006-10-16 17:22:21
piece handle=H:RMANBACKSPCTL2894056775_C-2894056775-20061016-02.CTL comment=NONE
Finished Control File and SPFILE Autobackup at 2006-10-16 17:22:28

sql statement: alter system archive log current

released channel: d1

RMAN>


2、导入数据,使数据库的数据有所变化
F:ORACLEbin>imp ncv31 file=g:tempBD_CUMANDOC.dmp log=g:tempimp_BD_CUMANDOC.log tables=BD_CUM
ANDOC

Import: Release 10.1.0.4.0 - Production on Mon Oct 16 17:24:26 2006

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

Password:

Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V09.02.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing NCV31's objects into NCV31
. . importing table "BD_CUMANDOC" 169778 rows imported
About to enable constraints...
Import terminated successfully without warnings.

F:ORACLEbin>

3、再所增量备份。
RMAN> run
2> {allocate channel d1 type disk maxpiecesize = 2000m;
3> backup incremental level=1 for recover of copy with tag WEEKLY database
4> format 'H:rmanbacklevellevel_0_1';
5> sql 'alter system archive log current';
6> release channel d1;
7> }

allocated channel: d1
channel d1: sid=160 devtype=DISK

Starting backup at 2006-10-16 17:36:14
channel d1: starting incremental level 1 datafile backupset
channel d1: specifying datafile(s) in backupset
input datafile fno=00002 name=H:ORADATAPSI3UNDOTBS01.DBF
input datafile fno=00001 name=H:ORADATAPSI3SYSTEM01.DBF
input datafile fno=00006 name=H:ORADATAPSI3DB_CUMANDOC_TS01.DBF
input datafile fno=00009 name=H:ORADATAPSI3SYSAUX01.DBF
input datafile fno=00005 name=H:ORADATAPSI3TOOLS01.DBF
input datafile fno=00004 name=H:ORADATAPSI3INDX01.DBF
input datafile fno=00003 name=H:ORADATAPSI3DRSYS01.DBF
channel d1: starting piece 1 at 2006-10-16 17:36:19
channel d1: finished piece 1 at 2006-10-16 17:36:34
piece handle=H:RMANBACKLEVELLEVEL_0_1 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:17
Finished backup at 2006-10-16 17:36:34

Starting Control File and SPFILE Autobackup at 2006-10-16 17:36:35
piece handle=H:RMANBACKSPCTL2894056775_C-2894056775-20061016-03.CTL comment=NONE
Finished Control File and SPFILE Autobackup at 2006-10-16 17:36:43

sql statement: alter system archive log current

released channel: d1

RMAN> list backup of database;


List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
147 Incr 1 86M DISK 00:00:15 2006-10-16 17:36:32
BP Key: 144 Status: AVAILABLE Compressed: NO Tag: TAG20061016T173616
Piece Name: H:RMANBACKLEVELLEVEL_0_1
List of Datafiles in backup set 147
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3SYSTEM01.DBF
2 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3UNDOTBS01.DBF
3 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3DRSYS01.DBF
4 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3INDX01.DBF
5 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3TOOLS01.DBF
6 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3DB_CUMANDOC_TS01.DBF
9 1 Incr 8736268315 2006-10-16 17:36:20 H:ORADATAPSI3SYSAUX01.DBF

RMAN> list copy of database;


List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - ------------------- ---------- ------------------- ----
214 1 A 2006-10-16 17:20:28 8736266308 2006-10-16 17:19:56 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_SYSTEM_2M6MOWN0_.DBF
213 2 A 2006-10-16 17:19:44 8736266263 2006-10-16 17:19:10 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_UNDOTBS1_2M6MNHD6_.DBF
219 3 A 2006-10-16 17:22:19 8736266377 2006-10-16 17:22:17 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_DRSYS_2M6MTB1Y_.DBF
218 4 A 2006-10-16 17:22:12 8736266371 2006-10-16 17:22:09 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_INDX_2M6MT2C7_.DBF
217 5 A 2006-10-16 17:22:00 8736266362 2006-10-16 17:21:54 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_TOOLS_2M6MSLPG_.DBF
215 6 A 2006-10-16 17:21:07 8736266323 2006-10-16 17:20:34 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_BD_CUMAN_2M6MQ4HN_.DBF
216 9 A 2006-10-16 17:21:48 8736266344 2006-10-16 17:21:18 H:ORACLELOGASMMARKET2DATAFIL
EO1_MF_SYSAUX_2M6MRH7B_.DBF

RMAN>

4、RMAN使用步骤3的增量备份(H:RMANBACKLEVELLEVEL_0_1)来“提交”到IMAGE COPY里。
RMAN> recover copy of database with tag weekly;

Starting recover at 2006-10-16 17:39:42
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=160 devtype=DISK
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafilecopy fno=00001 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSTEM_2M6MOWN0_.DB
F
recovering datafilecopy fno=00002 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_UNDOTBS1_2M6MNHD6_.
DBF
recovering datafilecopy fno=00003 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_DRSYS_2M6MTB1Y_.DBF

recovering datafilecopy fno=00004 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_INDX_2M6MT2C7_.DBF
recovering datafilecopy fno=00005 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_TOOLS_2M6MSLPG_.DBF

recovering datafilecopy fno=00006 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_BD_CUMAN_2M6MQ4HN_.
DBF
recovering datafilecopy fno=00009 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSAUX_2M6MRH7B_.DB
F
channel ORA_DISK_1: restored backup piece 1
piece handle=H:RMANBACKLEVELLEVEL_0_1 tag=TAG20061016T173616
channel ORA_DISK_1: restore complete
Finished recover at 2006-10-16 17:40:06

Starting Control File and SPFILE Autobackup at 2006-10-16 17:40:07
piece handle=H:RMANBACKSPCTL2894056775_C-2894056775-20061016-04.CTL comment=NONE
Finished Control File and SPFILE Autobackup at 2006-10-16 17:40:14

RMAN>

删除掉刚导入的表。
drop">SYS@PSI2>drop table ncv31.BD_CUMANDOC;

Table dropped.

SYS@PSI2>


没做增量备份,RMAN提示,没什么好恢复的。
RMAN> recover copy of database with tag weekly;

Starting recover at 2006-10-16 17:44:24
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
no copy of datafile 5 found to recover
no copy of datafile 6 found to recover
no copy of datafile 9 found to recover
Finished recover at 2006-10-16 17:44:26


删除该表后作增量备份。
RMAN> run
2> {allocate channel d1 type disk maxpiecesize = 2000m;
3> backup incremental level=1 for recover of copy with tag WEEKLY database
4> format 'H:rmanbacklevellevel_0_12';
5> sql 'alter system archive log current';
6> release channel d1;
7> }

allocated channel: d1
channel d1: sid=160 devtype=DISK

Starting backup at 2006-10-16 17:45:24
channel d1: starting incremental level 1 datafile backupset
channel d1: specifying datafile(s) in backupset
input datafile fno=00002 name=H:ORADATAPSI3UNDOTBS01.DBF
input datafile fno=00001 name=H:ORADATAPSI3SYSTEM01.DBF
input datafile fno=00006 name=H:ORADATAPSI3DB_CUMANDOC_TS01.DBF
input datafile fno=00009 name=H:ORADATAPSI3SYSAUX01.DBF
input datafile fno=00005 name=H:ORADATAPSI3TOOLS01.DBF
input datafile fno=00004 name=H:ORADATAPSI3INDX01.DBF
input datafile fno=00003 name=H:ORADATAPSI3DRSYS01.DBF
channel d1: starting piece 1 at 2006-10-16 17:45:28
channel d1: finished piece 1 at 2006-10-16 17:45:35
piece handle=H:RMANBACKLEVELLEVEL_0_12 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:09
Finished backup at 2006-10-16 17:45:35

Starting Control File and SPFILE Autobackup at 2006-10-16 17:45:36
piece handle=H:RMANBACKSPCTL2894056775_C-2894056775-20061016-05.CTL comment=NONE
Finished Control File and SPFILE Autobackup at 2006-10-16 17:45:44

sql statement: alter system archive log current

released channel: d1

RMAN>

再次提交,这次有东西可恢复了。
RMAN> recover copy of database with tag weekly;

Starting recover at 2006-10-16 17:46:50
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=160 devtype=DISK
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafilecopy fno=00001 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSTEM_2M6MOWN0_.DB
F
recovering datafilecopy fno=00002 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_UNDOTBS1_2M6MNHD6_.
DBF
recovering datafilecopy fno=00003 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_DRSYS_2M6MTB1Y_.DBF

recovering datafilecopy fno=00004 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_INDX_2M6MT2C7_.DBF
recovering datafilecopy fno=00005 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_TOOLS_2M6MSLPG_.DBF

recovering datafilecopy fno=00006 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_BD_CUMAN_2M6MQ4HN_.
DBF
recovering datafilecopy fno=00009 name=H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSAUX_2M6MRH7B_.DB
F
channel ORA_DISK_1: restored backup piece 1
piece handle=H:RMANBACKLEVELLEVEL_0_12 tag=TAG20061016T174526
channel ORA_DISK_1: restore complete
Finished recover at 2006-10-16 17:47:02

Starting Control File and SPFILE Autobackup at 2006-10-16 17:47:02
piece handle=H:RMANBACKSPCTL2894056775_C-2894056775-20061016-06.CTL comment=NONE
Finished Control File and SPFILE Autobackup at 2006-10-16 17:47:10

RMAN> exit

至此,可以清楚地看到:backup incremental level=1 for recover of copy with tag WEEKLY database
和 recover copy of database with tag weekly; 是一起使用的,前者用于创建增量备份,后者则读取
该备份后,将备份信息APPLY到相应的IMAGE COPY 上。相当于同步了IMAGE COPY 到增量备份的那一时刻。


关闭数据库,尝试使用image datafilecopy
shutdown">SYS@PSI2>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
startup">SYS@PSI2>startup mount;
ORACLE instance started.

Total System Global Area 448790528 bytes
Fixed Size 789648 bytes
Variable Size 212857712 bytes
Database Buffers 234881024 bytes
Redo Buffers 262144 bytes
Database mounted.


RMAN连接数据库,转换使用image datafilecopy
F:ORACLEbin>rman target /

Recovery Manager: Release 10.1.0.4.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

connected to target database: MARKET2 (DBID=2894056775)

RMAN> switch database to copy;

using target database controlfile instead of recovery catalog
datafile 1 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSTEM_2M6MOWN0_.DBF
"
datafile 2 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_UNDOTBS1_2M6MNHD6_.D
BF"
datafile 3 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_DRSYS_2M6MTB1Y_.DBF"

datafile 4 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_INDX_2M6MT2C7_.DBF"
datafile 5 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_TOOLS_2M6MSLPG_.DBF"

datafile 6 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_BD_CUMAN_2M6MQ4HN_.D
BF"
datafile 9 switched to datafile copy "H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSAUX_2M6MRH7B_.DBF
"

RMAN> recover database;

Starting recover at 2006-10-16 18:02:03
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

starting media recovery -- RMAN在使用了此IMAGE COPY后,将自动读取日至来恢复数据库到
media recovery complete -- 最新的状态。

Finished recover at 2006-10-16 18:02:14

RMAN> alter database open;

database opened

RMAN>


当前使用的数据文件

select">SYS@PSI2>select file_name from dba_data_files;

FILE_NAME
---------------------------------------------------------------------------------------
H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSTEM_2M6MOWN0_.DBF
H:ORACLELOGASMMARKET2DATAFILEO1_MF_UNDOTBS1_2M6MNHD6_.DBF
H:ORACLELOGASMMARKET2DATAFILEO1_MF_DRSYS_2M6MTB1Y_.DBF
H:ORACLELOGASMMARKET2DATAFILEO1_MF_INDX_2M6MT2C7_.DBF
H:ORACLELOGASMMARKET2DATAFILEO1_MF_TOOLS_2M6MSLPG_.DBF
H:ORACLELOGASMMARKET2DATAFILEO1_MF_BD_CUMAN_2M6MQ4HN_.DBF
H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSAUX_2M6MRH7B_.DBF

7 rows selected.

SYS@PSI2>


RMAN> report schema;

Report of database schema
File K-bytes Tablespace RB segs Datafile Name
---- ---------- -------------------- ------- -------------------
1 522240 SYSTEM *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSTEM_2M6MOW
N0_.DBF
2 583680 UNDOTBS1 *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_UNDOTBS1_2M6M
NHD6_.DBF
3 20480 DRSYS *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_DRSYS_2M6MTB1
Y_.DBF
4 25600 INDX *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_INDX_2M6MT2C7
_.DBF
5 102400 TOOLS *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_TOOLS_2M6MSLP
G_.DBF
6 512000 BD_CUMANDOC_TS *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_BD_CUMAN_2M6M
Q4HN_.DBF
9 512000 SYSAUX *** H:ORACLELOGASMMARKET2DATAFILEO1_MF_SYSAUX_2M6MRH
7B_.DBF

原来的数据文件变成了image datafilecopy
RMAN> list copy of database;


List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - ------------------- ---------- ------------------- ----
234 1 A 2006-10-16 18:01:41 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3SYSTEM01.DBF
235 2 A 2006-10-16 18:01:42 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3UNDOTBS01.DBF
236 3 A 2006-10-16 18:01:43 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3DRSYS01.DBF
237 4 A 2006-10-16 18:01:44 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3INDX01.DBF
238 5 A 2006-10-16 18:01:45 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3TOOLS01.DBF
239 6 A 2006-10-16 18:01:46 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3DB_CUMANDOC_TS01
.DBF
240 9 A 2006-10-16 18:01:46 8736268997 2006-10-16 17:51:44 H:ORADATAPSI3SYSAUX01.DBF

RMAN>

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

请登录后发表评论 登录
全部评论

注册时间:2018-08-15

  • 博文量
    46
  • 访问量
    34989