[20171128]rman input memory buffer 3.txt

lfree發表於2017-11-29

[20171128]rman input memory buffer 3.txt

--//Input Memory Buffers如何測試,不清楚.不過找到一本電子書.摘要如下:
Oracle RMAN 11g Backup and Recovery.pdf

作者:Robert G. Freeman Matthew Hart
頁數:689
出版社:Mc graw hill
出版號: ISBN: 978-0-07-162861-7
        MHID: 0-07-162861-4

RMAN in Memory P80

    RMAN builds buffers in memory through which it streams data blocks for potential backup. This
memory utilization counts against the total size of the PGA and, sometimes, the SGA. There are
two kinds of memory buffers. Input buffers are the buffers that are filled with data blocks read
from files that are being backed up. Output buffers are the buffers that are filled when the
memory-to-memory write occurs to determine whether a particular block needs to be backed up.
When the output buffer is filled, it is written to the backup location. The memory buffers differ
depending on whether you are backing up to or restoring from disk or tape. Figure 2-3 illustrates
input and output buffer allocation. It illustrates a backup of two datafiles being multiplexed into
a single backup set.
       
Input Memory Buffers

    When you are backing up the database, the size and number of input memory buffers depend on
the exact backup command being executed. Primarily, they depend on the number of files being
multiplexed into a single backup. Multiplexing refers to the number of files that will have their
blocks backed up to the same backup piece. To keep the memory allocation within reason, the
following rules are applied to the memory buffer sizes based on the number of files being backed
up together:

■ If the number of files going into the backup set is four or less, then RMAN allocates four
   buffers per file at 1MB per buffer. The total will be 16MB or less.
■ If the number of files going into the backup set is greater than four, but no greater than
   eight, then each file gets four buffers, each of 512KB. This ensures that the total remains
   at 16MB or less.
■ If the number of files being multiplexed is greater than eight, then RMAN allocates four
   buffers of size 128KB. This ensures that each file being backed up will account for 512KB
   of buffer memory.

--//可以想像如果輸入快取如果全部寫入輸出快取,透過輸出檔案寫到備份集中的資料分佈,也能猜測出輸入快取大小.

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

CREATE TABLESPACE T01 DATAFILE '/mnt/ramdisk/book/T01.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T02 DATAFILE '/mnt/ramdisk/book/T02.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T03 DATAFILE '/mnt/ramdisk/book/T03.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T04 DATAFILE '/mnt/ramdisk/book/T04.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T05 DATAFILE '/mnt/ramdisk/book/T05.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T06 DATAFILE '/mnt/ramdisk/book/T06.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T07 DATAFILE '/mnt/ramdisk/book/T07.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T08 DATAFILE '/mnt/ramdisk/book/T08.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;

create table t01 tablespace t01 as select rownum id ,lpad('A',32,'A') name from dual connect by level<=1e5;
create table t02 tablespace t02 as select rownum id ,lpad('B',32,'B') name from dual connect by level<=1e5;
create table t03 tablespace t03 as select rownum id ,lpad('C',32,'C') name from dual connect by level<=1e5;
create table t04 tablespace t04 as select rownum id ,lpad('D',32,'D') name from dual connect by level<=1e5;
create table t05 tablespace t05 as select rownum id ,lpad('E',32,'E') name from dual connect by level<=1e5;
create table t06 tablespace t06 as select rownum id ,lpad('F',32,'F') name from dual connect by level<=1e5;
create table t07 tablespace t07 as select rownum id ,lpad('G',32,'G') name from dual connect by level<=1e5;
create table t08 tablespace t08 as select rownum id ,lpad('H',32,'H') name from dual connect by level<=1e5;
alter system checkpoint;
alter system checkpoint;

2.測試備份的情況:
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;

old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored

RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK CLEAR;
old RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 128 K;
old RMAN configuration parameters are successfully deleted
--//前面的測試限速取消.

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    1075     UNDOTBS1             ***     /mnt/ramdisk/book/undotbs01.dbf
4    2166     USERS                ***     /mnt/ramdisk/book/users01.dbf
5    346      EXAMPLE              ***     /mnt/ramdisk/book/example01.dbf
6    42       TEA                  ***     /mnt/ramdisk/book/tea01.dbf
7    6        T01                  ***     /mnt/ramdisk/book/T01.dbf
8    6        T02                  ***     /mnt/ramdisk/book/T02.dbf
9    6        T03                  ***     /mnt/ramdisk/book/T03.dbf
10   6        T04                  ***     /mnt/ramdisk/book/T04.dbf
11   6        T05                  ***     /mnt/ramdisk/book/T05.dbf
12   6        T06                  ***     /mnt/ramdisk/book/T06.dbf
13   6        T07                  ***     /mnt/ramdisk/book/T07.dbf
14   6        T08                  ***     /mnt/ramdisk/book/T08.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    414      TEMP                 32767       /mnt/ramdisk/book/temp01.dbf

RMAN> backup datafile 7,8,9,10,11,12,13,14 filesperset 8 format '/home/oracle/backup/t12345678_%U';
Starting backup at 2017-11-28 17:02:03
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=119 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=00007 name=/mnt/ramdisk/book/T01.dbf
input datafile file number=00008 name=/mnt/ramdisk/book/T02.dbf
input datafile file number=00009 name=/mnt/ramdisk/book/T03.dbf
input datafile file number=00010 name=/mnt/ramdisk/book/T04.dbf
input datafile file number=00011 name=/mnt/ramdisk/book/T05.dbf
input datafile file number=00012 name=/mnt/ramdisk/book/T06.dbf
input datafile file number=00013 name=/mnt/ramdisk/book/T07.dbf
input datafile file number=00014 name=/mnt/ramdisk/book/T08.dbf
channel ORA_DISK_1: starting piece 1 at 2017-11-28 17:02:03
channel ORA_DISK_1: finished piece 1 at 2017-11-28 17:02:04
piece handle=/home/oracle/backup/t12345678_lusknbob_1_1 tag=TAG20171128T170203 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-11-28 17:02:04

Starting Control File and SPFILE Autobackup at 2017-11-28 17:02:04
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_28/o1_mf_s_961261324_f1t9jdsj_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-28 17:02:05

3.分析備份集檔案:

$ strings t12345678_lusknbob_1_1 | egrep "AAAAA|BBBBB|CCCCC|DDDDD|EEEEE|FFFFF|GGGGG|HHHHH" | cut -c11-20 | uniq -c
   9978 AAAAAAAAAA
   9978 BBBBBBBBBB
   9978 CCCCCCCCCC
   9978 DDDDDDDDDD
   9978 EEEEEEEEEE
   9978 FFFFFFFFFF
   9978 GGGGGGGGGG
   9978 HHHHHHHHHH
  10080 AAAAAAAAAA
  10080 BBBBBBBBBB
  10080 CCCCCCCCCC
  10080 DDDDDDDDDD
  10080 EEEEEEEEEE
  10080 FFFFFFFFFF
  10080 GGGGGGGGGG
  10080 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
  10752 AAAAAAAAAA
  10752 BBBBBBBBBB
  10752 CCCCCCCCCC
  10752 DDDDDDDDDD
  10752 EEEEEEEEEE
  10752 FFFFFFFFFF
  10752 GGGGGGGGGG
  10752 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
  10752 AAAAAAAAAA
  10752 BBBBBBBBBB
  10752 CCCCCCCCCC
  10752 DDDDDDDDDD
  10752 EEEEEEEEEE
  10752 FFFFFFFFFF
  10752 GGGGGGGGGG
  10752 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
  10752 AAAAAAAAAA
  10752 BBBBBBBBBB
  10752 CCCCCCCCCC
  10752 DDDDDDDDDD
  10752 EEEEEEEEEE
  10752 FFFFFFFFFF
  10752 GGGGGGGGGG
  10752 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
   6022 AAAAAAAAAA
   6022 BBBBBBBBBB
   6022 CCCCCCCCCC
   6022 DDDDDDDDDD
   6022 EEEEEEEEEE
   6022 FFFFFFFFFF
   6022 GGGGGGGGGG
   6022 HHHHHHHHHH

--//你可以發現AAAAA BBBBB CCCCC DDDDD EEEEE FFFFF GGGGG HHHHH,交錯出現,同一批次出現次數都是一樣,只要驗證"AAAAA"輸出就ok了.
$ strings t12345678_lusknbob_1_1 | egrep "AAAAA|BBBBB|CCCCC|DDDDD|EEEEE|FFFFF|GGGGG|HHHHH" | cut -c11-20 | uniq -c | grep "AAAAA"
   9978 AAAAAAAAAA
  10080 AAAAAAAAAA
  10416 AAAAAAAAAA
  10752 AAAAAAAAAA
  10416 AAAAAAAAAA
  10752 AAAAAAAAAA
  10416 AAAAAAAAAA
  10752 AAAAAAAAAA
  10416 AAAAAAAAAA
   6022 AAAAAAAAAA

SCOTT@book> column PARTITION_NAME noprint
SCOTT@book> select * from dba_extents where owner=user and segment_name in ('T01');
OWNER  SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME  EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
------ ------------ ------------ --------------- ---------- ---------- ---------- ---------- ---------- ------------
SCOTT  T01          TABLE        T01                      0          7        128      65536          8            7
SCOTT  T01          TABLE        T01                      1          7        136      65536          8            7
SCOTT  T01          TABLE        T01                      2          7        144      65536          8            7
SCOTT  T01          TABLE        T01                      3          7        152      65536          8            7
SCOTT  T01          TABLE        T01                      4          7        160      65536          8            7
SCOTT  T01          TABLE        T01                      5          7        168      65536          8            7
SCOTT  T01          TABLE        T01                      6          7        176      65536          8            7
SCOTT  T01          TABLE        T01                      7          7        184      65536          8            7
SCOTT  T01          TABLE        T01                      8          7        192      65536          8            7
SCOTT  T01          TABLE        T01                      9          7        200      65536          8            7
SCOTT  T01          TABLE        T01                     10          7        208      65536          8            7
SCOTT  T01          TABLE        T01                     11          7        216      65536          8            7
SCOTT  T01          TABLE        T01                     12          7        224      65536          8            7
SCOTT  T01          TABLE        T01                     13          7        232      65536          8            7
SCOTT  T01          TABLE        T01                     14          7        240      65536          8            7
SCOTT  T01          TABLE        T01                     15          7        248      65536          8            7
SCOTT  T01          TABLE        T01                     16          7        256    1048576        128            7
SCOTT  T01          TABLE        T01                     17          7        384    1048576        128            7
SCOTT  T01          TABLE        T01                     18          7        512    1048576        128            7
SCOTT  T01          TABLE        T01                     19          7        640    1048576        128            7
20 rows selected.

--//按照前面的介紹
■ If the number of files going into the backup set is greater than four, but no greater than
   eight, then each file gets four buffers, each of 512KB. This ensures that the total remains
   at 16MB or less.

--//這樣應該是512K.512/8 = 64塊.
SELECT    'select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between '
           || TO_CHAR (128 + (ROWNUM - 1) * 64)
           || ' and '
           || TO_CHAR (128 + ROWNUM * 64 - 1)
           || ' ;'
              c100
      FROM DUAL
CONNECT BY LEVEL <= 10;

C100
----------------------------------------------------------------------------------------------------
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 128 and 191 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 192 and 255 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 256 and 319 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 320 and 383 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 384 and 447 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 448 and 511 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 512 and 575 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 576 and 639 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 640 and 703 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 704 and 767 ;
10 rows selected.

--//順便抽取執行:
SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 128 and 191 ;
  COUNT(*)
----------
      9978

SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 192 and 255 ;
  COUNT(*)
----------
     10080

SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 256 and 319 ;
  COUNT(*)
----------
     10416

SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 320 and 383 ;
  COUNT(*)
----------
     10752

SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 384 and 447 ;
  COUNT(*)
----------
     10416

...

SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 704 and 767 ;
  COUNT(*)
----------
      6022

--//這也反向證明的輸入快取是512K.

--//如果備份集合中設定filesperset 6

RMAN> backup datafile 7,8,9,10,11,12 filesperset 6 format '/home/oracle/backup/t123456_%U';
Starting backup at 2017-11-28 17:22:40
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/mnt/ramdisk/book/T01.dbf
input datafile file number=00008 name=/mnt/ramdisk/book/T02.dbf
input datafile file number=00009 name=/mnt/ramdisk/book/T03.dbf
input datafile file number=00010 name=/mnt/ramdisk/book/T04.dbf
input datafile file number=00011 name=/mnt/ramdisk/book/T05.dbf
input datafile file number=00012 name=/mnt/ramdisk/book/T06.dbf
channel ORA_DISK_1: starting piece 1 at 2017-11-28 17:22:40
channel ORA_DISK_1: finished piece 1 at 2017-11-28 17:22:41
piece handle=/home/oracle/backup/t123456_m0skncv0_1_1 tag=TAG20171128T172240 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-11-28 17:22:41

Starting Control File and SPFILE Autobackup at 2017-11-28 17:22:41
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_28/o1_mf_s_961262561_f1tbq1kr_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-28 17:22:42


$ strings t123456_m0skncv0_1_1 | egrep "AAAAA|BBBBB|CCCCC|DDDDD|EEEEE|FFFFF|GGGGG|HHHHH" | cut -c11-20 | uniq -c | grep "AAAAA"
   9978 AAAAAAAAAA
  10080 AAAAAAAAAA
  10416 AAAAAAAAAA
  10752 AAAAAAAAAA
  10416 AAAAAAAAAA
  10752 AAAAAAAAAA
  10416 AAAAAAAAAA
  10752 AAAAAAAAAA
  10416 AAAAAAAAAA
   6022 AAAAAAAAAA
--//也可以驗證輸入快取是512K.

3.再增加一個表空間:
CREATE TABLESPACE T09 DATAFILE '/mnt/ramdisk/book/T09.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
create table t09 tablespace t09 as select rownum id ,lpad('I',32,'I') name from dual connect by level<=1e5;
alter system checkpoint;
alter system checkpoint;

RMAN> backup datafile 7,8,9,10,11,12,13,14,15 filesperset 9 format '/home/oracle/backup/t123456789_%U';
Starting backup at 2017-11-28 17:26:24
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/mnt/ramdisk/book/T01.dbf
input datafile file number=00008 name=/mnt/ramdisk/book/T02.dbf
input datafile file number=00009 name=/mnt/ramdisk/book/T03.dbf
input datafile file number=00010 name=/mnt/ramdisk/book/T04.dbf
input datafile file number=00011 name=/mnt/ramdisk/book/T05.dbf
input datafile file number=00012 name=/mnt/ramdisk/book/T06.dbf
input datafile file number=00013 name=/mnt/ramdisk/book/T07.dbf
input datafile file number=00014 name=/mnt/ramdisk/book/T08.dbf
input datafile file number=00015 name=/mnt/ramdisk/book/T09.dbf
channel ORA_DISK_1: starting piece 1 at 2017-11-28 17:26:24
channel ORA_DISK_1: finished piece 1 at 2017-11-28 17:26:25
piece handle=/home/oracle/backup/t123456789_m2sknd60_1_1 tag=TAG20171128T172624 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-11-28 17:26:25
Starting Control File and SPFILE Autobackup at 2017-11-28 17:26:25
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_28/o1_mf_s_961262785_f1tby1ll_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-28 17:26:26

$ strings t123456789_m2sknd60_1_1| egrep "AAAAA|BBBBB|CCCCC|DDDDD|EEEEE|FFFFF|GGGGG|HHHHH|IIIII" | cut -c11-20 | uniq -c
   9978 AAAAAAAAAA
   9978 BBBBBBBBBB
   9978 CCCCCCCCCC
   9978 DDDDDDDDDD
   9978 EEEEEEEEEE
   9978 FFFFFFFFFF
   9978 GGGGGGGGGG
   9978 HHHHHHHHHH
  10080 AAAAAAAAAA
  10080 BBBBBBBBBB
  10080 CCCCCCCCCC
  10080 DDDDDDDDDD
  10080 EEEEEEEEEE
  10080 FFFFFFFFFF
  10080 GGGGGGGGGG
  10080 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
  10752 AAAAAAAAAA
  10752 BBBBBBBBBB
  10752 CCCCCCCCCC
  10752 DDDDDDDDDD
  10752 EEEEEEEEEE
  10752 FFFFFFFFFF
  10752 GGGGGGGGGG
  10752 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
  10752 AAAAAAAAAA
  10752 BBBBBBBBBB
  10752 CCCCCCCCCC
  10752 DDDDDDDDDD
  10752 EEEEEEEEEE
  10752 FFFFFFFFFF
  10752 GGGGGGGGGG
  10752 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
  10752 AAAAAAAAAA
  10752 BBBBBBBBBB
  10752 CCCCCCCCCC
  10752 DDDDDDDDDD
  10752 EEEEEEEEEE
  10752 FFFFFFFFFF
  10752 GGGGGGGGGG
  10752 HHHHHHHHHH
  10416 AAAAAAAAAA
  10416 BBBBBBBBBB
  10416 CCCCCCCCCC
  10416 DDDDDDDDDD
  10416 EEEEEEEEEE
  10416 FFFFFFFFFF
  10416 GGGGGGGGGG
  10416 HHHHHHHHHH
   6022 AAAAAAAAAA
   6022 BBBBBBBBBB
   6022 CCCCCCCCCC
   6022 DDDDDDDDDD
   6022 EEEEEEEEEE
   6022 FFFFFFFFFF
   6022 GGGGGGGGGG
   6022 HHHHHHHHHH
100000 IIIIIIIIII

--//你可以發現T09表空間是最後備份的,與前面介紹的電子文件不同,前備份8個資料檔案,input memory buffer=512K.
--//補充:我後面測試10個檔案的備份情況在10g下,也是一樣的,先備份8個.然後如此迴圈...

■ If the number of files being multiplexed is greater than eight, then RMAN allocates four
   buffers of size 128KB. This ensures that each file being backed up will account for 512KB
   of buffer memory.

--//不知道如果恢復T09表空間是否直接會跳到備份的位置來恢復,如果前面也讀的話,效率就很低了.
--//這也是主張備份設定filesperset=1的原因,參考連結http://blog.itpub.net/267265/viewspace-2127267/.

--//順便測試看看T09表空間的恢復.

SCOTT@book> alter database datafile 15 offline ;
Database altered.

$ mv T09.dbf T09.dbf_20171129

$ strace -f -o /tmp/t09.txt rman target /
RMAN> restore datafile 15;

Starting restore at 2017-11-29 08:38:26
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=94 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00015 to /mnt/ramdisk/book/T09.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/t123456789_m2sknd60_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/t123456789_m2sknd60_1_1 tag=TAG20171128T172624
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2017-11-29 08:38:30

$ ls -l /home/oracle/backup/t123456789_m2sknd60_1_1
-rw-r----- 1 oracle oinstall 54591488 2017-11-28 17:26:24 /home/oracle/backup/t123456789_m2sknd60_1_1

--//昏filesystemio_options=ASYNCH採用非同步IO.使用的函式是io_submit,io_getevents.
$ grep io_submit /tmp/t09.txt | egrep "258}|259}"  | head
24142 io_submit(139770951761920, 4, {{0x7f1ef5ec1a98, 0, 0, 0, 258}, {0x7f1ef5ec1d20, 0, 0, 0, 258}, {0x7f1ef5ec1fa8, 0, 0, 0, 258}, {0x7f1ef5ec2230, 0, 0, 0, 258}}) = 4
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1a98, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1d20, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1fa8, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec2230, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1a98, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1d20, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1fa8, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec2230, 0, 0, 0, 258}}) = 1
24142 io_submit(139770951761920, 1, {{0x7f1ef5ec1a98, 0, 0, 0, 258}}) = 1
--//看不懂.重新設定filesystemio_options=NONE.
SYS@book> alter system set filesystemio_options=NONE scope=spfile;
System altered.

--//重啟在恢復看看.
$ strace  -f  -o /tmp/tt09.txt rman target /
....

$ grep "pread(258" /tmp/tt09.txt | sed -n "s/^.*=//p" | xargs echo | sed 's/ /+/g' | bc -l
55107584

--//你可以發現pread量與備份集檔案大小相當.

$ grep "pwrite(259" /tmp/tt09.txt | sed -n "s/^.*=//p" | xargs echo | sed 's/ /+/g' | bc -l
6299648

$ ls -l /mnt/ramdisk/book/T09.dbf
-rw-r----- 1 oracle oinstall 6299648 2017-11-29 09:28:55 /mnt/ramdisk/book/T09.dbf
--//pwrite寫入量一直.

$ grep "pread(258" /tmp/tt09.txt | tail
24443 pread(258, "\6\242\0\0\200\2@\3'\243\215\27\3\0\2\4\364\200\7\0\1\0\0\0\vc\1\0\375\242\215\27"..., 1048576, 45088768) = 1048576
24443 pread(258, "\6\242\0\0\200\2\300\1\344\241\215\27\3\0\2\4\vK\1\0\1\0\0\0\5c\1\0\271\241\215\27"..., 1048576, 46137344) = 1048576
24443 pread(258, "\6\242\0\0\200\2\200\2\207\242\215\27\3\0\2\4\267\324\4\0\1\0\0\0\10c\1\0]\242\215\27"..., 1048576, 47185920) = 1048576
24443 pread(258, "\6\242\0\0\200\2\200\3a\243\215\27\3\0\2\4\0277\10\0\1\0\0\0\fc\1\0007\243\215\27"..., 1048576, 48234496) = 1048576
24443 pread(258, "\36\242\0\0\200\0\300\3\376\257\215\27\3\0\1\4\301V\t\0\17\0\0\0\200\0\311\2\0\0\0\0"..., 1048576, 49283072) = 1048576
24443 pread(258, "\6\242\0\0\200\0\300\3r\260\215\27\3\0\2\4h6\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 50331648) = 1048576
24443 pread(258, "\6\242\0\0\200\1\300\3z\260\215\27\3\0\2\4\3717\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 51380224) = 1048576
24443 pread(258, "\6\242\0\0\200\1\300\3|\260\215\27\3\0\2\00497\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 52428800) = 1048576
24443 pread(258, "\6\242\0\0\200\2\300\3\177\260\215\27\3\0\2\4\274\347\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 53477376) = 1048576
24443 pread(258, "\6\242\0\0\200\2\300\3\202\260\215\27\3\0\2\4\2117\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 65536, 54525952) = 65536
--//可以發現這個時候的讀快取是1048576.

$ grep "pwrite(259" /tmp/tt09.txt
24443 pwrite(259, "\0\242\0\0\1\0\300\3\0\0\0\0\0\0\1\5\301\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1040384, 8192) = 1040384
24443 pwrite(259, " \242\0\0\200\0\300\3\202\260\215\27\3\0\4\4\327\325\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 1048576) = 1048576
24443 pwrite(259, " \242\0\0\0\1\300\3\202\260\215\27\3\0\2\4\335\326\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 2097152) = 1048576
24443 pwrite(259, " \242\0\0\200\1\300\3\202\260\215\27\3\0\2\4\337\326\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 3145728) = 1048576
24443 pwrite(259, " \242\0\0\0\2\300\3\202\260\215\27\3\0\2\4\331\326\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 4194304) = 1048576
24443 pwrite(259, " \242\0\0\200\2\300\3\202\260\215\27\3\0\2\4\333\326\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 5242880) = 1048576
24443 pwrite(259, "\0\242\0\0\0\3\300\3\0\0\0\0\0\0\1\5\300\247\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 6291456) = 8192
24443 pwrite(259, "\v\242\0\0\1\0\300\3\0\0\0\0\0\0\1\4y\4\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
--//注意最後一行,可以發現檔案頭是最後寫入資料檔案的.這樣保證恢復的資料檔案可用.
--//可以看出如果單獨恢復T09表空間要讀整個備份集合,做許多無用功.

4.繼續測試看看T01表空間.
SCOTT@book> alter database datafile 7 offline ;
Database altered.

$ mv T01.dbf T01.dbf-20171129

$ strace  -f  -o /tmp/t01.txt rman target /

RMAN> restore datafile 7;
Starting restore at 2017-11-29 09:55:10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=94 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /mnt/ramdisk/book/T01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/t123456789_m2sknd60_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/t123456789_m2sknd60_1_1 tag=TAG20171128T172624
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2017-11-29 09:55:12

$ grep "pread(258" /tmp/t01.txt | sed -n "s/^.*=//p" | xargs echo | sed 's/ /+/g' | bc -l
53469184

$ grep "pwrite(259" /tmp/t01.txt | sed -n "s/^.*=//p" | xargs echo | sed 's/ /+/g' | bc -l
6299648

$ ls -l /home/oracle/backup/t123456789_m2sknd60_1_1
-rw-r----- 1 oracle oinstall 54591488 2017-11-28 17:26:24 /home/oracle/backup/t123456789_m2sknd60_1_1

$ ls -l /mnt/ramdisk/book/T01.dbf
-rw-r----- 1 oracle oinstall 6299648 2017-11-29 09:55:12 /mnt/ramdisk/book/T01.dbf

--//也是一樣基本讀取備份集檔案.

$ grep "pread(258" /tmp/t01.txt | tail
25016 pread(258, "\6\242\0\0\200\2@\2S\242\215\27\3\0\2\4\374\200\3\0\1\0\0\0\7c\1\0)\242\215\27"..., 1048576, 42991616) = 1048576
25016 pread(258, "\6\242\0\0\200\2\300\2\274\242\215\27\3\0\2\4\364\200\5\0\1\0\0\0\tc\1\0\222\242\215\27"..., 1048576, 44040192) = 1048576
25016 pread(258, "\6\242\0\0\200\2@\3'\243\215\27\3\0\2\4\364\200\7\0\1\0\0\0\vc\1\0\375\242\215\27"..., 1048576, 45088768) = 1048576
25016 pread(258, "\6\242\0\0\200\2\300\1\344\241\215\27\3\0\2\4\vK\1\0\1\0\0\0\5c\1\0\271\241\215\27"..., 1048576, 46137344) = 1048576
25016 pread(258, "\6\242\0\0\200\2\200\2\207\242\215\27\3\0\2\4\267\324\4\0\1\0\0\0\10c\1\0]\242\215\27"..., 1048576, 47185920) = 1048576
25016 pread(258, "\6\242\0\0\200\2\200\3a\243\215\27\3\0\2\4\0277\10\0\1\0\0\0\fc\1\0007\243\215\27"..., 1048576, 48234496) = 1048576
25016 pread(258, "\36\242\0\0\200\0\300\3\376\257\215\27\3\0\1\4\301V\t\0\17\0\0\0\200\0\311\2\0\0\0\0"..., 1048576, 49283072) = 1048576
25016 pread(258, "\6\242\0\0\200\0\300\3r\260\215\27\3\0\2\4h6\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 50331648) = 1048576
25016 pread(258, "\6\242\0\0\200\1\300\3z\260\215\27\3\0\2\4\3717\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 51380224) = 1048576
25016 pread(258, "\6\242\0\0\200\1\300\3|\260\215\27\3\0\2\00497\t\0\1\0\0\0\rc\1\0R\260\215\27"..., 1048576, 52428800) = 1048576
--//仔細看pread,資料量1M,也就是不管是否是需要恢復還是不恢復的,都依次讀取出來.

$ grep "pwrite(259" /tmp/t01.txt | tail
25016 pwrite(259, "\0\242\0\0\1\0\300\1\0\0\0\0\0\0\1\5\301\246\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1040384, 8192) = 1040384
25016 pwrite(259, " \242\0\0\200\0\300\1\345\241\215\27\3\0\1\4\322\325\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 1048576) = 1048576
25016 pwrite(259, " \242\0\0\0\1\300\1\344\241\215\27\3\0\2\4\330\324\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 2097152) = 1048576
25016 pwrite(259, " \242\0\0\200\1\300\1\344\241\215\27\3\0\2\4\332\324\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 3145728) = 1048576
25016 pwrite(259, " \242\0\0\0\2\300\1\344\241\215\27\3\0\2\4\334\324\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 4194304) = 1048576
25016 pwrite(259, " \242\0\0\200\2\300\1\344\241\215\27\3\0\2\4\336\324\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 5242880) = 1048576
25016 pwrite(259, "\0\242\0\0\0\3\300\1\0\0\0\0\0\0\1\5\300\245\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 6291456) = 8192
25016 pwrite(259, "\v\242\0\0\1\0\300\1\0\0\0\0\0\0\1\4\201 \0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
--//看看寫入的過程.

$ man pwrite
PREAD(2)                   Linux Programmer's Manual                  PREAD(2)

NAME
       pread, pwrite - read from or write to a file descriptor at a given offset

SYNOPSIS
       #define _XOPEN_SOURCE 500
       #include <unistd.h>
       ssize_t pread(int fd, void *buf, size_t count, off_t offset);
       ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);

DESCRIPTION
       pread() reads up to count bytes from file descriptor fd at offset offset (from the start of the file) into the
       buffer starting at buf.  The file offset is not changed.

       pwrite() writes up to count bytes from the buffer starting at buf to the file descriptor fd at offset offset.
       The file offset is not changed.

       The file referenced by fd must be capable of seeking.

--//先從偏移8192處,寫1040384/8192=127塊,也就是從檔案頭到點陣圖區資訊.注意os頭實際上不備份(第0塊)是構造出來的.
--//接著連續更新5M的資料塊.
--//從偏移6291456/8192=768塊處,寫8192位元組.也就是最後資料檔案的最後一塊.(^_^,這樣建立的資料檔案浪費1塊)
--//最後在寫資料檔案頭.

SYS@book> recover datafile 7,15;
Media recovery complete.

5.繼續測試備份集合包含4個檔案的情況:
RMAN> backup datafile 7,8,9,10 filesperset 4 format '/home/oracle/backup/t1234_%U';

Starting backup at 2017-11-29 10:21:00
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=94 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=00007 name=/mnt/ramdisk/book/T01.dbf
input datafile file number=00008 name=/mnt/ramdisk/book/T02.dbf
input datafile file number=00009 name=/mnt/ramdisk/book/T03.dbf
input datafile file number=00010 name=/mnt/ramdisk/book/T04.dbf
channel ORA_DISK_1: starting piece 1 at 2017-11-29 10:21:01
channel ORA_DISK_1: finished piece 1 at 2017-11-29 10:21:02
piece handle=/home/oracle/backup/t1234_m6skp8kd_1_1 tag=TAG20171129T102101 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-11-29 10:21:02

Starting Control File and SPFILE Autobackup at 2017-11-29 10:21:02
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_29/o1_mf_s_961323662_f1w6dgt5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-29 10:21:03

$ strings t1234_m6skp8kd_1_1 | egrep "AAAAA|BBBBB|CCCCC|DDDDD|EEEEE|FFFFF|GGGGG|HHHHH" | cut -c11-20 | uniq -c
  20058 AAAAAAAAAA
  20058 BBBBBBBBBB
  20058 CCCCCCCCCC
  20058 DDDDDDDDDD
  21168 AAAAAAAAAA
  21168 BBBBBBBBBB
  21168 CCCCCCCCCC
  21168 DDDDDDDDDD
  21168 AAAAAAAAAA
  21168 BBBBBBBBBB
  21168 CCCCCCCCCC
  21168 DDDDDDDDDD
  21168 AAAAAAAAAA
  21168 BBBBBBBBBB
  21168 CCCCCCCCCC
  21168 DDDDDDDDDD
  16438 AAAAAAAAAA
  16438 BBBBBBBBBB
  16438 CCCCCCCCCC
  16438 DDDDDDDDDD

$ strings t1234_m6skp8kd_1_1 | egrep "AAAAA|BBBBB|CCCCC|DDDDD|EEEEE|FFFFF|GGGGG|HHHHH" | cut -c11-20 | uniq -c | grep "AAAAA"
  20058 AAAAAAAAAA
  21168 AAAAAAAAAA
  21168 AAAAAAAAAA
  21168 AAAAAAAAAA
  16438 AAAAAAAAAA

SELECT    'select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between '
           || TO_CHAR (128 + (ROWNUM - 1) * 128)
           || ' and '
           || TO_CHAR (128 + ROWNUM * 128 - 1)
           || ' ;'
              c100
      FROM DUAL
CONNECT BY LEVEL <= 10;

C100
----------------------------------------------------------------------------------------------------
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 128 and 255 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 256 and 383 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 384 and 511 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 512 and 639 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 640 and 767 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 768 and 895 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 896 and 1023 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 1024 and 1151 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 1152 and 1279 ;
select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 1280 and 1407 ;
10 rows selected.

SCOTT@book> select count(*) from t01 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) between 128 and 255 ;
  COUNT(*)
----------
     20058

--//不再計算,也證明備份集合在4個檔案以內,input memory buffer =1M.
--//僅僅8個資料檔案以上的備份不按照電子文件的介紹,自己要再找1個10G的資料庫測試看看.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2147913/,如需轉載,請註明出處,否則將追究法律責任。

相關文章