BACKUP SET和BACKUP PIECE
先來一段官方解釋
RMAN can store backup data in a logical structure called a backup set, which is the smallest unit of an RMAN backup. A backup set contains the data from one or more datafiles, archived redo logs, control files, or server parameter file. Backup sets, which are only created and accessed through RMAN, are the only form in which RMAN can write backups to media managers such as tape drives and tape libraries.
A backup set contains one or more binary files in an RMAN-specific format. Each of these files is known as a backup piece. A backup set can contain multiple datafiles.For example, you can back up 10 datafiles into a single backup set consisting of a
single backup piece. In this case, RMAN creates one backup piece as output. The backup set contains only this backup piece.
If you specify the SECTION SIZE parameter on the BACKUP command, then RMAN produces a multisection backup. This is a backup of a single large file, produced bymultiple channels in parallel, each of which produces one backup piece. Each backup
piece contains one file section of the file being backed up.
For non-multisection backups, RMAN only records backup sets in the repository that complete successfully. There is no such thing as a partial backup set. This differs from?an unsuccessful multisection backup, where it is possible for RMAN metadata to
contain a record for a partial backup set. In the latter case, you must use the DELETE?command to delete the partial backup set.
我的理解就從一個例子開始說吧。
如果配置了參數MAXSETSIZE就可能遇到這個問題
RMAN-03002: failure of backup command at 01/05/2020 18:00:07 RMAN-06183: datafile or datafile copy /oracle/oradata/orcl/users01.dbf (file number 4) larger than MAXSETSIZE
這里設置了MAXSETSIZE為20G,此時的users01.dbf已經超過了20G,導致此報錯。
解決方法
1、取消MAXSETSIZE;Oracle 默認值是unlimited,可以設置為 CONFIGURE MAXSETSIZE TO UNLIMITED;
2、調大MAXSETSIZE;此處是20G,可以改為CONFIGURE MAXSETSIZE TO 100G;
為什么會報這種錯誤?
首先從官文中理解下BACKUP SET和BACKUP PIECE:
1、BACKUP SET是個邏輯概念,是RMAN備份的最小單元;一個BACKUP SET包含一個或多個數據文件、歸檔日志,控制文件或者SPFILE的數據。
2、一個BACKUP SET可以包含一個或者多個BACKUP PIECE,BACKUP PIECE的數量取決于是否在備份時設置了MAXPIECESIZE(用在?ALLOCATE CHANNEL or CONFIGURE CHANNEL command);
3、BACKUP PIECE是個物理概念,存在于磁盤上;一個BACKUP PIECE可以包含一個或多個數據文件;例如當BACKUP SET只有一個BACKUP PIECE,它就包含所有的數據文件
Oracle的原理是BACKUP SET不能跨數據文件,即如果設置MAXSETSIZE,此值的最小值也要大于占用物理空間最大的數據文件的大小,
生成BACKUP SET的個數(排除控制文件及SPFILE產生的BACKUP SET)= 數據文件占用總物理空間 / MAXSETSIZE
BACKUP PIECE可以跨數據文件,一個BACKUP SET下的多個BACKUP PIECE可能來自一個較大的數據文件,也可能一個BACKUP PIECE包含來自兩個數據文件的數據。
以下來自測試環境:
先看數據文件大小,手動添加test表空間并指定1G大小數據文件test01.dbf
[oracle@orcl orcl]$ ls -lh
total 3.0G
-rw-r----- 1 oracle oinstall 9.6M Dec 24 06:00 control01.ctl
-rw-r----- 1 oracle oinstall 347M Dec 24 05:40 example01.dbf
-rw-r----- 1 oracle oinstall? 51M Dec 24 05:34 redo01.log
-rw-r----- 1 oracle oinstall? 51M Dec 24 06:00 redo02.log
-rw-r----- 1 oracle oinstall? 51M Dec 24 05:34 redo03.log
-rw-r----- 1 oracle oinstall 601M Dec 24 05:57 sysaux01.dbf
-rw-r----- 1 oracle oinstall 761M Dec 24 05:59 system01.dbf
-rw-r----- 1 oracle oinstall? 30M Dec 24 05:35 temp01.dbf
-rw-r----- 1 oracle oinstall 1.1G Dec 24 05:59 test01.dbf
-rw-r----- 1 oracle oinstall 101M Dec 24 05:59 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5.1M Dec 24 05:39 users01.dbf
執行rman備份后,查看BACKUP SET,此時的MAXSETSIZE設置為1G,MAXPIECESIZE無限制
RMAN> list backup;
List of Backup Sets
===================
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
55 ? ? ?Full ? ?1.03M ? ? ?DISK ? ? ? ?00:00:00 ? ? 24-DEC-19 ? ? ?
? ? ? ? BP Key: 66 ? Status: AVAILABLE ?Compressed: NO ?Tag: TAG20191224T060127
? ? ? ? Piece Name: /u01/app/oracle/oradata/Backup/oradb_ORCL_124_1.bak
? List of Datafiles in backup set 55
? File LV Type Ckp SCN ? ?Ckp Time ?Name
? ---- -- ---- ---------- --------- ----
? 6 ? ? ? Full 1757455 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/test01.dbf
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
56 ? ? ?Full ? ?519.12M ? ?DISK ? ? ? ?00:00:09 ? ? 24-DEC-19 ? ? ?
? ? ? ? BP Key: 67 ? Status: AVAILABLE ?Compressed: NO ?Tag: TAG20191224T060127
? ? ? ? Piece Name: /u01/app/oracle/oradata/Backup/oradb_ORCL_125_1.bak
? List of Datafiles in backup set 56
? File LV Type Ckp SCN ? ?Ckp Time ?Name
? ---- -- ---- ---------- --------- ----
? 2 ? ? ? Full 1757457 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/sysaux01.dbf
? 5 ? ? ? Full 1757457 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/example01.dbf
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
57 ? ? ?Full ? ?652.44M ? ?DISK ? ? ? ?00:00:38 ? ? 24-DEC-19 ? ? ?
? ? ? ? BP Key: 68 ? Status: AVAILABLE ?Compressed: NO ?Tag: TAG20191224T060127
? ? ? ? Piece Name: /u01/app/oracle/oradata/Backup/oradb_ORCL_126_1.bak
? List of Datafiles in backup set 57
? File LV Type Ckp SCN ? ?Ckp Time ?Name
? ---- -- ---- ---------- --------- ----
? 1 ? ? ? Full 1757469 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/system01.dbf
? 3 ? ? ? Full 1757469 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/undotbs01.dbf
? 4 ? ? ? Full 1757469 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/users01.dbf
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
58 ? ? ?Full ? ?9.64M ? ? ?DISK ? ? ? ?00:00:01 ? ? 24-DEC-19 ? ? ?
? ? ? ? BP Key: 69 ? Status: AVAILABLE ?Compressed: NO ?Tag: TAG20191224T060127
? ? ? ? Piece Name: /u01/app/oracle/oradata/Backup/oradb_ORCL_127_1.bak
? SPFILE Included: Modification time: 24-DEC-19
? SPFILE db_unique_name: ORCL
? Control File Included: Ckp SCN: 1757510 ? ? ?Ckp time: 24-DEC-19
查看BACKUP PIECE大小
-rw-r----- 1 oracle oinstall 1.1M Dec 24 06:01 oradb_ORCL_124_1.bak?
--1G的數據文件生成的BACKUP PIECE只有1.1M,證明RMAN只備份USED的數據塊
-rw-r----- 1 oracle oinstall 520M Dec 24 06:01 oradb_ORCL_125_1.bak
-rw-r----- 1 oracle oinstall 653M Dec 24 06:02 oradb_ORCL_126_1.bak
-rw-r----- 1 oracle oinstall 9.7M Dec 24 06:02 oradb_ORCL_127_1.bak
手動設置MAXPIECESIZE為300M,MAXSETSIZE依然為1G,再次執行備份
RMAN> list backup;
List of Backup Sets
===================
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
59 ? ? ?Full ? ?1.03M ? ? ?DISK ? ? ? ?00:00:00 ? ? 24-DEC-19 ? ? ?
? ? ? ? BP Key: 70 ? Status: AVAILABLE ?Compressed: NO ?Tag: TAG20191224T061050
? ? ? ? Piece Name: /u01/app/oracle/oradata/Backup/oradb_ORCL_128_1.bak
? List of Datafiles in backup set 59
? File LV Type Ckp SCN ? ?Ckp Time ?Name
? ---- -- ---- ---------- --------- ----
? 6 ? ? ? Full 1758274 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/test01.dbf
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
60 ? ? ?Full ? ?519.14M ? ?DISK ? ? ? ?00:00:36 ? ? 24-DEC-19 ? ? ?
? List of Datafiles in backup set 60
? File LV Type Ckp SCN ? ?Ckp Time ?Name
? ---- -- ---- ---------- --------- ----
? 2 ? ? ? Full 1758276 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/sysaux01.dbf
? 5 ? ? ? Full 1758276 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/example01.dbf
? Backup Set Copy #1 of backup set 60
? Device Type Elapsed Time Completion Time Compressed Tag
? ----------- ------------ --------------- ---------- ---
? DISK ? ? ? ?00:00:36 ? ? 24-DEC-19 ? ? ? NO ? ? ? ? TAG20191224T061050
? ? List of Backup Pieces for backup set 60 Copy #1
? ? BP Key ?Pc# Status ? ? ?Piece Name
? ? ------- --- ----------- ----------
? ? 71 ? ? ?1 ? AVAILABLE ? /u01/app/oracle/oradata/Backup/oradb_ORCL_129_1.bak
? ? 72 ? ? ?2 ? AVAILABLE ? /u01/app/oracle/oradata/Backup/oradb_ORCL_129_2.bak
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
61 ? ? ?Full ? ?652.58M ? ?DISK ? ? ? ?00:00:34 ? ? 24-DEC-19 ? ? ?
? List of Datafiles in backup set 61
? File LV Type Ckp SCN ? ?Ckp Time ?Name
? ---- -- ---- ---------- --------- ----
? 1 ? ? ? Full 1758319 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/system01.dbf
? 3 ? ? ? Full 1758319 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/undotbs01.dbf
? 4 ? ? ? Full 1758319 ? ?24-DEC-19 /u01/app/oracle/oradata/orcl/users01.dbf
? Backup Set Copy #1 of backup set 61
? Device Type Elapsed Time Completion Time Compressed Tag
? ----------- ------------ --------------- ---------- ---
? DISK ? ? ? ?00:00:34 ? ? 24-DEC-19 ? ? ? NO ? ? ? ? TAG20191224T061050
? ? List of Backup Pieces for backup set 61 Copy #1
? ? BP Key ?Pc# Status ? ? ?Piece Name
? ? ------- --- ----------- ----------
? ? 73 ? ? ?1 ? AVAILABLE ? /u01/app/oracle/oradata/Backup/oradb_ORCL_130_1.bak
? ? 74 ? ? ?2 ? AVAILABLE ? /u01/app/oracle/oradata/Backup/oradb_ORCL_130_2.bak
? ? 75 ? ? ?3 ? AVAILABLE ? /u01/app/oracle/oradata/Backup/oradb_ORCL_130_3.bak
BS Key ?Type LV Size ? ? ? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
62 ? ? ?Full ? ?9.64M ? ? ?DISK ? ? ? ?00:00:01 ? ? 24-DEC-19 ? ? ?
? ? ? ? BP Key: 76 ? Status: AVAILABLE ?Compressed: NO ?Tag: TAG20191224T061050
? ? ? ? Piece Name: /u01/app/oracle/oradata/Backup/oradb_ORCL_131_1.bak
? SPFILE Included: Modification time: 24-DEC-19
? SPFILE db_unique_name: ORCL
? Control File Included: Ckp SCN: 1758361 ? ? ?Ckp time: 24-DEC-19
查看生成的BACKUP PIECE大小,發現被按照最大300M分割成多個文件
-rw-r----- 1 oracle oinstall 1.1M Dec 24 06:10 oradb_ORCL_128_1.bak
-rw-r----- 1 oracle oinstall 300M Dec 24 06:11 oradb_ORCL_129_1.bak
-rw-r----- 1 oracle oinstall 220M Dec 24 06:11 oradb_ORCL_129_2.bak
-rw-r----- 1 oracle oinstall 300M Dec 24 06:11 oradb_ORCL_130_1.bak
-rw-r----- 1 oracle oinstall 300M Dec 24 06:11 oradb_ORCL_130_2.bak
-rw-r----- 1 oracle oinstall? 53M Dec 24 06:12 oradb_ORCL_130_3.bak
-rw-r----- 1 oracle oinstall 9.7M Dec 24 06:12 oradb_ORCL_131_1.bak
結論:
1、BACKUP SET設置不能小于最大占用物理空間的數據文件大小
2、不根據是否使用塊判斷,只根據占用的物理空間判斷分成多少BACKUP SET,當前數據文件總量大約2.7G,根據1G的MAXSETSIZE將全部數據文件備份為3個BACKUP SET
3、RMAN只備份已經使用的塊
4、概念不要混淆,MAXSETSIZE指的是BACKUPSET大小,MAXPIECESIZE指的是BACKUP PIECE大小
總結
以上是生活随笔為你收集整理的BACKUP SET和BACKUP PIECE的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Environment 注入servic
- 下一篇: 网络摄像视频方案整理