bbed修改undo段状态(ORA-01578)
Linuxidc@orcl11g>select * from Linuxidc;
select * from Linuxidc
*
ERROR at line 1:
ORA-01578: Oracle data block corrupted (file # 3, block # 1449)
ORA-01110: data file 3: '/opt/oracle/oradata/orcl11g/undotbs01.dbf'
这里是事务正在执行,但是数据库直接以abort方式关机,并且对应的回滚段损坏
当然这里其实不需要bbed,只需要用_offline_rollback_segments 隐含参数标记对应的回滚段,然后使用drop rollback segment 该回滚段即可
这里使用bbed目的是在于研究undo回滚段的状态存于何处以及如何修改
这里我们创建另外一个undo表空间,并且切换到该表空间
Linuxidc@orcl11g>create undo tablespace undotbs02 datafile '/opt/oracle/oradata/orcl11g/undotb02.dbf' size 100m;
Tablespace created.
Linuxidc@orcl11g>alter system set undo_tablespace=undotbs02;
System altered.
Linuxidc@orcl11g>show parameter undo
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS02
我们查看回滚段的状态,发现即使切换了,还有一个回滚段处于online状态,因为这个回滚段上面还存在需要恢复的数据,但是这个回滚段已经被损坏,无法进行恢复。那么我们只能将其删除。
Linuxidc@orcl11g>select segment_name,tablespace_name,status from dba_rollback_segs;
SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ -------------------- ------------------------------------------------------------
SYSTEM SYSTEM ONLINE
_SYSSMU10_3550978943$ UNDOTBS1 ONLINE
_SYSSMU9_1424341975$ UNDOTBS1 OFFLINE
_SYSSMU8_2012382730$ UNDOTBS1 OFFLINE
_SYSSMU7_3286610060$ UNDOTBS1 OFFLINE
_SYSSMU6_2443381498$ UNDOTBS1 OFFLINE
_SYSSMU5_1527469038$ UNDOTBS1 OFFLINE
_SYSSMU4_1152005954$ UNDOTBS1 OFFLINE
_SYSSMU3_2097677531$ UNDOTBS1 OFFLINE
_SYSSMU2_2232571081$ UNDOTBS1 OFFLINE
_SYSSMU1_3780397527$ UNDOTBS1 OFFLINE
_SYSSMU20_3705739785$ UNDOTBS02 ONLINE
_SYSSMU19_3920348761$ UNDOTBS02 ONLINE
_SYSSMU18_2539622763$ UNDOTBS02 ONLINE
_SYSSMU17_178842559$ UNDOTBS02 ONLINE
_SYSSMU16_3035903491$ UNDOTBS02 ONLINE
_SYSSMU15_444141832$ UNDOTBS02 ONLINE
_SYSSMU14_3021863913$ UNDOTBS02 ONLINE
_SYSSMU13_3717211136$ UNDOTBS02 ONLINE
_SYSSMU12_3182721254$ UNDOTBS02 ONLINE
_SYSSMU11_3909920883$ UNDOTBS02 ONLINE
通过以下可以看到不同的数字对应不同的状态:
undo segment 的状态:
1表示offline并且被删除
2 表示offline
3 表示online
4 未知
5 表示need recovery
SYS@orcl11g>select name,status$ from undo$;
NAME STATUS$
------------------------------------------------------------ ----------
SYSTEM 3
_SYSSMU1_3780397527$ 2
_SYSSMU2_2232571081$ 2
_SYSSMU3_2097677531$ 2
_SYSSMU4_1152005954$ 2
_SYSSMU5_1527469038$ 2
_SYSSMU6_2443381498$ 2
_SYSSMU7_3286610060$ 2
_SYSSMU8_2012382730$ 2
_SYSSMU9_1424341975$ 2
_SYSSMU10_3550978943$ 3
_SYSSMU11_3909920883$ 3
_SYSSMU12_3182721254$ 3
_SYSSMU13_3717211136$ 3
_SYSSMU14_3021863913$ 3
_SYSSMU15_444141832$ 3
_SYSSMU16_3035903491$ 3
_SYSSMU17_178842559$ 3
_SYSSMU18_2539622763$ 3
_SYSSMU19_3920348761$ 3
_SYSSMU20_3705739785$ 3
强制将该回滚段offline,发现还是无法删除:
SYS@orcl11g>alter rollback segment "_SYSSMU10_3550978943$" offline;
Rollback segment altered.
SYS@orcl11g>drop tablespace UNDOTBS1;
drop tablespace UNDOTBS1
*
ERROR at line 1:
ORA-30013: undo tablespace 'UNDOTBS1' is currently in use
此时,我们关闭数据库使用bbed更改该回滚段的状态:
在数据库启动的时候,我们可以是oradebug 10046事件追踪,通过trace文件分析:
PARSING IN CURSOR #2 len=142 dep=1 uid=0 oct=3 lid=0 tim=1414654507002840 hv=361892850 ad='78938c58' sqlid='7bd391hat42zk'
select /*+ rule */ name,file#,block#,status$,user#,undosqn,xactsqn,scnbas,scnwrp,DECODE(inst#,0,NULL,inst#),ts#,spare1 from undo$ where us#=:1
END OF STMT
PARSE #2:c=0,e=17,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=3,plh=906473769,tim=1414654507002839
BINDS #2:
Bind#0
oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
oacflg=08 fl2=0001 frm=00 csi=00 siz=24 off=0
kxsbbbfp=7fcf70adc448 bln=22 avl=02 flg=05
value=7
undo段的状态是从undo$基表中获取的,那么我们看看这里的基表对应的物理块号
SYS@orcl11g>select rowid,dbms_rowid.rowid_object(rowid) robject,
2 dbms_rowid.rowid_relative_fno(rowid) fno,
3 dbms_rowid.rowid_block_number(rowid) bno,
4 dbms_rowid.rowid_row_number(rowid) rno from undo$ where rownum=1;
ROWID ROBJECT FNO BNO RNO
------------------ ---------- ---------- ---------- ----------
AAAAAPAABAAAADhAAA 15 1 225 0
然后我们使用bbed查看该数据块:
BBED> map
File: /opt/oracle/oradata/orcl11g/system01.dbf (1)
Block: 225 Dba:0x004000e1
------------------------------------------------------------
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
struct ktbbh, 48 bytes @20
struct kdbh, 14 bytes @68
struct kdbt[1], 4 bytes @82
sb2 kdbr[21] @86
ub1 freespace[3752] @128
ub1 rowdata[4308] @3880
ub4 tailchk @8188
这里可以看出与视图对应的21个回滚段:
BBED> p kdbr
sb2 kdbr[0] @86 8078
sb2 kdbr[1] @88 4071
sb2 kdbr[2] @90 5156
sb2 kdbr[3] @92 5088
sb2 kdbr[4] @94 4206
sb2 kdbr[5] @96 4952
sb2 kdbr[6] @98 4341
sb2 kdbr[7] @100 4816
sb2 kdbr[8] @102 4748
sb2 kdbr[9] @104 4680
sb2 kdbr[10] @106 4611
sb2 kdbr[11] @108 4008
sb2 kdbr[12] @110 5880
sb2 kdbr[13] @112 5817
sb2 kdbr[14] @114 5751
sb2 kdbr[15] @116 3943
sb2 kdbr[16] @118 5622
sb2 kdbr[17] @120 3878
sb2 kdbr[18] @122 5490
sb2 kdbr[19] @124 3812
sb2 kdbr[20] @126 5360
BBED> p *kdbr[10]
rowdata[799]
------------
ub1 rowdata[799] @4679 0x2c
BBED> x /1rnnnnnnnn
rowdata[799] @4679
------------
flag@4679: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@4680: 0x00
cols@4681: 17
col 0[2] @4682: 10
col 1[21] @4685: -0
col 2[2] @4707: 1
col 3[2] @4710: 3
col 4[3] @4713: 272
col 5[5] @4717: 5168854
col 6[1] @4723: 0
col 7[3] @4725: 866
col 8[3] @4729: 350
col 9[1] @4733: 0
col 10[2] @4735: 3
col 11[2] @4738: 2
col 12[0] @4741: *NULL*
col 13[0] @4742: *NULL*
col 14[0] @4743: *NULL*
col 15[0] @4744: *NULL*
col 16[2] @4745: 2
在这里我们将回滚段的状态修改为2,表示offline
BBED> modify /x 02 offset 4737
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /opt/oracle/oradata/orcl11g/system01.dbf (1)
Block: 225 Offsets: 4737 to 5248 Dba:0x004000e1
------------------------------------------------------------------------
0202c103 ffffffff 02c1032c 011102c1 0a145f53 5953534d 55395f31 34323433
34313937 352402c1 0202c104 03c20339 05c40614 12210180 03c20b5e 03c2045e
018002c1 0302c103 ffffffff 02c1032c 001102c1 09145f53 5953534d 55385f32
30313233 38323733 302402c1 0202c104 03c20329 05c40614 11380180 03c20b40
03c20334 018002c1 0302c103 ffffffff 02c1032c 001102c1 08145f53 5953534d
55375f33 32383636 31303036 302402c1 0202c104 03c20319 05c40614 11350180
03c20953 03c20418 018002c1 0302c103 ffffffff 02c1032c 001102c1 07145f53
5953534d 55365f32 34343333 38313439 382402c1 0202c104 03c20309 05c40220
295a0180 03c20944 03c20261 018002c1 0402c103 ffffffff 02c1032c 001102c1
06145f53 5953534d 55355f31 35323734 36393033 382402c1 0202c104 03c2025d
05c40614 11340180 03c20d4c 03c20512 018002c1 0302c103 ffffffff 02c1032c
001102c1 05145f53 5953534d 55345f31 31353230 30353935 342402c1 0202c104
03c2024d 05c4023e 14400180 03c2084c 03c20461 018002c1 0402c103 ffffffff
02c1032c 001102c1 04145f53 5953534d 55335f32 30393736 37373533 312402c1
0202c104 03c2023d 05c40614 11360180 03c20b5d 03c2053a 018002c1 0302c103
ffffffff 02c1032c 001102c1 03145f53 5953534d 55325f32 32333235 37313038
BBED> p *kdbr[10]
rowdata[799]
------------
ub1 rowdata[799] @4679 0x2c
BBED> x /1rnnnnnnnn
rowdata[799] @4679
------------
flag@4679: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@4680: 0x00
cols@4681: 17
col 0[2] @4682: 10
col 1[21] @4685: -0
col 2[2] @4707: 1
col 3[2] @4710: 3
col 4[3] @4713: 272
col 5[5] @4717: 5168854
col 6[1] @4723: 0
col 7[3] @4725: 866
col 8[3] @4729: 350
col 9[1] @4733: 0
col 10[2] @4735: 1
col 11[2] @4738: 2
col 12[0] @4741: *NULL*
col 13[0] @4742: *NULL*
col 14[0] @4743: *NULL*
col 15[0] @4744: *NULL*
col 16[2] @4745: 2
BBED> sum apply;
Check value for File 1, Block 225:
current = 0x93df, required = 0x93df
BBED> verify
DBVERIFY - Verification starting
FILE = /opt/oracle/oradata/orcl11g/system01.dbf
BLOCK = 225
DBVERIFY - Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 0
Total Blocks Influx : 0
Message 531 not found; product=RDBMS; facility=BBED
刷新缓存,重新查看视图:
SYS@orcl11g>alter system flush buffer_cache;
System altered.
SYS@orcl11g>select segment_name,tablespace_name,status from dba_rollback_segs;
SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ -------------------- ------------------------------------------------------------
SYSTEM SYSTEM ONLINE
_SYSSMU10_3550978943$ UNDOTBS1 OFFLINE
_SYSSMU9_1424341975$ UNDOTBS1 OFFLINE
_SYSSMU8_2012382730$ UNDOTBS1 OFFLINE
_SYSSMU7_3286610060$ UNDOTBS1 OFFLINE
_SYSSMU6_2443381498$ UNDOTBS1 OFFLINE
_SYSSMU5_1527469038$ UNDOTBS1 OFFLINE
_SYSSMU4_1152005954$ UNDOTBS1 OFFLINE
_SYSSMU3_2097677531$ UNDOTBS1 OFFLINE
_SYSSMU2_2232571081$ UNDOTBS1 OFFLINE
_SYSSMU1_3780397527$ UNDOTBS1 OFFLINE
_SYSSMU20_3705739785$ UNDOTBS02 ONLINE
_SYSSMU19_3920348761$ UNDOTBS02 ONLINE
_SYSSMU18_2539622763$ UNDOTBS02 ONLINE
_SYSSMU17_178842559$ UNDOTBS02 ONLINE
_SYSSMU16_3035903491$ UNDOTBS02 ONLINE
_SYSSMU15_444141832$ UNDOTBS02 ONLINE
_SYSSMU14_3021863913$ UNDOTBS02 ONLINE
_SYSSMU13_3717211136$ UNDOTBS02 ONLINE
_SYSSMU12_3182721254$ UNDOTBS02 ONLINE
_SYSSMU11_3909920883$ UNDOTBS02 ONLINE
SYS@orcl11g>select name,status$ from undo$;
NAME STATUS$
------------------------------------------------------------ ----------
SYSTEM 3
_SYSSMU1_3780397527$ 2
_SYSSMU2_2232571081$ 2
_SYSSMU3_2097677531$ 2
_SYSSMU4_1152005954$ 2
_SYSSMU5_1527469038$ 2
_SYSSMU6_2443381498$ 2
_SYSSMU7_3286610060$ 2
_SYSSMU8_2012382730$ 2
_SYSSMU9_1424341975$ 2
_SYSSMU10_3550978943$ 1
_SYSSMU11_3909920883$ 3
_SYSSMU12_3182721254$ 3
_SYSSMU13_3717211136$ 3
_SYSSMU14_3021863913$ 3
_SYSSMU15_444141832$ 3
_SYSSMU16_3035903491$ 3
_SYSSMU17_178842559$ 3
_SYSSMU18_2539622763$ 3
_SYSSMU19_3920348761$ 3
_SYSSMU20_3705739785$ 3
SYS@orcl11g>select name,status$ from undo$;
NAME STATUS$
------------------------------------------------------------ ----------
SYSTEM 3
_SYSSMU1_3780397527$ 1
_SYSSMU2_2232571081$ 1
_SYSSMU3_2097677531$ 1
_SYSSMU4_1152005954$ 1
_SYSSMU5_1527469038$ 1
_SYSSMU6_2443381498$ 1
_SYSSMU7_3286610060$ 1
_SYSSMU8_2012382730$ 1
_SYSSMU9_1424341975$ 1
_SYSSMU10_3550978943$ 1
_SYSSMU11_3909920883$ 3
_SYSSMU12_3182721254$ 3
_SYSSMU13_3717211136$ 3
_SYSSMU14_3021863913$ 3
_SYSSMU15_444141832$ 3
_SYSSMU16_3035903491$ 3
_SYSSMU17_178842559$ 3
_SYSSMU18_2539622763$ 3
_SYSSMU19_3920348761$ 3
_SYSSMU20_3705739785$ 3
21 rows selected.
重新启动数据库,发现offline的回滚段不存在:
SYS@orcl11g>col segment_name for a30;
SYS@orcl11g>col tablespace_name for a30;
SYS@orcl11g>select segment_name,tablespace_name,status from dba_rollback_segs;
SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ ------------------------------------------------------------
SYSTEM SYSTEM ONLINE
_SYSSMU20_3705739785$ UNDOTBS02 ONLINE
_SYSSMU19_3920348761$ UNDOTBS02 ONLINE
_SYSSMU18_2539622763$ UNDOTBS02 ONLINE
_SYSSMU17_178842559$ UNDOTBS02 ONLINE
_SYSSMU16_3035903491$ UNDOTBS02 ONLINE
_SYSSMU15_444141832$ UNDOTBS02 ONLINE
_SYSSMU14_3021863913$ UNDOTBS02 ONLINE
_SYSSMU13_3717211136$ UNDOTBS02 ONLINE
_SYSSMU12_3182721254$ UNDOTBS02 ONLINE
_SYSSMU11_3909920883$ UNDOTBS02 ONLINE
这时候我们来查看该表:
SYS@orcl11g>conn Linuxidc/oracle;
Connected.
Linuxidc@orcl11g>select * from Linuxidc;
NAME
------------------------------------------------------------
Linuxidc
--------------------------------------------------------------------------------
RMAN备份与恢复之undo表空间丢失
关于Oracle 释放过度使用的undo表空间
Oracle undo的一些理解
Oracle undo 镜像数据探究
Oracle 回滚(ROLLBACK)和撤销(undo)
Linux-6-64下安装Oracle 12C笔记
在CentOS 6.4下安装Oracle 11gR2(x64)
Oracle 11gR2 在VMWare虚拟机中安装步骤
Debian 下 安装 Oracle 11g XE R2
--------------------------------------------------------------------------------
: