[20170315]ORA-19656错误.txt
--//上午删除测试数据库的归档日志,遇到ORA-19656,做一个记录.
1.环境:
SYS@book> @ &r/ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
RMAN> delete archivelog all;
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=1 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=12 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=24 device type=DISK
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
1205 1 680 A 2017-02-23 08:31:29
Name: /u01/app/oracle/archivelog/book/1_680_896605872.dbf
1206 1 681 A 2017-02-23 16:55:47
Name: /u01/app/oracle/archivelog/book/1_681_896605872.dbf
....
1441 1 808 A 2017-03-15 09:56:40
Name: /u01/app/oracle/archivelog/book/1_808_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 03/15/2017 10:17:46
ORA-19656: cannot backup, copy, or delete online log /u01/app/oracle/archivelog/book/1_694_896605872.dbf
$ oerr ora 19656
19656, 00000, "cannot backup, copy, or delete online log %s"
// *Cause: The indicated log file is an active log. You can only backup,
// copy, or delete archived logs.
// *Action: The indicated log file cannot be processed - select another file.
--//很明显/u01/app/oracle/archivelog/book/1_694_896605872.dbf是在线日志.因为当时我前面做测试删除归档日志,没有办法只能拿
--//冷备份的在线日志代替.
--//这样rman做删除操作时无法删除这个文件,导致以上操作根本没有执行.
2.很明显oracle知道这个文件是在线日志文件.看看根据前面学的知识修改它.
--//参考链接:http://blog.itpub.net/267265/viewspace-2135094/
--//备份
$ cp 1_694_896605872.dbf 1_694_896605872.dbf_XXX
SYS@book> alter system dump logfile '/u01/app/oracle/archivelog/book/1_694_896605872.dbf' validate;
System altered.
DUMP OF REDO FROM FILE '/u01/app/oracle/archivelog/book/1_694_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=36119=0x8d17, File size=102400=0x19000
File Number=3, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000694, SCN 0x0003175d9396-0x0003175d9565"
thread: 1 nab: 0x120 seq: 0x000002b6 hws: 0x3 eot: 0 dis: 0
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low scn: 0x0003.175d9396 (13276910486) 02/28/2017 14:40:06
Next scn: 0x0003.175d9565 (13276910949) 02/28/2017 14:40:12
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.175d9396 (13276910486) 02/28/2017 14:40:06
Disk cksum: 0x198d Calc cksum: 0x198d
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery 01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 12 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 542736ff7fbed565a1b9fef4c3d95a
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP
--//我估计仅仅修改下划线位置就ok了.
$ bvi80 -s 512 -b 512 1_694_896605872.dbf
00000200 01 22 00 00 01 00 00 00 B6 02 00 00 00 80 8D 19 ................
00000210 00 00 00 00 00 04 20 0B 6E 21 B7 4F 42 4F 4F 4B ...... .n!.OBOOK
00000220 00 00 00 00 17 8D 00 00 00 90 01 00 00 02 00 00 ................
00000230 03 00 02 00 6E D8 B7 4F 00 00 00 00 00 00 00 00 ....n..O........
00000240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000250 00 00 00 00 00 00 00 00 00 00 00 00 54 68 72 65 ............Thre
00000260 61 64 20 30 30 30 31 2C 20 53 65 71 23 20 30 30 ad 0001, Seq# 00
00000270 30 30 30 30 30 36 39 34 2C 20 53 43 4E 20 30 78 00000694, SCN 0x
00000280 30 30 30 33 31 37 35 64 39 33 39 36 2D 30 78 30 0003175d9396-0x0
00000290 30 30 33 31 37 35 64 39 35 36 35 00 20 01 00 00 003175d9565. ...
000002A0 B0 1E 71 35 06 20 0E 00 00 00 00 00 03 00 00 00 ..q5. ..........
000002B0 01 00 00 00 96 93 5D 17 03 00 00 00 46 BB DB 37 ......].....F..7
000002C0 65 95 5D 17 03 00 00 00 4C BB DB 37 00 00 08 02 e.].....L..7....
000002D0 06 20 0E 00 00 00 00 00 B0 1E 71 35 96 93 5D 17 . ........q5..].
000002E0 03 00 00 00 46 BB DB 37 00 00 00 00 00 00 80 00 ....F..7........
~~~~~~~~~~~
000002F0 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 ................
00000300 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 ................
00000310 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ................
00000320 00 00 00 00 7A C9 21 31 00 00 00 00 00 00 00 00 ....z.!1........
00000330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000370 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000390 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003C0 54 02 73 6F F7 FB 0E D5 65 A1 B9 FE F4 C3 D9 5A T.so....e......Z
000003D0 27 F7 6C 1F 74 8A 40 20 48 9C 47 0B 46 31 76 E0 '.l.t.@ H.G.F1v.
000003E0 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000400
--//修改0x2EB处 0x00008000 => 0x11008000
$ xor.sh /tmp/aaa.txt
1100
0000
8D19
xor result: 9C19
--//修改检查和偏移0x14-15处 0x9c19
SYS@book> alter system dump logfile '/u01/app/oracle/archivelog/book/1_694_896605872.dbf' validate;
System altered.
--//检查转储:
Miscellaneous flags: 0x800011
--再次执行rman:
RMAN> delete archivelog all;
...
$ ls -l /u01/app/oracle/archivelog/book/1_694_896605872.dbf*
-rw-r----- 1 oracle oinstall 52429312 2017-03-15 10:22:57 /u01/app/oracle/archivelog/book/1_694_896605872.dbf_XXX
--ok,可以发现现在删除了归档文件1_694_896605872.dbf.也就是知道通过这个Miscellaneous flags标识那个文件是现在日志还是归档.
3.反向证明:
--//从冷备库恢复,测试机器有点乱,重来
$ ls -l /u01/app/oracle/archivelog/book/1_697_896605872.dbf
-rw-r----- 1 oracle oinstall 1139200 2017-03-15 11:02:58 /u01/app/oracle/archivelog/book/1_697_896605872.dbf
--//文件大小不足50M.
$ xor.sh /tmp/aaa.txt
1100
8F8D
xor result: 9E8D
--//以下是修改后的情况:
$ bvi80 -s 512 -b 512 1_697_896605872.dbf
00000200 01 22 00 00 01 00 00 00 B9 02 00 00 00 80 9E 8D ................
~~~~~
00000210 00 00 00 00 00 04 20 0B 6E 21 B7 4F 42 4F 4F 4B ...... .n!.OBOOK
00000220 00 00 00 00 39 8D 00 00 00 90 01 00 00 02 00 00 ....9...........
00000230 03 00 02 00 6E D8 B7 4F 00 00 00 00 00 00 00 00 ....n..O........
00000240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000250 00 00 00 00 00 00 00 00 00 00 00 00 54 68 72 65 ............Thre
00000260 61 64 20 30 30 30 31 2C 20 53 65 71 23 20 30 30 ad 0001, Seq# 00
00000270 30 30 30 30 30 36 39 37 2C 20 53 43 4E 20 30 78 00000697, SCN 0x
00000280 30 30 30 33 31 37 35 64 65 39 36 31 2D 30 78 30 0003175de961-0x0
00000290 30 30 33 31 37 35 64 65 61 33 32 00 B1 08 00 00 003175dea32.....
000002A0 B0 1E 71 35 06 20 0E 00 00 00 00 00 02 00 00 00 ..q5. ..........
000002B0 01 00 00 00 61 E9 5D 17 03 00 00 00 6B 42 F3 37 ....a.].....kB.7
000002C0 32 EA 5D 17 03 00 00 00 92 42 F3 37 00 00 08 02 2.]......B.7....
000002D0 06 20 0E 00 00 00 00 00 B0 1E 71 35 61 E9 5D 17 . ........q5a.].
000002E0 03 00 00 00 6B 42 F3 37 00 00 00 00 00 00 80 00 ....kB.7........
~~~~~~~~~~~
000002F0 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 ................
00000300 00 00 00 00 00 00 00 00 00 00 00 00 FD 01 00 00 ................
00000310 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ................
00000320 00 00 00 00 7A C9 21 31 00 00 00 00 00 00 00 00 ....z.!1........
00000330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000370 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000390 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003C0 B1 12 8F FC F6 9C F4 8F B7 29 84 ED E9 A0 3B 51 .........)....;Q
000003D0 27 F7 6C 1F 74 8A 40 20 48 9C 47 0B 46 31 76 E0 '.l.t.@ H.G.F1v.
000003E0 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000400
SYS@book> alter system dump logfile '/u01/app/oracle/archivelog/book/1_697_896605872.dbf' validate;
System altered.
DUMP OF REDO FROM FILE '/u01/app/oracle/archivelog/book/1_697_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=36153=0x8d39, File size=102400=0x19000
File Number=3, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000697, SCN 0x0003175de961-0x0003175dea32"
thread: 1 nab: 0x8b1 seq: 0x000002b9 hws: 0x2 eot: 0 dis: 0
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low scn: 0x0003.175de961 (13276932449) 03/15/2017 10:58:51
Next scn: 0x0003.175dea32 (13276932658) 03/15/2017 10:59:30
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.175de961 (13276932449) 03/15/2017 10:58:51
Disk cksum: 0x8d9e Calc cksum: 0x8d9e
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery 01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 509 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 b1128ffcf69cf48fb72984ede9a03b51
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP
RMAN> delete archivelog sequence 697 ;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=3 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=12 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=24 device type=DISK
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
1237 1 697 A 2017-03-15 10:58:51
Name: /u01/app/oracle/archivelog/book/1_697_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 03/15/2017 11:08:00
ORA-19656: cannot backup, copy, or delete online log /u01/app/oracle/archivelog/book/1_697_896605872.dbf
--//再次验证了自己的判断.加入force参数可以从控制文件中剔除.但是实际的文件还存在.
RMAN> delete force archivelog sequence 697 ;
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=3 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=12 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=24 device type=DISK
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
1237 1 697 A 2017-03-15 10:58:51
Name: /u01/app/oracle/archivelog/book/1_697_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_697_896605872.dbf RECID=1237 STAMP=938689172
Deleted 1 objects
RMAN> list archivelog sequence 696;
specification does not match any archived log in the repository
$ ls -l /u01/app/oracle/archivelog/book/1_697_896605872.dbf
-rw-r----- 1 oracle oinstall 1139200 2017-03-15 11:02:58 /u01/app/oracle/archivelog/book/1_697_896605872.dbf
--//可以发现文件还存在,oracle可能出于安全的考虑,实际上并没有删除这个文件.毕竟它认为这个文件是在线日志文件^_^.