1112catalog copy的数据文件作为0级备份

[20151112]catalog copy的数据文件作为0级备份.txt

--使用热备份模式备份的文件是否可以作为0级备份呢?

--以前学习rman这部分内容时候有点混乱,无法理解为什么使用rman backup as copy 的数据文件与0级备份的数据文件存在那些不同.
--是否使用热备份以及backpup as copy备份的数据文件是否可以作为0级备份.
--通过例子来说明:

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

SYS@book> alter  tablespace users begin  backup ;
Tablespace altered.

$ cp /mnt/ramdisk/book/users01.dbf /home/oracle/backup/

SYS@book> alter  tablespace users end  backup ;
Tablespace altered.

RMAN> list copy of tablespace users;
specification does not match any datafile copy in the repository

RMAN> list copy of datafile 4;
specification does not match any datafile copy in the repository

--可以发现使用热备份模式的方式控制文件不会记录,毕竟这个os命令完成的备份,这也是淘汰热备份模式主要原因.管理问题.

2.使用catalog注册.

RMAN> catalog start with '/home/oracle/backup/users01.dbf';
searching for all files that match the pattern /home/oracle/backup/users01.dbf
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/backup/users01.dbf
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/backup/users01.dbf

RMAN> list copy of tablespace users;
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
2       4    A 2015-11-12 09:20:23 1558886    2015-11-12 09:14:58
        Name: /home/oracle/backup/users01.dbf

--可以发现记录的备份是按照copy方式做了.

RMAN> backup as copy datafile 4 format '/home/oracle/backup/datafile_4_%N.dbf';
Starting backup at 2015-11-12 09:27:07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/home/oracle/backup/datafile_4_USERS.dbf tag=TAG20151112T092707 RECID=3 STAMP=895570027
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:27:08

RMAN> list copy of datafile 4;
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
3       4    A 2015-11-12 09:27:07 1559316    2015-11-12 09:27:07
        Name: /home/oracle/backup/datafile_4_USERS.dbf
        Tag: TAG20151112T092707

2       4    A 2015-11-12 09:20:23 1558886    2015-11-12 09:14:58
        Name: /home/oracle/backup/users01.dbf

3.理论讲这些文件可以作为0级备份:

RMAN> catalog datafilecopy '/home/oracle/backup/users01.dbf' level 0 ;
cataloged datafile copy

RMAN> list copy of datafile 4;

List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
3       4    A 2015-11-12 09:27:07 1559316    2015-11-12 09:27:07
        Name: /home/oracle/backup/datafile_4_USERS.dbf
        Tag: TAG20151112T092707

5       4    A 2015-11-12 09:30:59 1558886    2015-11-12 09:14:58
        Name: /home/oracle/backup/users01.dbf

--注意看key已经变成了5.

RMAN> BACKUP INCREMENTAL LEVEL 1 datafile 4 format '/home/oracle/backup/inc_user01_%U.dbf';

Starting backup at 2015-11-12 09:37:25
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 09:37:26
channel ORA_DISK_1: finished piece 1 at 2015-11-12 09:37:27
piece handle=/home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf tag=TAG20151112T093725 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:37:27

$ ll /home/oracle/backup/
total 97440
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall    40960 Nov 12 09:37 inc_user01_08qm2kmm_1_1.dbf
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:15 users01.dbf

RMAN> list backupset ;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
7       Incr 1  32.00K     DISK        00:00:00     2015-11-12 09:37:26
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20151112T093725
        Piece Name: /home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf
  List of Datafiles in backup set 7
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  4    1  Incr 1560000    2015-11-12 09:37:26 /mnt/ramdisk/book/users01.dbf

--文件大小也可以说明问题.可以确定热备份已经作为0级备份.

4.对比看看:
--使用增量0级备份看看:

RMAN> BACKUP INCREMENTAL LEVEL 0 datafile 4 format '/home/oracle/backup/inc0_user01_%U.dbf';
Starting backup at 2015-11-12 09:39:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 09:39:44
channel ORA_DISK_1: finished piece 1 at 2015-11-12 09:39:45
piece handle=/home/oracle/backup/inc0_user01_09qm2kr0_1_1.dbf tag=TAG20151112T093944 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:39:45

RMAN> host "ls -l /home/oracle/backup";
total 142088
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 09:39 inc0_user01_09qm2kr0_1_1.dbf
-rw-r----- 1 oracle oinstall    40960 Nov 12 09:37 inc_user01_08qm2kmm_1_1.dbf
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:15 users01.dbf
host command complete

RMAN> host "ls -l /mnt/ramdisk/book/users01.dbf";
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:39 /mnt/ramdisk/book/users01.dbf
host command complete

--注意看文件大小,实际上0级备份与copy方式两者存在不同.0级备份也是备份仅仅使用的块,以这个备份为基础,做1级备份,或者1级累积
--备份.实际上还可以在备份时选择压缩模式.

RMAN> BACKUP as compressed backupset  INCREMENTAL LEVEL 0 datafile 4  format '/home/oracle/backup/inc0_user01_%U.dbf';

Starting backup at 2015-11-12 09:49:01
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 09:49:01
channel ORA_DISK_1: finished piece 1 at 2015-11-12 09:49:02
piece handle=/home/oracle/backup/inc0_user01_0aqm2lcd_1_1.dbf tag=TAG20151112T094901 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:49:02

RMAN> host "ls -l /home/oracle/backup";
total 143452
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 09:39 inc0_user01_09qm2kr0_1_1.dbf
-rw-r----- 1 oracle oinstall  1392640 Nov 12 09:49 inc0_user01_0aqm2lcd_1_1.dbf
-rw-r----- 1 oracle oinstall    40960 Nov 12 09:37 inc_user01_08qm2kmm_1_1.dbf
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:15 users01.dbf
host command complete

-- 注意看文件大小.

5.好了,现在删除一些备份,仅仅留下as copy方式的备份:
RMAN> delete backupset 7,8,9;
using channel ORA_DISK_1
List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
7       7       1   1   AVAILABLE   DISK        /home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf
8       8       1   1   AVAILABLE   DISK        /home/oracle/backup/inc0_user01_09qm2kr0_1_1.dbf
9       9       1   1   AVAILABLE   DISK        /home/oracle/backup/inc0_user01_0aqm2lcd_1_1.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf RECID=7 STAMP=895570646
deleted backup piece
backup piece handle=/home/oracle/backup/inc0_user01_09qm2kr0_1_1.dbf RECID=8 STAMP=895570784
deleted backup piece
backup piece handle=/home/oracle/backup/inc0_user01_0aqm2lcd_1_1.dbf RECID=9 STAMP=895571341
Deleted 3 objects

RMAN> delete copy of datafile 4 completed after '2015-11-12 09:30:59';
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=394 device type=DISK
List of Datafile Copies
=======================
Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
5       4    A 2015-11-12 09:30:59 1558886    2015-11-12 09:14:58
        Name: /home/oracle/backup/users01.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=/home/oracle/backup/users01.dbf RECID=5 STAMP=895570259
Deleted 1 objects

RMAN> list copy of database;
List of Datafile Copies
=======================
Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
3       4    A 2015-11-12 09:27:07 1559316    2015-11-12 09:27:07
        Name: /home/oracle/backup/datafile_4_USERS.dbf
        Tag: TAG20151112T092707

RMAN> list backupset summary;
specification does not match any backup in the repository

--做1个增量1级备份:
RMAN> BACKUP INCREMENTAL LEVEL 1 datafile 4  format '/home/oracle/backup/inc1_user01_%U.dbf';
Starting backup at 2015-11-12 10:30:44
using channel ORA_DISK_1
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 10:30:44
channel ORA_DISK_1: finished piece 1 at 2015-11-12 10:30:45
piece handle=/home/oracle/backup/inc1_user01_0bqm2nqk_1_1.dbf tag=TAG20151112T103044 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 10:30:45

RMAN> host "ls -l /home/oracle/backup";
total 93348
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 10:30 inc1_user01_0bqm2nqk_1_1.dbf
host command complete

--可以发现增量备份虽然是1级,因为不存在0级备份,备份文件实际上是0级.as copy方式的备份没有作为0级备份.

RMAN> list backupset ;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
10      Incr 0  43.55M     DISK        00:00:00     2015-11-12 10:30:44
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20151112T103044
        Piece Name: /home/oracle/backup/inc1_user01_0bqm2nqk_1_1.dbf
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  4    0  Incr 1562428    2015-11-12 10:30:44 /mnt/ramdisk/book/users01.dbf

--注意看LV=0 , 表示0级备份,说明没有指定as copy作为0级备份.

RMAN> BACKUP INCREMENTAL LEVEL 1 datafile 4  format '/home/oracle/backup/inc1_user01_%U.dbf';
Starting backup at 2015-11-12 10:34:13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 10:34:13
channel ORA_DISK_1: finished piece 1 at 2015-11-12 10:34:14
piece handle=/home/oracle/backup/inc1_user01_0cqm2o15_1_1.dbf tag=TAG20151112T103413 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 10:34:14

RMAN> host "ls -l /home/oracle/backup";
total 93388
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 10:30 inc1_user01_0bqm2nqk_1_1.dbf
-rw-r----- 1 oracle oinstall    40960 Nov 12 10:34 inc1_user01_0cqm2o15_1_1.dbf
host command complete

RMAN> list backupset summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
10      B  0  A DISK        2015-11-12 10:30:44 1       1       NO         TAG20151112T103044
11      B  1  A DISK        2015-11-12 10:34:13 1       1       NO         TAG20151112T103413

--注意看lv,第2次才是1级备份,前面第1次是0级备份(因为0级不存在).再看看这个as copy的备份能否作为0级备份.
RMAN> catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.dbf' level 0 ;

cataloged datafile copy
datafile copy file name=/home/oracle/backup/datafile_4_USERS.dbf RECID=6 STAMP=895574253

RMAN> list datafilecopy all;
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
6       4    A 2015-11-12 10:37:33 1559316    2015-11-12 09:27:07
        Name: /home/oracle/backup/datafile_4_USERS.dbf
        Tag: TAG20151112T092707

--key变成了6.不过那里能看出来这个copy备份作为0级备份呢?

RMAN> catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.dbf' level 1 ;

cataloged datafile copy
datafile copy file name=/home/oracle/backup/datafile_4_USERS.dbf RECID=7 STAMP=895574636

--key变成了7. 还是不知道那里能看出来这个copy备份作为1级备份呢?不知道那位知道.

时间: 2024-09-18 17:33:13

1112catalog copy的数据文件作为0级备份的相关文章

1207catalog copy的数据文件作为0级备份2

[20151207]catalog copy的数据文件作为0级备份补充.txt --  前一阵子写了1篇blog,使用热备份模式备份的文件是否可以作为0级备份. --  以及使用backpup as copy备份的数据文件是否可以作为0级备份. --  链接:http://blog.itpub.net/267265/viewspace-1832475/ --  当时困惑的是使用catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.d

[20151116]rman 全备份以及增量0级备份.txt

[20151116]rman 全备份以及增量0级备份.txt --前一阵子写了一篇将as copy作为增量0级备份的帖子,今天对比全备份以及增量0级备份的不同. 1.测试环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- --------------------------------------

0级备份和全备份的本质区别

准备:将测试环境的users表空间只读 测试: 1.数据库0级别备份 RMAN> backup incremental level 0 database tag 'levle0' format '/home/oracle/guo/%U'; Starting backup at 23-MAY-15 using channel ORA_DISK_1 channel ORA_DISK_1: starting incremental level 0 datafile backup set channel

[20161101]rman备份与数据文件变化7.txt

[20161101]rman备份与数据文件变化7.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.... --//而且当时的测试很乱,自己主要一边做一边想.... --//链接: http://blog.itpub.net/267265/viewspace-2127386/ http://blog.itpub

[20171123]rman备份与数据文件变化6.txt

[20171123]rman备份与数据文件变化6.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.... --//而且当时的测试很乱,自己主要一边做一边想.... --//链接: http://blog.itpub.net/267265/viewspace-2127386/ http://blog.itpub

ORACLE 只读数据文件备份与恢复

      第一章 只读数据文件备份与恢复 BLOG文档结果图:       只读数据文件是只读表空间的数据文件,其数据块包括文件头在内不允许更改(少数管理性命令除外). 将表空间设置为只读状态的命令: SQL> alter tablespace TBS_READ read only;   Tablespace altered.   将表空间重新设置为常规的读/写状态的命令: SQL> alter tablespace TBS_READ read write;   Tablespace alt

如何不使用rman工具恢复被rm删除的数据文件

朋友一时兴起使用了rm**,删除了oracle数据文件后找我帮忙,我在帮朋友恢复数据库时,遇到了当recover时,报错不能找到28739号归档日志,这样我就不能同步scn,更不能打开数据库了.这是归档日志不连续的典型案例,我最后告诉他要做好心理准备.事情还没有完,这个真实案例引发了我的思考,如果当时在朋友没有做rman拯救措施的情况下,可不可能不使用rman即可恢复数据文件呢!最后我找到了答案:) 案例 1.系统solaris SunOS TJLT-YDWG6 5.9 Generic_1223

[20151218]数据文件的unrecover与增量备份

[20151218]数据文件的unrecover与增量备份.txt --前一阵子我给别人演示truncate的不完全恢复,结果非常难堪的遇到无法恢复的情况. --问题是我建立的数据库按照这个链接建立的. http://blog.itpub.net/267265/viewspace-1845062/ --而这样建立的数据库表空间example的属性NOLOGGING. CREATE TABLESPACE EXAMPLE DATAFILE   '/mnt/ramdisk/book/example01

数据文件丢失如何恢复

摘要: 数据文件丢失如何恢复,内容来自以下讨论: http://www.itpub.net/348275.html 数据库归档模式,新建表空间testtbs, 数据文件testtbs.dbf关闭数据库删除数据文件testtbs.dbf启动数据库 提示:ORA-01157: 无法标识/锁定数据文件 2 - 请参阅 DBWR 跟踪文件ORA-01110: 数据文件 2: 'D:ORACLEORADATAHAHATESTTBS.DBF' 此数据文件没有做任何备份, 请问这种情况怎么恢复 操作如下: S