[20170309]关于在线日志与归档1.txt

[20170309]关于在线日志与归档1.txt

--//当日志写满了,或者执行手工了切换,再或者rman备份时有时也会触发日志切换:
alter system switch logfile ;
alter system archive log current ;

--//本文简单探究日志归档是如何保存的.先探查os块.

1.环境:
--//启动到mount状态.

SYS@book> @ &r/ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> @ &r/logfile
GROUP# STATUS     TYPE       MEMBER                          IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- ------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log    NO       1       1       695    52428800       512       1 YES INACTIVE     13276910949 2017-02-28 14:40:12  13276931102 2017-03-09 10:01:48
     2            ONLINE     /mnt/ramdisk/book/redo02.log    NO       2       1       696    52428800       512       1 YES INACTIVE     13276931102 2017-03-09 10:01:48  13276931986 2017-03-09 10:02:36
     3            ONLINE     /mnt/ramdisk/book/redo03.log    NO       3       1       697    52428800       512       1 NO  CURRENT      13276931986 2017-03-09 10:02:36 2.814750E+14
     4            STANDBY    /mnt/ramdisk/book/redostb01.log NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log NO
7 rows selected.

--//仅仅拿seq#=696 来研究.

$ ls -l /mnt/ramdisk/book/redo02.log /u01/app/oracle/archivelog/book/1_696_896605872.dbf
-rw-r----- 1 oracle oinstall 52429312 2017-03-09 10:02:36 /mnt/ramdisk/book/redo02.log
-rw-r----- 1 oracle oinstall  1626112 2017-03-09 10:02:38 /u01/app/oracle/archivelog/book/1_696_896605872.dbf

--//可以发现2者大小不一样.你可以观察基本不会写满50M,大约4XM就会发生日志切换.
--//我以前oracle在归档时会删除一些类似空洞的空间,从而减少归档大小.拿这两个文件做一些简单探究:

2.首先探究日志文件的OS块:
--//oracle不管数据文件还是日志文件,第0块都是OS块,大小与块大小有关,日志一般块大小512字节.
--//所以从os角度看,建立50M的日志文件,实际大小是50M+512字节.
--//首先检查是否可以倍512整除.
52429312/512=102401 = 0x19001 (不包括OS块 是 0x19000)
1626112/512= 3176 = 0xc68    (不包括OS块  是 0xc67)

--然后对比前面的字节是否一样.
$ dd if=/mnt/ramdisk/book/redo02.log bs=512 count=3176 2>/dev/null | md5sum
812745bc5d7da07bcfa11e578b949226  -

$ md5sum /u01/app/oracle/archivelog/book/1_696_896605872.dbf
3e197986a3dfd1c392e052a14400d4c1  /u01/app/oracle/archivelog/book/1_696_896605872.dbf
--//可以发现不一样.也就是oracle日志转储归档时,不是简单的拷贝操作.

$ dd if=/mnt/ramdisk/book/redo02.log bs=512 count=1  | xxd -c 16 >| r0.txt
$ dd if=/u01/app/oracle/archivelog/book/1_696_896605872.dbf bs=512 count=1 | xxd -c 16 > d0.txt

$ diff  r0.txt d0.txt
2c2
< 0000010: 67c8 0000 0002 0000 0090 0100 7d7c 7b7a  g?.........}|{z
---
> 0000010: 0154 0000 0002 0000 670c 0000 7d7c 7b7a  .T......g...}|{z

--// 7d7c7b7a 有看到熟悉的东西,数据文件的OS块也能看到一样的信息.}
--//你可以看出偏移0x18~0x1B处 在线日志是0090 0100 =>如果4个字节颠倒 00019000 这里就是日志块数量(不包括OS块).
                              备用日志是670c 0000 =>如果4个字节颠倒 00000c67 这里就是日志块数量(不包括OS块).
--//与前面的计算数量一致.

--//但是前面的67c8 ,0154 表示什么呢? 很自然的猜想检查和(因为数据库(8k数据块大小),这个位置就是检查和.例子:
BBED> p dba 4,135 chkval_kcbh
ub2 chkval_kcbh                             @16       0xe273

--//可以猜测这个位置也是检查和.做一个证明看看.

3.取出计算:
$ cut -c10-50 r0.txt >| aa1.txt
...
0000
0000
xor result: 0

$ cut -c10-50 d0.txt >| aa1.txt
0000
0000
xor result: 0

--//异或的结果都是0,说明oracle在归档时OS块在偏移0x18~0x1B处写入块归档的数量(不包括OS块),然后在0x10-0x11处计算检查和.

--//转载一个链接,我认为分析比较仔细的:http://www.ludatou.com/?p=1334

在ue打开的16进制中每行是16bytes,一共32行,这为第一个块file header block.这个block包含的信息有限,逐一分析:

$ bvi80 -s 512 -b 0 /mnt/ramdisk/book/redo02.log
00000000  00 22 00 00 00 00 C0 FF 00 00 00 00 00 00 00 00 ................
00000010  67 C8 00 00 00 02 00 00 00 90 01 00 7D 7C 7B 7A g...........}|{z
00000020  A0 81 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000040  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000050  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000070  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000080  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000090  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000C0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000120  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000130  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000140  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000150  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000170  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001C0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000200
--//注:这里是我测试机器上的redo文件}

从第一个字节开始到第二个字节为0x22,这2个字节通常为oracle 文件类型的标识,像数据文件的开头这里就为0xA2,这里的0x22就代表
redo log file.接着下来第一行就没有有意义的东西了其中的0xFFC0应该和scn中的base部分有关.再看看第二行的16个字节,可以发现在
第21和22字节0x0200换算成10进制格式则为512,这里即代表block size.从第25到28字节0x00019000换算成10进制后为102400,而
0x00019000代表redo block的数量,这里即为代表这个file的blocks或者理解为这个file的size.而在后续跟着的0x7a7b7c7d为文件标识符
,为oracle快速识别文件的一种标识.到这之后第一个块的信息就没啦!

--//实际上如果后面00的地方修改任意字符,使用
SYS@book> alter system dump logfile '/u01/app/oracle/archivelog/book/1_696_896605872.dbf' validate;
System altered.

--//oracle并不报错.

时间: 2024-09-22 11:41:42

[20170309]关于在线日志与归档1.txt的相关文章

[20170309]关于在线日志与归档2.txt

[20170309]关于在线日志与归档2.txt --//当日志写满了,或者执行手工了切换,再或者rman备份时有时也会触发日志切换: alter system switch logfile ; alter system archive log current ; --//本文简单探究日志归档是如何保存的.探查日志文件头块. 1.环境: --//启动到mount状态. SYS@book> @ &r/ver BANNER ------------------------------------

[20170310]关于在线日志与归档4.txt

[20170310]关于在线日志与归档4.txt --//如果你顺便看归档日志目录,在线日志50M,你可以发现最大归档43M上下.也就是在线日志大于45M后面这些块基本不会写入日志记录信息. --//比如查询如下: #  ls -l -S -h /data/log/ORCL/archivelog/| head -10 total 27G -rw-r----- 1 oracle oinstall  43M 2017-03-02 10:53:07 0001_0000051850_628034536.

[20170309]dg环境下在线日志损坏13.txt

[20170309]dg环境下在线日志损坏13.txt http://blog.itpub.net/267265/viewspace-2134665/ http://blog.itpub.net/267265/viewspace-2134481/ --//按照如下链接,拷贝备用日志到主库,修改文件头偏移0x230 日志组号.以及hws,eot对应位置,欺骗oracle是正常的日志文件. http://blog.itpub.net/267265/viewspace-2134816/ --//看了一

[20170307]dg环境下在线日志损坏12.txt

[20170307]dg环境下在线日志损坏12.txt http://blog.itpub.net/267265/viewspace-2134665/ http://blog.itpub.net/267265/viewspace-2134481/ --//前面的链接我测试了如果日志实时传输与应用的情况下,主库的崩溃并且在线日志删除的情况下(包括主机的备用日志)情况下, --//利用备库接收日志来恢复主库的情况.做一点点总结: 1.将备用日志拷贝过来,必须执行如下命令,加入最后应用的scn号. r

[20170303]dg环境下在线日志损坏8.txt

[20170303]dg环境下在线日志损坏8.txt --前面的测试,链接http://blog.itpub.net/267265/viewspace-2134481/ --前面的测试必须使用recover database using backup controlfile until change 13276911099; 才能恢复到结尾. --但是由于主备库scn相差1,在open resetlog时备库的数据文件头scn号减1,采用应用日志. --前面学习了解文件头fuzzy特性以及具体位

[20160830]清除日志与跟踪文件.txt

[20160830]清除日志与跟踪文件.txt --我们数据库的dataguard磁盘空间非常紧张,前几天因为一些异常业务操作,导致dataguard磁盘空间不足, --日志切换情况: Date                Day    Total   H0   h1   h2   h3   h4   h5   h6   h7   h8   h9  h10  h11  h12  h13  h14  h15  h16  h17  h18  h19  h20  h21  h22  h23    

ORA-16038的解决(日志无法归档)

ORA-16038的解决 数据库装载完毕. ORA-16038: 日志 3 序列号 5035 无法归档 ORA-19809: 超出了恢复文件数的限制 ORA-00312: 联机日志 3 线程 1: ......REDO03.LOG' DB是归档模式, 每个日志组只有一个文件(新太公司的人通常使用的方法,FT), 没办法, 搜寻文档和晚上的资料, 有如下的解决方法: 损坏非当前联机日志: 1.启动数据库,遇到ORA-00312 or ORA-00313错误,如: ORA-00313: open f

DELETE OBSOLETE不删除归档日志以及归档的备份集

今天遇到一个奇怪的事情,使用OBSOLETE不删除归档日志,而且也不删除过期的归档的BACKUP SET 从delete obsolete的概念来看如下: The REPORT OBSOLETE and DELETE OBSOLETE commands work in two steps:                                                                                                         

RAC Ora-27054 导致使用NFS的日志不能归档

日志错误如下 WARNING:NFS file system /archive mounted with incorrect optionsWARNING:Expected NFS mount options: rsize>=16384,wsize>=16384,hard,noac/actimeo=0Sat Sep 22 18:29:43 2012Errors in file /home/oracle/product/admin/rac/udump/rac1_ora_23076.trc:ORA