[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.dbf
-rw-r----- 1 oracle oinstall 43M 2017-03-08 15:56:59 0001_0000051935_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-01-24 09:01:13 0001_0000051406_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-01-17 23:03:54 0001_0000051326_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-02-03 09:04:49 0001_0000051495_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-02-13 17:54:24 0001_0000051631_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-01-11 09:01:24 0001_0000051242_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-02-16 09:34:58 0001_0000051668_628034536.dbf
-rw-r----- 1 oracle oinstall 42M 2017-01-11 23:00:25 0001_0000051250_628034536.dbf
--//这样看看这些没有写入日志的数据块情况:
--//看看49M这个位置开始的情况.
1.环境:
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.
--// 拿/mnt/ramdisk/book/redo02.log 分析.
--// 49m 位于49*1024*1024=51380224 49*1024*1024/512=100352块位置.
2.探究:
$ xxd -c 16 -seek 51380224 -l 512 -a /mnt/ramdisk/book/redo02.log
3100000: 0122 0000 0088 0100 0000 0000 0080 002a ...............*
3100010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
31001f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
--//可以发现仅仅前面16字节由信息,实际上这个就是日志日志块的header为16bytes.
$ xxd -c 16 -seek 51380224 -l 512 -a /mnt/ramdisk/book/redo01.log
3100000: 0122 0000 0088 0100 0000 0000 0080 002a ...............*
3100010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
31001f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
$ xxd -c 16 -seek 51380224 -l 512 -a /mnt/ramdisk/book/redo03.log
3100000: 0122 0000 0088 0100 0000 0000 0080 002a ...............*
3100010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
31001f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
$ xxd -c 16 -seek 51380224 -l 512 -a /mnt/ramdisk/book/redo03.log |md5sum
05820513d808b3517ff90a57f093ac82 -
$ xxd -c 16 -seek 51380224 -l 512 -a /mnt/ramdisk/book/redo02.log |md5sum
05820513d808b3517ff90a57f093ac82 -
$ xxd -c 16 -seek 51380224 -l 512 -a /mnt/ramdisk/book/redo01.log |md5sum
05820513d808b3517ff90a57f093ac82 -
--//说明位置一样对于"空白"内容是一样的,而且里面不可能有group#号信息.这样完全可以从一个好的日志文件尾部来合并归档文件来建立
--//一个好的日志文件.从而欺骗oracle.
--//继续探究这16字节内容:
--//偏移0x14-0x15 是检查和.前面测试已经说明.
49*1024*1024=51380224
49*1024*1024/512=100352
100352 = 0x18800
3100000: 0122 0000 0088 0100 0000 0000 0080 002a ...............*
~~~~~~~~~
--//4个字节颠倒 0001 8800,顺便复习使用od查看(各种命令参数不同意,烦!!,注4个字节我对调显示):
$ od -j 51380224 -N 512 -t x4 /mnt/ramdisk/book/redo02.log
304000000 00002201 00018800 00000000 2a008000
304000020 00000000 00000000 00000000 00000000
*
304001000
--//也就是第4-7偏移表示块地址.