[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的檢查和計算還是存在問題。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2137010/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20150522]bbed與資料塊檢查和.txt
- [20150527]bbed與資料塊檢查和2.txt
- SQLServer的檢查點、redo和undoSQLServer
- [20160223]檢查redo日誌的完整性.txt
- 【TUNE_ORACLE】Oracle檢查點(四)檢查點對redo日誌的影響和redo日誌大小設定建議Oracle
- Oracle redo解析之-2、BBED & DUMP工具使用Oracle Redo
- Oracle redo解析之-1、oracle redo log結構計算Oracle Redo
- MySQL如何計算統計redo log大小MySql
- [20170803]如何檢視dg的redo應用率.txt
- [20141008]使用bbed檢視索引結構.txt索引
- [20180306]資料塊檢查和.txt
- [20130527]估計redo檔案的大小.txt
- Oracle redo解析之-4、rowid的計算Oracle Redo
- 轉roger大師_計算sql語句產生的redo和undo大小SQL
- 全域性檢查點和增量檢查點
- [20170419]bbed探究資料塊.txt
- [20160405]bbed的assign命令.txt
- [20160405]bbed修改檔案頭.txt
- [20160529]windows下使用bbed.txtWindows
- [20180306]資料塊檢查和2.txt
- 全域性檢查點和增量檢查點(zt)
- [20210906]bbed讀取資料塊(bbed-wrap.sh).txt
- How to 計算當前redo日誌的使用率
- Oracle完全檢查點和增量檢查點詳解Oracle
- [20150929]檢查資料塊.txt
- [20150308]熱備份和資料庫檢查點.txt資料庫
- python 計算txt文字詞頻率Python
- 檢查REDO日誌相關資訊並生成HTML檔案的指令碼HTML指令碼
- [20210304]bbed的assign命令.txt
- [20170412]bbed隱藏資料記錄.txt
- [20160303]顯示bbed x命令格式.txt
- [20170515]檢查資料庫scn指令碼.txt資料庫指令碼
- in list查詢計算cost
- [20231026]bbed檢視索引kd_off結構的問題.txt索引
- 如何檢查你的計算機使用的是 UEFI 還是 BIOS計算機iOS
- redo切換頻率查詢
- redo日誌組資訊查詢
- [20170215]再次理解flush redo.txt