[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的数据库测试看看.