[20171130]关于rman备份疑问.txt

--//前面测试太乱,重新做一些rman as copy相关测试.

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 SUGAR DATAFILE
  '/mnt/ramdisk/book/sugar01.dbf' SIZE 6M AUTOEXTEND OFF
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

create table t1 tablespace sugar as select rownum id ,lpad('A',32,'A') name from dual connect by level<=1e5;
alter system checkpoint ;

RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 128 K;
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 128 K;
new RMAN configuration parameters are successfully stored
--//主要目的减慢备份速度。

2.测试1:
--//测试脚本:
$ cat t1.sh
#! /bin/bash
rman target / <<EOF  >> /tmp/t1.txt &
backup as copy datafile 7 format '/home/oracle/backup/%b_1' ;
#backup  datafile 7 format '/home/oracle/backup/sugar01.dbf_1_%U' ;
quit
EOF
echo "sleep $1  "
sleep $1
sqlplus -s scott/book <<EOF
set numw 12
update t1 set name=lpad('B',32,'B') where mod(id,2)=1;
commit;
alter system checkpoint;
alter system checkpoint;
alter system checkpoint;
alter system checkpoint;
select dbms_flashback.get_system_change_number,sysdate from dual;
host strings /mnt/ramdisk/book/sugar01.dbf | grep "BBBB" |wc
EOF

$ . t1.sh 6
sleep 6
50000 rows updated.
Commit complete.
System altered.
System altered.
System altered.
System altered.

GET_SYSTEM_CHANGE_NUMBER SYSDATE
------------------------ -------------------
             13280180133 2017-11-29 16:37:08
  50000   84680 1811356

SCOTT@book> select rowid,ora_rowscn from t1 where rownum=1;
ROWID                ORA_ROWSCN
------------------ ------------
AAAWM5AAHAAAACDAAA  13280180120

SCOTT@book> select file#,CHECKPOINT_CHANGE#,ABSOLUTE_FUZZY_CHANGE# from v$datafile_copy order by 2 ;
FILE# CHECKPOINT_CHANGE# ABSOLUTE_FUZZY_CHANGE#
----- ------------------ ----------------------
    7        13280180084                      0

RMAN> list copy of database;

using target database control file instead of recovery catalog
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
76      7    A 2017-11-29 16:37:54 13280180084 2017-11-29 16:37:06
        Name: /home/oracle/backup/sugar01.dbf_1
        Tag: TAG20171129T163706

$ strings sugar01.dbf_1 | grep "AAAA"|wc
 100000  170040 3624077
$ strings sugar01.dbf_1 | grep "BBBB"|wc
      0       0       0
        
--//文件头scn=13280180084开始备份,而过了6秒,我修改一部分数据(提交scn=13280180120),这个时候还没读到相应表T1段.
--//为什么写入备份image的没有BBBB信息呢?我当时做测试非常不理解..........

3.从电子文档<Oracle RMAN 11g Backup and Recovery.pdf>中发现如下内容:

--//链接:http://blog.itpub.net/267265/viewspace-2147878/

作者: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.
   ...

--//我仔细阅读文档,对于备份1个数据文件,按照介绍,数据块先导入PGA(我感觉这里就进入input buffer),"处理"后放入output buffer,
--//如果output buffer满了,写出到备份文件对应位置.

--//换一句话讲,如果数据块已经读入PGA,即使在相应数据块发生DML,oracle也不会再重读数据文件.只有这样,才可能出现我前面备份的
--//情况.4M的位置已经可以排除(因为我前面设置数据文件大小6M),这样剩下应该出现在16M开始的位置.

CREATE TABLESPACE SUGAR DATAFILE
  '/mnt/ramdisk/book/sugar01.dbf' SIZE 21M AUTOEXTEND OFF
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

create table t1 tablespace sugar as select rownum id ,lpad('A',32,'A') name from dual connect by level<=4e5;

SCOTT@book> select sum(bytes) from dba_extents where segment_name='T1';
SUM(BYTES)
----------
  19922944

--//占19922944/1024/1024= 19M.

$ . t1.sh 6
sleep 6
200000 rows updated.
Commit complete.
System altered.
System altered.
System altered.
System altered.
GET_SYSTEM_CHANGE_NUMBER SYSDATE
------------------------ -------------------
             13280219948 2017-11-30 10:49:13

200000  339280 7260120

--//等备份完成:
Starting backup at 2017-11-30 10:49:08
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 copy
input datafile file number=00007 name=/mnt/ramdisk/book/sugar01.dbf
output file name=/home/oracle/backup/sugar01.dbf_1 tag=TAG20171130T104908 RECID=85 STAMP=961411917
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:55
channel ORA_DISK_1: throttle time: 0:02:48
Finished backup at 2017-11-30 10:52:04
Starting Control File and SPFILE Autobackup at 2017-11-30 10:52:04
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_30/o1_mf_s_961411924_f1ywln5x_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-30 10:52:05

SCOTT@book> column name format a50
SCOTT@book> select recid,file#,NAME,CHECKPOINT_CHANGE#,ABSOLUTE_FUZZY_CHANGE# from v$datafile_copy where recid=85 ;
       RECID        FILE# NAME                                               CHECKPOINT_CHANGE# ABSOLUTE_FUZZY_CHANGE#
------------ ------------ -------------------------------------------------- ------------------ ----------------------
          85            7 /home/oracle/backup/sugar01.dbf_1                         13280219895            13280219934
--//最高块scn=13280219934,应该备份有BBBB信息.

SCOTT@book> select rowid,ora_rowscn from t1 where rownum=1;
ROWID                ORA_ROWSCN
------------------ ------------
AAAWNaAAHAAAACDAAA  13280219933

$ strings -t d sugar01.dbf_1 | grep "AAAAA" |wc
 358205  968151 16037238
$ strings -t d sugar01.dbf_1 | grep "BBBBBB" |wc
  41795  113154 1909462

--//哈哈,终于出现,现在验证是否在数据文件16M的位置最早出现BBBBB.

$ strings -t d sugar01.dbf_1 | grep "BBBBBB" |head
16794947  BN BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795029  BL BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795111  BJ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795193  BH BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795275  BF BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795357  BD BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795439  BB BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795521  B@ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795603  B> BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
16795685  B< BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,

--//16794947/8192=2050.1644287109375,在块2050位置.在偏移0.1644287109375*8192=1347处出现.

SCOTT@book> select 2050*8192/1024/1024 from dual ;
2050*8192/1024/1024
-------------------
          16.015625

--//就是大约在16M的位置.
--//0.015625*1024*1024=16384.还差2块(数据块大小8192),我推测OS头,文件头读取(但是不进入input buffer),因为这个是构造出来,
--//说明:如果做备份集备份,是找不到OS头备份的.而文件头实际上是最后写入备份文件的.
--//基本在16M位置.验证我的判断应该是正确的.

--//更正前面的判断:
SCOTT@book> alter system dump datafile '/mnt/ramdisk/book/sugar01.dbf' block 2048;
System altered.

SCOTT@book> alter system dump datafile '/mnt/ramdisk/book/sugar01.dbf' block 2049;
System altered.

Dump all the blocks in range:
buffer tsn: 8 rdba: 0x01c00800 (7/2048)
scn: 0x0003.17719599 seq: 0x02 flg: 0x04 tail: 0x95992002
frmt: 0x02 chkval: 0x8a65 type: 0x20=FIRST LEVEL BITMAP BLOCK
Hex dump of block: st=0, typ_found=1
...
Dump all the blocks in range:
buffer tsn: 8 rdba: 0x01c00801 (7/2049)
scn: 0x0003.17719599 seq: 0x02 flg: 0x04 tail: 0x95992002
frmt: 0x02 chkval: 0x8a27 type: 0x20=FIRST LEVEL BITMAP BLOCK
Hex dump of block: st=0, typ_found=1

--//dba 7,2048 7,2049是FIRST LEVEL BITMAP BLOCK.里面没有BBBB信息.应该缓存的是前面16M的信息.分析有错.
--//如果分析strace跟踪文件也可以发现:
$ grep "pwrite(259" /tmp/tt1.txt
49454 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
49454 pwrite(259, " \242\0\0\200\0\300\1\231\225q\27\3\0\4\4C\213\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 1048576) = 1048576
49454 pwrite(259, " \242\0\0\0\1\300\1\231\225q\27\3\0\2\4I\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 2097152) = 1048576
49454 pwrite(259, " \242\0\0\200\1\300\1\231\225q\27\3\0\2\4K\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 3145728) = 1048576
49454 pwrite(259, " \242\0\0\0\2\300\1\231\225q\27\3\0\2\4M\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 4194304) = 1048576
49454 pwrite(259, " \242\0\0\200\2\300\1\231\225q\27\3\0\2\4O\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 5242880) = 1048576
49454 pwrite(259, " \242\0\0\0\3\300\1\231\225q\27\3\0\2\4Q\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 6291456) = 1048576
49454 pwrite(259, " \242\0\0\200\3\300\1\231\225q\27\3\0\2\4S\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 7340032) = 1048576
49454 pwrite(259, " \242\0\0\0\4\300\1\231\225q\27\3\0\2\4U\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 8388608) = 1048576
49454 pwrite(259, " \242\0\0\200\4\300\1\231\225q\27\3\0\2\4W\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 9437184) = 1048576
49454 pwrite(259, " \242\0\0\0\5\300\1\231\225q\27\3\0\2\4Y\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 10485760) = 1048576
49454 pwrite(259, " \242\0\0\200\5\300\1\231\225q\27\3\0\2\4[\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 11534336) = 1048576
49454 pwrite(259, " \242\0\0\0\6\300\1\231\225q\27\3\0\2\4]\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 12582912) = 1048576
49454 pwrite(259, " \242\0\0\200\6\300\1\231\225q\27\3\0\2\4_\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 13631488) = 1048576
49454 pwrite(259, " \242\0\0\0\7\300\1\231\225q\27\3\0\2\4a\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 14680064) = 1048576
49454 pwrite(259, " \242\0\0\200\7\300\1\231\225q\27\3\0\2\4c\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 15728640) = 1048576
49454 pwrite(259, " \242\0\0\0\10\300\1\231\225q\27\3\0\2\4e\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 16777216) = 1048576
49454 pwrite(259, " \242\0\0\200\10\300\1\231\225q\27\3\0\2\4g\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 17825792) = 1048576
49454 pwrite(259, " \242\0\0\0\t\300\1\231\225q\27\3\0\2\4i\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 18874368) = 1048576
49454 pwrite(259, " \242\0\0\200\t\300\1\231\225q\27\3\0\2\4k\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 19922944) = 1048576
49454 pwrite(259, "\0\242\0\0\0\n\300\1\0\0\0\0\0\0\1\5\300\254\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576, 20971520) = 1048576
49454 pwrite(259, "\0\242\0\0\200\n\300\1\0\0\0\0\0\0\1\5@\254\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 22020096) = 8192
49454 pwrite(259, "\v\242\0\0\1\0\300\1\0\0\0\0\0\0\1\4l/\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192

--//仔细看pwrite写出的偏移都是对齐1M的整数倍偏移,除了第1个,最后2个调用.
--//第1个实际上写入1040384/8192=127块,从8192偏移,就是写入文件头以及位图区信息.
--//最后1个实际上重写文件头.

BBED> x /rnc filename "/home/oracle/backup/sugar01.dbf_1" block 2050 *kdbr[166]
rowdata[41]                                 @1342
-----------
flag@1342: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@1343: 0x02
cols@1344:    2

col    0[4] @1345: 316577
col   1[32] @1350: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
--//偏移1350,如果注意看前面strings输出前面还有3个字符,这样就能对山了.
--//顺便说一下:定义字段name的长度32,这样长度指示器正好对应的ascii是空格.

--//感觉单个数据文件备份,会全部使用16M的内存作为input buffer,只有这样才能解析前面的测试.

SCOTT@book> select count(*) from t1 where DBMS_ROWID.ROWID_BLOCK_NUMBER (rowid) >=2050 and name=LPAD('B',32,'B');
    COUNT(*)
------------
       41795

--//也与查询备份image的结果一致.
$ strings -t d sugar01.dbf_1 | grep "BBBBBB" |wc
  41795  113154 1909462

--//终于把自己的困惑解开....以后不再做这样测试,累..
--//感觉自己在测试方法,工具选择上存在问题.比如最后将文件头写入备份映像的测试,实际上只要strace跟踪就更好一些.

[20171130]关于rman备份疑问.txt的更多相关文章

  1. [20190510]rman备份的疑问8.txt

    [20190510]rman备份的疑问8.txt --//上午测试rman备份多个文件,探究input memory buffer 的问题.--//补充测试5个文件的情况.--//http://blo ...

  2. [20190510]rman备份的疑问7.txt

    [20190510]rman备份的疑问7.txt --//上午测试rman备份时备份文件大小回缩的测试.链接:--//http://blog.itpub.net/267265/viewspace-26 ...

  3. [20190509]rman备份的疑问5.txt

    [20190509]rman备份的疑问5.txt --//别人跟我提到的rman备份问题,我开始以为是assm与mssm的问题,实际测试情况不是.--//开始备份时生成的备份集文件很大,以后会回缩(对 ...

  4. [20171206]rman与truncate.txt

    [20171206]rman与truncate.txt --//昨天下班在回家的路上,突然想起以前遇到的问题,就是truncate表后,rman做备份时会备份多少truncate表的信息,--//当时 ...

  5. RMAN备份归档日志ORA-19575

    RMAN备份归档日志ORA-19575 一.问题描述 1)环境oracle 10g; 2)报错现象RMAN进行备份归档报错失败ORA-19575 二.问题处理 1)根据客户说明的现象,百度了一波(详见 ...

  6. [20190517]rman tape compressed.txt

    [20190517]rman tape compressed.txt --//前一段测试rman选择压缩备份时,如果备份单个数据文件小于64M-3*8K时,先建立大小64M文件,最后会回收到自己的备份 ...

  7. 记录一则RMAN备份策略修正案例

    背景:在给某客户处理问题时,发现客户数据库的备份空间即将用尽,进一步查看发现是用户数据库的当前RMAN备份策略存在潜在问题,需要修改备份策略. 环境:SunOS 5.10 + Oracle 11.2. ...

  8. oracle数据库rman备份计划及恢复

    1.rman完全恢复的前提条件:历史的datafile,controlfile和spfile备份,加上完整的archivelog和完好的redolog. 2.rman备份脚本: a.RMAN 0级备份 ...

  9. RMAN备份失败之:mount: block device /dev/emcpowerc1 is write-protected, mounting read-only

    今天再做巡检的时候发现有一台服务器的RMAN备份不正常,有一段时间没能正常备份了.检查了一下脚本,正常,定时任务列表也正常,再检查一下/var/log/cron的内容,也没有问题.尝试在该挂载点上创建 ...

随机推荐

  1. hdu 6161--Big binary tree(思维--压缩空间)

    题目链接 Problem Description You are given a complete binary tree with n nodes. The root node is numbere ...

  2. c++为什么要面向对象?

    前言 c和c++的区别是什么?不可置否,最重要的就是c++的编程思想是面向对象,而c的编程思想是面向过程,这是它们的本质区别,如果你在使用c++编程时使用的还是面向过程的编程思想,那么还不如使用c,因 ...

  3. Python之unittest测试代码

    前言 编写函数或者类时,还可以为其编写测试.通过测试,可确定代码面对各种输入都能够按要求的那样工作. 本次我将介绍如何使用Python模块unittest中的工具来测试代码. 测试函数 首先我们先编写 ...

  4. 接口自动化思路_JAVA

    写在开头: 技术渣做接口自动化,大神们请轻喷!多提提优化方案和问题点. 以前做接口测试一直通过postman 和 soapUI来做,Postman 是Chrome的一个插件Case多了不好管理,同时执 ...

  5. Java连接Mysql数据库警告: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established

    详细错误: Establishing SSL connection without server's identity verification is not recommended. Accordi ...

  6. 以ActiveMQ为例JAVA消息中间件学习【4】——消息中间件实际应用场景

    前言 当前真正学习消息中间件,当前已经走到了,可以简单的使用,网上有很多那种复杂的高可用的架构,但是那些都是对于一些比较大型的项目来说的. 对于一些小型的项目可能用不到那么大的架构,于是我们需要从最简 ...

  7. Django | 模型类变更后生成迁移文件,报错:You are trying to add a non-nullable field 'BookName' to BookInfo without a default....

    报错: You are trying to add a non-nullable field 'BookName' to BookInfo without a default; we can't do ...

  8. Angular2入门:TypeScript的函数 - 函数定义、可选参数、默认参数和函数重载

  9. Java设计模式学习记录-装饰模式

    前言 装饰模式也是一种结构型模式,主要是目的是相对于类与类之间的继承关系来说,使用装饰模式可以降低耦合度.JDK中有不少地方都使用到了装饰模式,例如Java的各种I/O流,javax.swing包中一 ...

  10. 一张图读懂PBN旁切转弯计算

    当DOC8168进入PBN章节以后,所有的保护区不再标注风螺旋的字母位置点.似乎ICAO已经有了精确计算的方法,只是没有告诉我们.沿着风螺旋的轨迹一路走来,切线与角度的换算方法想必已经相当熟悉了吧,这 ...