[20170725]关于备份集与备份片.txt

简介: [20170725]关于备份集与备份片.txt --//以前学习rman对于备份集与备份片这个概念也不是很清晰. --//备份片(BACKUPPIECE)表示一个由RMAN产生备份的文件.

[20170725]关于备份集与备份片.txt

--//以前学习rman对于备份集与备份片这个概念也不是很清晰.
--//备份片(BACKUPPIECE)表示一个由RMAN产生备份的文件.用OS工具可以实实在在的看到.
--//备份集(BACKUPSET)表示进行一次备份所产生的所有备份片集合,是一个逻辑上的概念.

--//我的理解有点像表空间是一个逻辑的概念,里面可以有多过数据文件.还是通过例子说明:

1.环境:
SCOTT@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> report schema ;
using target database control file instead of recovery catalog
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    128      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

--//system表空间760M.

2.做一个测试:

$ cat aa.rman
run
{
allocate channel c1 device type disk maxpiecesize 100m;
backup datafile 1 format '/home/oracle/backup/datafile1_%U';
release channel c1;
}

RMAN> @ aa.rman

RMAN> run
2> {
3> allocate channel c1 device type disk maxpiecesize 100m;
4> backup datafile 1 format '/home/oracle/backup/datafile1_%U';
5> release channel c1;
6> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=68 device type=DISK

Starting backup at 2017-07-25 15:54:30
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel c1: starting piece 1 at 2017-07-25 15:54:30
channel c1: finished piece 1 at 2017-07-25 15:54:31
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_1_1 tag=TAG20170725T155430 comment=NONE
channel c1: starting piece 2 at 2017-07-25 15:54:31
channel c1: finished piece 2 at 2017-07-25 15:54:32
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_2_1 tag=TAG20170725T155430 comment=NONE
channel c1: starting piece 3 at 2017-07-25 15:54:32
channel c1: finished piece 3 at 2017-07-25 15:54:33
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_3_1 tag=TAG20170725T155430 comment=NONE
channel c1: starting piece 4 at 2017-07-25 15:54:33
channel c1: finished piece 4 at 2017-07-25 15:54:34
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_4_1 tag=TAG20170725T155430 comment=NONE
channel c1: starting piece 5 at 2017-07-25 15:54:34
channel c1: finished piece 5 at 2017-07-25 15:54:35
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_5_1 tag=TAG20170725T155430 comment=NONE
channel c1: starting piece 6 at 2017-07-25 15:54:35
channel c1: finished piece 6 at 2017-07-25 15:54:36
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_6_1 tag=TAG20170725T155430 comment=NONE
channel c1: starting piece 7 at 2017-07-25 15:54:36
channel c1: finished piece 7 at 2017-07-25 15:54:37
piece handle=/home/oracle/backup/datafile1_f7sa8c5m_7_1 tag=TAG20170725T155430 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:07
Finished backup at 2017-07-25 15:54:37

Starting Control File and SPFILE Autobackup at 2017-07-25 15:54:37
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_07_25/o1_mf_s_950284477_dqfy9xq3_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-07-25 15:54:38

released channel: c1

RMAN> **end-of-file**

$ ls -l /home/oracle/backup/datafile1_f7sa8c5m_*
-rw-r----- 1 oracle oinstall 104857600 2017-07-25 15:54:30 /home/oracle/backup/datafile1_f7sa8c5m_1_1
-rw-r----- 1 oracle oinstall 104857600 2017-07-25 15:54:31 /home/oracle/backup/datafile1_f7sa8c5m_2_1
-rw-r----- 1 oracle oinstall 104857600 2017-07-25 15:54:32 /home/oracle/backup/datafile1_f7sa8c5m_3_1
-rw-r----- 1 oracle oinstall 104857600 2017-07-25 15:54:33 /home/oracle/backup/datafile1_f7sa8c5m_4_1
-rw-r----- 1 oracle oinstall 104857600 2017-07-25 15:54:34 /home/oracle/backup/datafile1_f7sa8c5m_5_1
-rw-r----- 1 oracle oinstall 104857600 2017-07-25 15:54:35 /home/oracle/backup/datafile1_f7sa8c5m_6_1
-rw-r----- 1 oracle oinstall  50921472 2017-07-25 15:54:36 /home/oracle/backup/datafile1_f7sa8c5m_7_1

--//看到的这些文件就是备份片.
--//而整个备份片就构成了备机集.而且这个备份实际上2个备份片,另外一个控制文件以及spfile的备份集.具体看下面的视图查询.

3.通过视图说明问题:
SCOTT@book> select recid,piece#,handle,tag,set_count from V$BACKUP_PIECE where tag='TAG20170725T155430';
     RECID     PIECE# HANDLE                                        TAG                SET_COUNT
---------- ---------- --------------------------------------------- ------------------ ---------
       202          1 /home/oracle/backup/datafile1_f7sa8c5m_1_1    TAG20170725T155430       487
       203          2 /home/oracle/backup/datafile1_f7sa8c5m_2_1    TAG20170725T155430       487
       204          3 /home/oracle/backup/datafile1_f7sa8c5m_3_1    TAG20170725T155430       487
       205          4 /home/oracle/backup/datafile1_f7sa8c5m_4_1    TAG20170725T155430       487
       206          5 /home/oracle/backup/datafile1_f7sa8c5m_5_1    TAG20170725T155430       487
       207          6 /home/oracle/backup/datafile1_f7sa8c5m_6_1    TAG20170725T155430       487
       208          7 /home/oracle/backup/datafile1_f7sa8c5m_7_1    TAG20170725T155430       487
7 rows selected.

SCOTT@book> column handle format a100
SCOTT@book> select recid,piece#,handle,tag,set_count from V$BACKUP_PIECE where set_count=488;
     RECID     PIECE# HANDLE                                                                                               TAG                               SET_COUNT
---------- ---------- ---------------------------------------------------------------------------------------------------- -------------------------------- ----------
       209          1 /u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_07_25/o1_mf_s_950284477_dqfy9xq3_.bkp        TAG20170725T155437                      488

--//备份集可以查询V$BACKUP_SET_DETAILS,V$BACKUP_SET视图.
SCOTT@book> select * from V$BACKUP_SET;
RECID      STAMP  SET_STAMP  SET_COUNT B CON INCREMENTAL_LEVEL PIECES START_TIME          COMPLETION_TIME     ELAPSED_SECONDS BLOCK_SIZE INP KEE KEEP_UNTIL KEEP_OPTION MUL
----- ---------- ---------- ---------- - --- ----------------- ------ ------------------- ------------------- --------------- ---------- --- --- ---------- ----------- ---
  201  950284476  950284470        487 D NO                         7 2017-07-25 15:54:30 2017-07-25 15:54:36               6       8192 NO  NO                         NO
  202  950284477  950284477        488 D YES                        1 2017-07-25 15:54:37 2017-07-25 15:54:37               0      16384 NO  NO                         NO


SCOTT@book> @ &r/pt2 'select * from V$BACKUP_SET_DETAILS'
old   6:     from table(xmlsequence(cursor( &1 )))
new   6:     from table(xmlsequence(cursor( select * from V$BACKUP_SET_DETAILS )))
   ROW_NUM    COL_NUM COL_NAME                       COL_VALUE
---------- ---------- ------------------------------ -----------------------------------------------------
         1          1 SESSION_KEY                    451
                    2 SESSION_RECID                  451
                    3 SESSION_STAMP                  950284466
                    4 BS_KEY                         201
                    5 RECID                          201
                    6 STAMP                          950284476
                    7 SET_STAMP                      950284470
                    8 SET_COUNT                      487
                    9 BACKUP_TYPE                    D
                   10 CONTROLFILE_INCLUDED           NO
                   11 PIECES                         7
                   12 START_TIME                     2017-07-25 15:54:30
                   13 COMPLETION_TIME                2017-07-25 15:54:36
                   14 ELAPSED_SECONDS                6
                   15 BLOCK_SIZE                     8192
                   16 KEEP                           NO
                   17 DEVICE_TYPE                    DISK
                   18 COMPRESSED                     NO
                   19 NUM_COPIES                     1
                   20 OUTPUT_BYTES                   680009728
                   21 ORIGINAL_INPUT_BYTES           796925952
                   22 COMPRESSION_RATIO              1.1719331638737968172125914057511836066
                   23 STATUS                         A
                   24 ORIGINAL_INPRATE_BYTES         132820992
                   25 OUTPUT_RATE_BYTES              113334954.666666666666666666666666666667
                   26 ORIGINAL_INPUT_BYTES_DISPLAY     760.01M
                   27 OUTPUT_BYTES_DISPLAY             648.51M
                   28 ORIGINAL_INPRATE_BYTES_DISPLAY   126.67M
                   29 OUTPUT_RATE_BYTES_DISPLAY        108.08M
                   30 TIME_TAKEN_DISPLAY             00:00:06
                   31 ENCRYPTED                      NO
                   32 BACKED_BY_OSB                  NO
Press Enter to view next row...

ROW_NUM    COL_NUM COL_NAME                       COL_VALUE
---------- ---------- ------------------------------ --------------------------------------------
         2          1 SESSION_KEY                    451
                    2 SESSION_RECID                  451
                    3 SESSION_STAMP                  950284466
                    4 BS_KEY                         202
                    5 RECID                          202
                    6 STAMP                          950284477
                    7 SET_STAMP                      950284477
                    8 SET_COUNT                      488
                    9 BACKUP_TYPE                    D
                   10 CONTROLFILE_INCLUDED           YES
                   11 PIECES                         1
                   12 START_TIME                     2017-07-25 15:54:37
                   13 COMPLETION_TIME                2017-07-25 15:54:37
                   14 ELAPSED_SECONDS                0
                   15 BLOCK_SIZE                     16384
                   16 KEEP                           NO
                   17 DEVICE_TYPE                    DISK
                   18 COMPRESSED                     NO
                   19 NUM_COPIES                     1
                   20 OUTPUT_BYTES                   10764288
                   21 ORIGINAL_INPUT_BYTES           10698754
                   22 COMPRESSION_RATIO              1
                   23 STATUS                         A
                   24 ORIGINAL_INPRATE_BYTES         10698754
                   25 OUTPUT_RATE_BYTES              10764288
                   26 ORIGINAL_INPUT_BYTES_DISPLAY      10.20M
                   27 OUTPUT_BYTES_DISPLAY              10.27M
                   28 ORIGINAL_INPRATE_BYTES_DISPLAY    10.20M
                   29 OUTPUT_RATE_BYTES_DISPLAY         10.27M
                   30 TIME_TAKEN_DISPLAY             00:00:00
                   31 ENCRYPTED                      NO
                   32 BACKED_BY_OSB                  NO
64 rows selected.

--//两者结合起来就很容易理解这些基本概念.

4.补充测试:
$ cat aa.rman
run
{
allocate channel c1 device type disk maxpiecesize 100m;
allocate channel c2 device type disk maxpiecesize 100m;
allocate channel c3 device type disk maxpiecesize 100m;
backup  as backupset section size 100M datafile 1 format '/home/oracle/backup/datafile1_%U';
release channel c1;
release channel c2;
release channel c3;
}

RMAN> @ aa.rman

RMAN> run
2> {
3> allocate channel c1 device type disk maxpiecesize 100m;
4> allocate channel c2 device type disk maxpiecesize 100m;
5> allocate channel c3 device type disk maxpiecesize 100m;
6> backup  as backupset section size 100M datafile 1 format '/home/oracle/backup/datafile1_%U';
7> release channel c1;
8> release channel c2;
9> release channel c3;
10> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=68 device type=DISK

allocated channel: c2
channel c2: SID=80 device type=DISK

allocated channel: c3
channel c3: SID=90 device type=DISK

Starting backup at 2017-07-26 08:56:02
released channel: c1
released channel: c2
released channel: c3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 07/26/2017 08:56:02
RMAN-06808: SECTION SIZE cannot be used when piece limit is in effect

RMAN> **end-of-file**

--//报错.修改如下,注意要退出rman在执行,不然SECTION SIZE cannot be used when piece limit is in effect依旧有效.
$ cat aa.rman
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup  as backupset section size 100M datafile 1 format '/home/oracle/backup/datafile1_%U';
release channel c1;
release channel c2;
release channel c3;
}

RMAN> @ aa.rman

RMAN> run
2> {
3> allocate channel c1 device type disk;
4> allocate channel c2 device type disk;
5> allocate channel c3 device type disk;
6> backup  as backupset section size 100M datafile 1 format '/home/oracle/backup/datafile1_%U';
7> release channel c1;
8> release channel c2;
9> release channel c3;
10> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=68 device type=DISK

allocated channel: c2
channel c2: SID=80 device type=DISK

allocated channel: c3
channel c3: SID=90 device type=DISK

Starting backup at 2017-07-26 08:57:58
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 1 through 12800
channel c1: starting piece 1 at 2017-07-26 08:57:59
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 12801 through 25600
channel c2: starting piece 2 at 2017-07-26 08:57:59
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 25601 through 38400
channel c3: starting piece 3 at 2017-07-26 08:57:59
channel c1: finished piece 1 at 2017-07-26 08:58:00
piece handle=/home/oracle/backup/datafile1_fbsaa84n_1_1 tag=TAG20170726T085758 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 38401 through 51200
channel c1: starting piece 4 at 2017-07-26 08:58:00
channel c2: finished piece 2 at 2017-07-26 08:58:00
piece handle=/home/oracle/backup/datafile1_fbsaa84n_2_1 tag=TAG20170726T085758 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 51201 through 64000
channel c2: starting piece 5 at 2017-07-26 08:58:00
channel c3: finished piece 3 at 2017-07-26 08:58:00
piece handle=/home/oracle/backup/datafile1_fbsaa84n_3_1 tag=TAG20170726T085758 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:01
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 64001 through 76800
channel c3: starting piece 6 at 2017-07-26 08:58:00
channel c1: finished piece 4 at 2017-07-26 08:58:01
piece handle=/home/oracle/backup/datafile1_fbsaa84n_4_1 tag=TAG20170726T085758 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 76801 through 89600
channel c1: starting piece 7 at 2017-07-26 08:58:01
channel c2: finished piece 5 at 2017-07-26 08:58:01
piece handle=/home/oracle/backup/datafile1_fbsaa84n_5_1 tag=TAG20170726T085758 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
backing up blocks 89601 through 97280
channel c2: starting piece 8 at 2017-07-26 08:58:02
channel c3: finished piece 6 at 2017-07-26 08:58:02
piece handle=/home/oracle/backup/datafile1_fbsaa84n_6_1 tag=TAG20170726T085758 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:02
channel c1: finished piece 7 at 2017-07-26 08:58:03
piece handle=/home/oracle/backup/datafile1_fbsaa84n_7_1 tag=TAG20170726T085758 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
channel c2: finished piece 8 at 2017-07-26 08:58:03
piece handle=/home/oracle/backup/datafile1_fbsaa84n_8_1 tag=TAG20170726T085758 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-07-26 08:58:03

Starting Control File and SPFILE Autobackup at 2017-07-26 08:58:03
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_07_26/o1_mf_s_950345883_dqht8v4k_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-07-26 08:58:04

released channel: c1

released channel: c2

released channel: c3

RMAN> **end-of-file**


SCOTT@book> select recid,piece#,handle,tag,set_count from V$BACKUP_PIECE where tag like 'TAG20170726T085%';
RECID PIECE# HANDLE                                                                                        TAG                SET_COUNT
----- ------ --------------------------------------------------------------------------------------------- ------------------ ---------
  218      1 /home/oracle/backup/datafile1_fbsaa84n_1_1                                                    TAG20170726T085758       491
  219      2 /home/oracle/backup/datafile1_fbsaa84n_2_1                                                    TAG20170726T085758       491
  220      3 /home/oracle/backup/datafile1_fbsaa84n_3_1                                                    TAG20170726T085758       491
  221      4 /home/oracle/backup/datafile1_fbsaa84n_4_1                                                    TAG20170726T085758       491
  222      5 /home/oracle/backup/datafile1_fbsaa84n_5_1                                                    TAG20170726T085758       491
  223      6 /home/oracle/backup/datafile1_fbsaa84n_6_1                                                    TAG20170726T085758       491
  224      7 /home/oracle/backup/datafile1_fbsaa84n_7_1                                                    TAG20170726T085758       491
  225      8 /home/oracle/backup/datafile1_fbsaa84n_8_1                                                    TAG20170726T085758       491
  226      1 /u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_07_26/o1_mf_s_950345883_dqht8v4k_.bkp TAG20170726T085803       499
9 rows selected.

--//虽然建立3个通道,但是建立2个备份集.

目录
相关文章
|
7月前
|
Oracle Unix 关系型数据库
通过磁带系统备份与还原的一些记录
通过磁带系统备份与还原的一些记录
38 1
|
SQL Oracle 关系型数据库
[20171225]没有备份数据文件的恢复.txt
[20171225]没有备份数据文件的恢复.txt --//别人问的问题,增加了数据文件没有备份,如何恢复,实际上很简单,因为当前控制文件有记录建立时间只要从建立数据文件开始的 --//归档日志都存在恢复是没有任何问题的.
912 0
|
Oracle 关系型数据库 数据库
[20171122]恢复数据文件块头5.txt
[20171122]恢复数据文件块头5.txt --//前几天做了恢复数据文件块头,通过备份文件直接取出文件块头,覆盖原来的数据块,然后修复. --//今天测试使用image copy来恢复.
1123 0
|
Oracle 关系型数据库 OLAP
[20171123]rman备份与数据文件变化6.txt
[20171123]rman备份与数据文件变化6.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.
794 0
|
Oracle 关系型数据库 数据库管理
[20161101]rman备份与数据文件变化7.txt
[20161101]rman备份与数据文件变化7.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.
1189 0
|
关系型数据库 MySQL 数据库
|
Oracle 关系型数据库 数据库
[20171114]恢复数据文件块头2.txt
[20171114]恢复数据文件块头2.txt --//曾经写过一篇[20161111]数据库文件头的修复.txt,但是利用大小相似的数据文件头覆盖来恢复,那是属于特种恢复.
1082 0

相关实验场景

更多