[20170411]bbed计算redo检查和.txt

[20170411]bbed计算redo检查和.txt

--前一阵子做测试,需要一个计算器做异或的操作,链接http://blog.itpub.net/267265/viewspace-2134945/
--正好前几天开会遇到熟人,谈起我写的脚本很实用。我说不支持管道操作不是很好,对方讲支持,他自己就是这样用的。

$ cat ~/bin/xor.sh
#! /bin/bash
# just play , calc xor!!

s='0'
for i in $(cat $1| tr 'a-f' 'A-F')
do
    #echo "obase=16;ibase=16; xor($s,$i)"
    echo $i
    [ $i != '0000' ] &&  s=$(echo "obase=16;ibase=16; xor($s,$i)" | bc -l ~/bc/logic.bc)
done
echo -e "\nxor result: $s \n"

--//我再仔细看才明白如果不存在$1,就通过输入来接收数值。也就是执行执行输入参数也可以。

$ xor.sh
5 7
5
7
xor result: 2

$ echo 5 7 | xor.sh
5
7
xor result: 2

--//实际上bbed也可以,自己测试看看。

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

SCOTT@book> alter system dump logfile '/u01/app/oracle/archivelog/book/1_821_896605872.dbf' validate;
System altered.

DUMP OF REDO FROM FILE '/u01/app/oracle/archivelog/book/1_821_896605872.dbf'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=39112=0x98c8, File size=102400=0x19000
    File Number=1, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000821, SCN 0x00031764db63-0x00031764fb91"
thread: 1 nab: 0x39cf seq: 0x00000335 hws: 0x2 eot: 0 dis: 0
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.1764db63 (13277387619) 04/11/2017 08:13:52
Next scn: 0x0003.1764fb91 (13277395857) 04/11/2017 10:02:32
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.1764db63 (13277387619) 04/11/2017 08:13:52
Disk cksum: 0x46d3 Calc cksum: 0x46d3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 1930 blocks
End-of-redo stream : No
Unprotected mode
Miscellaneous flags: 0x800021
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 8
Format ID is 2
redo log key is ae927dbdcfa81f95689f9787f274818
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP

2.通过bbed观察看看:
BBED> set filename '/u01/app/oracle/archivelog/book/1_821_896605872.dbf'
        FILENAME        /u01/app/oracle/archivelog/book/1_821_896605872.dbf

BBED> show all
        FILE#           0
        BLOCK#          1
        OFFSET          0
        DBA             0x00000000 (0 0,1)
        FILENAME        /u01/app/oracle/archivelog/book/1_821_896605872.dbf
        BIFILE          bifile.bbd
        LISTFILE        /home/oracle/bbed/filelist.txt
        BLOCKSIZE       512
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           160
        COUNT           64
        LOGFILE         log.bbd
        SPOOL           Yes
--//blocksize=512,设置也正常。

BBED> set block 1
        BLOCK#          1

BBED> sum
Check value for File 0, Block 1:
current = 0x0000, required = 0x0000

--//很明显不适合block=1的计算,因为在线日志(或者归档日志)的文件头检查和位于偏移14,15字节。
BBED> dump
File: /u01/app/oracle/archivelog/book/1_821_896605872.dbf (0)
Block: 1                                                    Offsets:    0 to   63                                               Dba:0x00000000
------------------------------------------------------------------------------------------------------------------------------------------------
01220000 01000000 35030000 0080d346 00000000 0004200b 6e21b74f 424f4f4b 00000000 c8980000 00900100 00020000 01000200 6ed8b74f 00000000 00000000
<64 bytes per line>

--//偏移14,15 = d346 ,颠倒过来就是46d3.

BBED> set block 2
        BLOCK#          2

BBED> sum
Check value for File 0, Block 2:
current = 0x0060, required = 0x0060

BBED> dump
File: /u01/app/oracle/archivelog/book/1_821_896605872.dbf (0)
Block: 2                                                    Offsets:    0 to   63                                               Dba:0x00000000
------------------------------------------------------------------------------------------------------------------------------------------------
01220000 02000000 35030000 1080431a 60000000 04020300 63db6417 01000000 8402ac58 c26f5917 00000100 01000000 01000000 0a000000 63db6417 03005917
<64 bytes per line>

--//第2块就OK了。

--//另外bbed许多命令无效的,因为结构对不上,oracle当作数据块读取。仅仅dump之类的命令有效。
--//换一句话如果拿bbed来算,需要将偏移14,15字节清0,在计算看看呢?

$ bvi -s 512 -b 512 1_821_896605872.dbf
--//将偏移14,15字节清0.

$ dd if=1_821_896605872.dbf count=1 bs=512 skip=1 2>/dev/null | xxd -c 16 | cut -c10-50 | xor.sh
...
0000

xor result: D346

--//但是很奇怪bbed计算还是0,不知道为什么?

BBED> set block 1
        BLOCK#          1

BBED> sum
Check value for File 0, Block 1:
current = 0x0000, required = 0x0000

BBED> dump
File: /u01/app/oracle/archivelog/book/1_821_896605872.dbf (0)
Block: 1                                                    Offsets:    0 to   63                                               Dba:0x00000000
------------------------------------------------------------------------------------------------------------------------------------------------
01220000 01000000 35030000 00800000 00000000 0004200b 6e21b74f 424f4f4b 00000000 c8980000 00900100 00020000 01000200 6ed8b74f 00000000 00000000
<64 bytes per line>

--//oracle真奇怪,不知道问题在那里????修改回来。

3.在修改Miscellaneous flags: 0x800021看看:

Miscellaneous flags: 0x800021 => 0x800000.

--//使用bvi修改
BBED> set filename '/u01/app/oracle/archivelog/book/1_821_896605872.dbf'
        FILENAME        /u01/app/oracle/archivelog/book/1_821_896605872.dbf

BBED> set block 1
        BLOCK#          1

BBED> sum
Check value for File 0, Block 1:
current = 0x0000, required = 0x0000

BBED> set filename '/u01/app/oracle/archivelog/book/1_821_896605872.dbf'
        FILENAME        /u01/app/oracle/archivelog/book/1_821_896605872.dbf

BBED> set block 1
        BLOCK#          1

BBED> sum
Check value for File 0, Block 1:
current = 0x0000, required = 0x0021
--//这次计算又对了。当然这个不是检查和。

$ echo d346 2100 0000 | xor.sh
D346
2100
0000
xor result: F246

--//修改偏移14,15=F246.

--//验证
SCOTT@book> alter system dump logfile '/u01/app/oracle/archivelog/book/1_821_896605872.dbf' validate;
System altered.

DUMP OF REDO FROM FILE '/u01/app/oracle/archivelog/book/1_821_896605872.dbf'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=39112=0x98c8, File size=102400=0x19000
    File Number=1, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000821, SCN 0x00031764db63-0x00031764fb91"
thread: 1 nab: 0x39cf seq: 0x00000335 hws: 0x2 eot: 0 dis: 0
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.1764db63 (13277387619) 04/11/2017 08:13:52
Next scn: 0x0003.1764fb91 (13277395857) 04/11/2017 10:02:32
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.1764db63 (13277387619) 04/11/2017 08:13:52
Disk cksum: 0x46f2 Calc cksum: 0x46f2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 1930 blocks
End-of-redo stream : No
Unprotected mode
Miscellaneous flags: 0x800000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 8
Format ID is 2
redo log key is ae927dbdcfa81f95689f9787f274818
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP

--//这样oracle认为是在线日志,不是归档文件,无法删除文件,仅仅能从控制文件剔除。

RMAN> delete archivelog sequence 821 ;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=112 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=123 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=134 device type=DISK
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================

Key     Thrd Seq     S Low Time
------- ---- ------- - -------------------
1487    1    821     A 2017-04-11 08:13:52
        Name: /u01/app/oracle/archivelog/book/1_821_896605872.dbf

Do you really want to delete the above objects (enter YES or NO)? yes
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of delete command on ORA_DISK_1 channel at 04/11/2017 10:53:59
ORA-19656: cannot backup, copy, or delete online log /u01/app/oracle/archivelog/book/1_821_896605872.dbf

RMAN> delete force archivelog sequence 821  ;
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=112 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=123 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=134 device type=DISK
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================

Key     Thrd Seq     S Low Time
------- ---- ------- - -------------------
1487    1    821     A 2017-04-11 08:13:52
        Name: /u01/app/oracle/archivelog/book/1_821_896605872.dbf

Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=/u01/app/oracle/archivelog/book/1_821_896605872.dbf RECID=1487 STAMP=941018552
Deleted 1 objects

$ ls -l /u01/app/oracle/archivelog/book/1_821_896605872.dbf
-rw-r----- 1 oracle oinstall 7577088 2017-04-11 10:50:41 /u01/app/oracle/archivelog/book/1_821_896605872.dbf

--//仅仅重复了链接http://blog.itpub.net/267265/viewspace-2135379/的测试。
--//oracle可能出于安全的考虑,实际上并没有删除这个文件.毕竟它认为这个文件是在线日志文件^_^.
--//感觉还是我的脚本简单一些。块1的检查和计算还是存在问题。

时间: 2024-10-30 11:49:02

[20170411]bbed计算redo检查和.txt的相关文章

[20150522]bbed与数据块检查和.txt

[20150522]bbed与数据块检查和.txt --我现在基本拿bbed学习,基本是拿bbed查看,而使用bvi修改数据.我感觉这种方便1写. --实际上使用bbed的好处就是修改数据块检查和不一致,而使用bbed修改很简单仅仅需要执行sum apply就ok了. --对比dbv与bbed确定检查和位置. 1.建立测试环境: SCOTT@test> @ &r/ver1 PORT_STRING                    VERSION        BANNER -------

[20170411]bbed删除记录的恢复.txt

[20170411]bbed删除记录的恢复.txt --//昨天上午做的测试,链接:http://blog.itpub.net/267265/viewspace-2136933/ --//我当时并没有选择恢复记录,仅仅看删除的内容.因为这样恢复是存在许多问题. --//执行 drop function scott.sleep ; 删除sys.source$相关记录仅仅是该命令的一小部分,恢复 --//sys.source$相关记录会存在许多问题,但是如果是应用数据恢复还是可以,实际上以前我的博客

[20160526]bbed修复删除记录.txt

[20160526]bbed修复删除记录.txt --以前也做过,链接: http://blog.itpub.net/267265/viewspace-745944/ --自己当时完全是依葫芦画瓢,许多东西理解不深刻,重新做一次. 1.环境: 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ --------------

[20160405]bbed修改文件头.txt

[20160405]bbed修改文件头.txt --以前做过一次,重复测试: http://blog.itpub.net/267265/viewspace-746222/ 如果数据库数据文件损坏,并且archivelog损坏,这样无法完全恢复,如果仅仅某个数据文件的scn与其他文件不同步,导致该数据文件无法mount. 正常可以像odu之类的工具恢复.但是在实际上如果修改数据文件的scn保持同步,这样数据库可以正常打开,选择常规的方法imp/exp以及expdp/impdp 方式恢复,这样虽然丢

[20170412]bbed隐藏数据记录.txt

[20170412]bbed隐藏数据记录.txt --上午做了bbed恢复修改记录(不等长)的情况,http://blog.itpub.net/267265/viewspace-2137082/ --下午做一个隐藏数据记录的情况,实际上这样做有点多余,就是删除命令,看看bbed是否可以完成. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER --------------------

[20141111]11G redo暴涨.txt

[20141111]11G redo暴涨.txt --新上线生产系统日志出现暴涨,当天达到了400G,正常业务每天7G上下,导致dataguard,备份出现问题,磁盘空间不足 --自己做一些调查: SYS@xxxx> @ ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -----------------------------------

[20160303]显示bbed x命令格式.txt

[20160303]显示bbed x命令格式.txt --使用bbed显示数据信息时要选对类型,随手写一个脚本 prompt PROMPT DISPLAY BBED EXAMINE(X) FORMAT prompt SELECT REPLACE (wmsys.wm_concat (c1), ',') c80   FROM (  SELECT data_type                 ,column_name                 ,DECODE                

[20160405]bbed的assign命令.txt

[20160405]bbed的assign命令.txt --我记得开始学习bbed的时候,看的是一份pdf文档,提到assign的用法,摘要如下: assign The assign command does symbolic assignment, with type and range checking. Either target or source can be omitted for the current offset.  For example, the following com

[20170308]关于redo dump.txt

[20170308]关于redo dump.txt --//前一阵子在探究是否可以备库的备用日志来恢复主库,当主库在线日志丢失的情况下.遇到一些问题. DUMP OF REDO FROM FILE '/mnt/ramdisk/book/redo01.log' Opcodes *.* RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff SCNs: scn: 0x0000.00000000 thru scn: 0xffff.fffff