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

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: [20170411]bbed计算redo检查和.txt --前一阵子做测试,需要一个计算器做异或的操作,链接http://blog.itpub.net/267265/viewspace-2134945/ --正好前几天开会遇到熟人,谈起我写的脚本很实用。

[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的检查和计算还是存在问题。

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
|
Oracle 关系型数据库 数据库管理
|
Oracle 关系型数据库 数据库
[20180604]在内存修改数据(bbed).txt
[20180604]在内存修改数据(bbed).txt --//以前曾经做过在内存修改数据,通过oradebug poke命令修改内存信息,相关链接: --//http://blog.itpub.net/267265/viewspace-2124466/=>[20160904]在内存修改数据.txt --//今天测试看看是否通过bbed修改数据信息的情况.使用asmm,这样/dev/shm可以看到一个一个文件。
1101 0
|
Oracle 关系型数据库 数据库管理
[20170419]bbed探究数据块.txt
[20170419]bbed探究数据块.txt --//bbed 是一个瑞士军刀,也是了解oracle内部数据块结构的好工具。我自己开始使用基本是看别人的帖子,对oracle数据块的内部也不是很了解。
1052 0
|
数据库管理
[20170411]bbed删除记录的恢复.txt
[20170411]bbed删除记录的恢复.txt --//昨天上午做的测试,链接:http://blog.itpub.net/267265/viewspace-2136933/ --//我当时并没有选择恢复记录,仅仅看删除的内容.
1045 0
|
Oracle 关系型数据库 数据库
[20170302]异常恢复scn到那里3.txt
[20170302]异常恢复scn到那里3.txt --//如果oracle数据库异常关闭,打开数据库自动执行实例恢复,这个恢复scn到那里呢? --//通过例子说明:实际上http://blog.
936 0
|
Oracle 关系型数据库 测试技术
[20160816]11G dataguard坏块修复.txt
[20160816]11G dataguard坏块修复.txt --11GR2 不仅仅支持在备库在只读的情况下,日志应用(ACTIVE Data Guard),还提供主备库的坏块修复.
1053 0
|
数据库管理
[20160526]bbed修复删除记录.txt
[20160526]bbed修复删除记录.txt --以前也做过,链接: http://blog.itpub.net/267265/viewspace-745944/ --自己当时完全是依葫芦画瓢,许多东西理解不深刻,重新做一次.
933 0
|
Oracle 关系型数据库 数据库
[20160413利用bbed修改跳过损坏的索引.txt
[20160413利用bbed修改跳过损坏的索引.txt --前一阵子做过利用bbed修改跳过损坏的索引,这次测试看看破坏索引SYS.I_OBJ1看看. 1.环境: SYS@book> @ &r/ver1 PORT_STRING             ...
1017 0
|
SQL Oracle 关系型数据库
[20160406] 恢复until scn NNN.txt
[20160406] 恢复until scn NNN.txt --昨天别人问的问题,如果使用rman恢复,restore database until scn NNN;是恢复到NNN,还是NNN-1.
841 0
|
关系型数据库 测试技术 数据库
[20160405]利用bbed修改跳过损坏的索引.txt
[20160405]利用bbed修改跳过损坏的索引.txt --oracle的启动通过system的第一块的rdba(kcvfhrdb) http://blog.itpub.
906 0