UNDO相关问题总结(五)

来源:互联网 发布:c语言可以用else if 编辑:程序博客网 时间:2024/05/18 16:57


转载: 原文地址:http://blog.csdn.net/oradh/article/details/25119143


这次主题介绍undo数据文件丢失的处理示例(2),紧接着上一篇,不过较上篇处理过程更加复杂(数据库无法正常打开,需借助BBED修改数据字典),步骤也要更多。
模拟环境
os: linux x86-64
db: oracle 11gr2
mode: archivelog

模拟过程
1、用户发起事务(insert),未提交
2、shutdown abort 数据库
3、模拟undo数据文件丢失
4、数据库mount状态下offline掉undo数据文件
5、alter database open情况无法打开数据库
6、后续处理
所需预备知识详见我上一篇博客"UNDO相关问题总结(四)"


示例

1)启动数据库
[oracle@netdbhost ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 5 11:32:35 2014
Copyright (c19822009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
Database opened

2)模拟未完成事务
session 1
[oracle@netdbhost dbs]$ sqlplus dh/dh
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 5 11:33:41 2014
Copyright (c19822009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 
SQL> create table test as select * from dba_objects;
Table created.
SQL> insert into test select * from test;                  -----不提交
71895 rows created.

session 2
[oracle@netdbhost ~]$ sqlplus dh/dh
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 5 11:34:16 2014
Copyright (c19822009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> delete test where rownum<100;                   -----不提交
99 rows deleted.

3)检查回滚段上是否正在运行事务
SQL> select status,usn,xacts from v$rollstat;
STATUS                 USN      XACTS
--------------- ---------- ----------
ONLINE                   0          0
ONLINE                   1          0
ONLINE                   2          0
ONLINE                   3          0
ONLINE                   4          1     ------大于0,表示该回滚段上存在一个活动事务
ONLINE                   5          0
ONLINE                   6          1    ------大于0,表示该回滚段上存在一个活动事务
ONLINE                   7          0
ONLINE                   8          0
ONLINE                   9          0
ONLINE                  10          0
11 rows selected.

4abort停止数据库模拟undo数据库文件丢失
SQL> shutdown abort;    
ORACLE instance shut down.
SQL>  host mv /u01/test/test/undotbs01.dbf  /u01/test/test/undotbs01.dbfbak

(5)重启数据库报错,提示undo数据库无法识别
SQL> startup
ORACLE instance started.
Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110data file 3'/u01/test/test/undotbs01.dbf'
SQL> archive log list   
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/archtest
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SQL> select name from v$datafile where file#=3;
NAME
--------------------------------------------------------------------------------
/u01/test/test/undotbs01.dbf

(6)将undo数据文件offline掉(仅offline,而不offline drop),数据库启动报错,并且数据库被自动down掉
SQL> alter database datafile '/u01/test/test/undotbs01.dbf' offline;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 2
ORA-00376: file 3 cannot be read at this time
ORA-01110data file 3'/u01/test/test/undotbs01.dbf'
Process ID: 30899
Session ID: 2273 Serial number5
SQL> quit

(7)alert日志报错信息
Mon May 05 13:58:31 2014
ARC3 started with pid=25, OS id=31904 
Archived Log entry 5 added for thread 1 sequence 9 ID 0x7fca6911 dest 1:
Errors in file /u01/oracle/diag/rdbms/test/test/trace/test_ora_31803.trc:
ORA-00704: bootstrap process failure                  ---数据库自举启动是报错,涉及到数据字典表!
ORA-00604: error occurred at recursive SQL level 2
ORA-00376: file 3 cannot be read at this time
ORA-01110data file 3: '/u01/test/test/undotbs01.dbf'
Errors in file /u01/oracle/diag/rdbms/test/test/trace/test_ora_31803.trc:
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 2
ORA-00376: file 3 cannot be read at this time
ORA-01110data file 3: '/u01/test/test/undotbs01.dbf'
Error 704 happened during db open, shutting down database
USER
 (ospid: 31803): terminating the instance due to error 704
Instance terminated by USER, pid = 31803
ORA-1092 signalled during: alter database open...
opiodr aborting process unknown ospid (31803as a result of ORA-1092
Mon May 05 13:58:32 2014
ORA-1092 : opitsk aborting process


(8)重新启动数据库到mount状态,此时使用offline drop方式drop掉undo数据文件,但是再次启动后,仍旧报一样的错误(注意,如果undo文件丢失后,第一次直接使用offline drop方式干掉undo文件,数据库是可以打开的,详见我上面部分
[oracle@netdbhost ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 5 11:49:30 2014
Copyright (c19822009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
SQL> alter database datafile '/u01/test/test/undotbs01.dbf' offline drop;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 2
ORA-00376: file 3 cannot be read at this time
ORA-01110data file 3'/u01/test/test/undotbs01.dbf'
Process ID: 31046
Session ID: 2273 Serial number5
SQL> quit

(9)尝试将所有的undo段都通过隐含参数offline掉,重启数据库后,仍旧报错
[oracle@netdbhost ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 5 11:55:37 2014
Copyright (c19822009, Oracle.  All rights reserved.
Connected to an idle instance.
strings system01.dbf | grep _SYSSMU | cut -d $ -f 1 | sort -u   ---通过该语句获取数据库中的undo段,并全部offline
*._offline_rollback_segments=('_SYSSMU1_3780397527$','_SYSSMU2_2232571081$','_SYSSMU3_2097677531$','_SYSSMU4_1152005954$','_SYSSMU5_1527469038$','_SYSSMU6_2443381498$','_SYSSMU7_3286610060$','_SYSSMU8_2012382730$','_SYSSMU9_1424341975$','_SYSSMU10_3550978943$')


SQL> startup mount pfile='/home/oracle/dhtest.ora'
ORACLE instance started.
Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 2
ORA-00376: file 3 cannot be read at this time
ORA-01110data file 3'/u01/test/test/undotbs01.dbf'
Process ID: 31285
Session ID: 2273 Serial number5

(10) 检查alert日志的错误信息,发现报错的信息与前面贴出来的一致,因此就不贴出来了。
(11)通过10046跟踪数据库不能启动的原因(我这里同时设置了10200逻辑读跟踪事件,确认问题块,当然需要设置db_file_multiblock_read_count=1
[oracle@netdbhost ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 5 13:47:02 2014
Copyright (c19822009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
SQL> col name format a50
SQL> set linesize 200
SQL> select file#,name,bytes from v$datafile;
     FILE# NAME                                                    BYTES
---------- -------------------------------------------------- ----------
         1 /u01/test/test/system01.dbf                         702545920
         2 /u01/test/test/sysaux01.dbf                         482344960
         3 /u01/test/test/undotbs01.dbf                                0
         4 /u01/test/test/users01.dbf                           20971520
SQL> oradebug segmypid 
ORA-00070: command segmypid is not valid
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug tracefile_name;
/u01/oracle/diag/rdbms/test/test/trace/test_ora_31803.trc
SQL> oradebug event 10046 trace name context forever,level 12;
Statement processed.
SQL> oradebug event 10200 trace name context forever ,level 1;
Statement processed.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 2
ORA-00376: file 3 cannot be read at this time
ORA-01110data file 3'/u01/test/test/undotbs01.dbf'
Process ID: 31803
Session ID: 2273 Serial number5

(12)检查跟踪日志,可以发现system01.dbf的225数据库存在问题,这个块为undo$对应数据块(11g 为225块号,10g 为106块号,可以在正常版本库上查询进行判断)
PARSING IN CURSOR #2 len=142 dep=3 uid=0 oct=3 lid=0 tim=1399269511221174 hv=361892850 ad='94506078'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=999,e=527,p=0,cr=0,cu=0,mis=1,r=0,dep=3,og=3,plh=0,tim=1399269511221172
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=2ab2eb34e098  bln=22  avl=02  flg=05
  value=3
EXEC #2:c=1000,e=731,p=0,cr=0,cu=0,mis=1,r=0,dep=3,og=3,plh=906473769,tim=1399269511221995
ktrgtc2(): started for block <0x0000 : 0x00400141> objd: 0x00000022
  env: (scn: 0x0000.0010b708  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 96sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.00000000)
WAIT #2: nam='db file sequential read' ela= 26 file#=1 block#=321 blocks=1 obj#=34 tim=1399269511222121
showing 0x8bfae5e8 400141 (1) dscn ffffffff:ffff bcrp ffff:ffffffff, bestcrp (nil)
ktrexc(): returning 2 on:  0xa9e539c  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
new dscn ffff:ffffffff ret=2
ktrgtc2(): completed for block <0x0000 : 0x00400141> objd: 0x00000022
ktrgtc2(): started for block <0x0000 : 0x004000e1> objd: 0x0000000f
  env: (scn: 0x0000.0010b708  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid: xid: 0x0000.000.00000000  scn: 0x0000.00000000 96sch: scn: 0x0000.00000000  mascn: (scn: 0x0000.00000000)
WAIT #2: nam='db file sequential read' ela= 11 file#=1 block#=225 blocks=1 obj#=15 tim=1399269511222234
showing 0x8bff79f8 4000e1 (1) dscn ffffffff:ffff bcrp ffff:ffffffff, bestcrp (nil)
ktrexc(): returning 9 on:  0xa9e539c  scn: 0xffff.ffffffff  xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  scn: 0xffff.ffffffff  sfl: 0
new dscn ffff:ffffffff ret=9
WAIT #2: nam='db file sequential read' ela= 11 file#=1 block#=128 blocks=1 obj#=0 tim=1399269511222381
showing 0x8bfae4b8 400080 (1) dscn ffffffff:ffff bcrp ffff:ffffffff, bestcrp (nil)
CR: Caching commit time for XID: xid: 0x0000.035.00000014  CSCN: scn: 0x0000.000f2da7
new dscn ffff:ffffffff ret=2
ktrgcm(): completed for block  <0x0000 : 0x004000e1> objd: 0x0000000f
ktrgtc2(): completed for block <0x0000 : 0x004000e1> objd: 0x0000000f
FETCH #2:c=0,e=462,p=3,cr=3,cu=0,mis=0,r=1,dep=3,og=3,plh=906473769,tim=1399269511222491
STAT #2 id=1 cnt=1 pid=0 pos=1 obj=15 op='TABLE ACCESS BY INDEX ROWID UNDO$ (cr=3 pr=3 pw=0 time=0 us)'
STAT #2 id=2 cnt=1 pid=1 pos=1 obj=34 op='INDEX UNIQUE SCAN I_UNDO1 (cr=1 pr=1 pw=0 time=0 us)'
CLOSE #2:c=0,e=9,dep=3,type=0,tim=1399269511222561

(13) 这种情况下,需要通过bbed来修改undo的元数据,将undo$中用户回滚段的状态(status)全部修改为2(offline状态)
BBED> set file 1 block 225
        FILE#           1
        BLOCK#          225
BBED> map /v
 File: /u01/test/test/system01.dbf (1)
 Block: 225                                   Dba:0x004000e1
------------------------------------------------------------
 KTB Data Block (Table/Cluster)
 struct kcbh, 20 bytes                      @0       
    ub1 type_kcbh                           @0       
    ub1 frmt_kcbh                           @1       
    ub1 spare1_kcbh                         @2       
    ub1 spare2_kcbh                         @3       
    ub4 rdba_kcbh                           @4       
    ub4 bas_kcbh                            @8       
    ub2 wrp_kcbh                            @12      
    ub1 seq_kcbh                            @14      
    ub1 flg_kcbh                            @15      
    ub2 chkval_kcbh                         @16      
    ub2 spare3_kcbh                         @18      
 struct ktbbh, 48 bytes                     @20      
    ub1 ktbbhtyp                            @20      
    union ktbbhsid, 4 bytes                 @24      
    struct ktbbhcsc, 8 bytes                @28      
    sb2 ktbbhict                            @36      
    ub1 ktbbhflg                            @38      
    ub1 ktbbhfsl                            @39      
    ub4 ktbbhfnx                            @40      
    struct ktbbhitl[1], 24 bytes            @44      
 struct kdbh, 14 bytes                      @68      
    ub1 kdbhflag                            @68      
    sb1 kdbhntab                            @69      
    sb2 kdbhnrow                            @70      
    sb2 kdbhfrre                            @72      
    sb2 kdbhfsbo                            @74      
    sb2 kdbhfseo                            @76      
    sb2 kdbhavsp                            @78      
    sb2 kdbhtosp                            @80      
 struct kdbt[1], 4 bytes                    @82      
    sb2 kdbtoffs                            @82      
    sb2 kdbtnrow                            @84      
 sb2 kdbr[21]                               @86 ------表示有21条记录,从0开始一直到20,从1开始修改,需要修改20次!!
 ub1 freespace[5167]                        @128     
 ub1 rowdata[2893]                          @5295    
 ub4 tailchk                                @8188    

BBED> p kdbr
sb2 kdbr[0]                                 @86       8078
sb2 kdbr[1]                                 @88       6142
sb2 kdbr[2]                                 @90       6880
sb2 kdbr[3]                                 @92       6947
sb2 kdbr[4]                                 @94       5227
sb2 kdbr[5]                                 @96       7080
sb2 kdbr[6]                                 @98       7147
sb2 kdbr[7]                                 @100      7214
sb2 kdbr[8]                                 @102      7280
sb2 kdbr[9]                                 @104      6008
sb2 kdbr[10]                                @106      7413
sb2 kdbr[11]                                @108      5946
sb2 kdbr[12]                                @110      5880
sb2 kdbr[13]                                @112      5817
sb2 kdbr[14]                                @114      5751
sb2 kdbr[15]                                @116      5685
sb2 kdbr[16]                                @118      5622
sb2 kdbr[17]                                @120      5556
sb2 kdbr[18]                                @122      5490
sb2 kdbr[19]                                @124      5426
sb2 kdbr[20]                                @126      5360

BBED> p *kdbr[1]
rowdata[915]
------------
ub1 rowdata[915]                            @6210     0x2c
BBED> x /rncnnnnnnn                        --可视化显示
rowdata[915]                                @6210    
------------
flag@6210: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6211: 0x00
cols@6212:   17
col    0[2] @62131 
col   1[20] @6216: _SYSSMU1_3780397527$
col    2[2] @62371 
col    3[2] @62403 
col    4[3] @6243128 
col    5[4] @6247994689 
col    6[1] @62520 
col    7[3] @6254585 
col    8[2] @625893 
col    9[1] @62610 
col   10[2] @62633                        ---这一列为状态列,需要修改为0X02
col   11[2] @62662 
col   12[0] @6269*NULL*
col   13[0] @6270*NULL*
col   14[0] @6271*NULL*
col   15[0] @6272*NULL*
col   16[2] @62732 

BBED> x /r                               ---十六进制显示
rowdata[915]                                @6210    
------------
flag@6210: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6211: 0x00
cols@6212:   17

col    0[2] @6213:  0xc1  0x02 
col   1[20] @6216:  0x5f  0x53  0x59  0x53  0x53  0x4d  0x55  0x31  0x5f  0x33 
 0x37  0x38  0x30  0x33  0x39  0x37  0x35  0x32  0x37  0x24 
col    2[2] @6237:  0xc1  0x02 
col    3[2] @6240:  0xc1  0x04 
col    4[3] @6243:  0xc2  0x02  0x1d 
col    5[4] @6247:  0xc3  0x64  0x2f  0x5a 
col    6[1] @6252:  0x80 
col    7[3] @6254:  0xc2  0x06  0x56 
col    8[2] @6258:  0xc1  0x5e 
col    9[1] @6261:  0x80 
col   10[2] @6263:  0xc1  0x04                ---这一列为状态列,需要修改为0X02
col   11[2] @6266:  0xc1  0x03 
col   12[0] @6269*NULL*
col   13[0] @6270*NULL*
col   14[0] @6271*NULL*
col   15[0] @6272*NULL*
col   16[2] @6273:  0xc1  0x03 

BBED> m /02 offset 6265                --修改为02
 File: /u01/test/test/system01.dbf (1)
 Block: 225              Offsets: 6265 to 6776           Dba:0x004000e1
------------------------------------------------------------------------
 0202c103 ffffffff 02c1032c 001102c1 15155f53 5953534d 5532305f 33383530 
 39333938 34342402 c10202c1 0603c203 49018001 80018001 80018002 c10402c1 
 06ffffff ff02c103 2c001102 c114135f 53595353 4d553139 5f353337 32333936 
 372402c1 0202c106 03c20339 01800180 01800180 018002c1 0402c106 ffffffff 
 02c1032c 001102c1 13155f53 5953534d 5531385f 32383030 37383937 31342402 
 c10202c1 0603c203 29018001 80018001 80018002 c10402c1 06ffffff ff02c103 
 2c001102 c112155f 53595353 4d553137 5f323034 31343339 33333224 02c10202 
 c10603c2 03190180 01800180 01800180 02c10402 c106ffff ffff02c1 032c0011 
 02c11115 5f535953 534d5531 365f3233 31333231 32333936 2402c102 02c10603 
 c2030901 80018001 80018001 8002c104 02c106ff ffffff02 c1032c00 1102c110 
 155f5359 53534d55 31355f31 36383339 32343137 342402c1 0202c106 03c2025d 
 01800180 01800180 018002c1 0402c106 ffffffff 02c1032c 001102c1 0f155f53 
 5953534d 5531345f 32343231 34313139 39362402 c10202c1 0603c202 4d018001 
 80018001 80018002 c10402c1 06ffffff ff02c103 2c001102 c10e155f 53595353 
 4d553133 5f323736 31313933 36323524 02c10202 c10603c2 023d0180 01800180 
 01800180 02c10402 c106ffff ffff02c1 032c0011 02c10d15 5f535953 534d5531 
 <32 bytes per line>
BBED> p *kdbr[1]
rowdata[915]
------------
ub1 rowdata[915]                            @6210     0x2c
BBED> x /rncnnnnnnn
rowdata[915]                                @6210    
------------
flag@6210: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6211: 0x00
cols@6212:   17

col    0[2] @62131 
col   1[20] @6216: _SYSSMU1_3780397527$
col    2[2] @62371 
col    3[2] @62403 
col    4[3] @6243128 
col    5[4] @6247994689 
col    6[1] @62520 
col    7[3] @6254585 
col    8[2] @625893 
col    9[1] @62610  
col   10[2] @62631                ---实际展现值为1
col   11[2] @62662  
col   12[0] @6269*NULL*
col   13[0] @6270*NULL*
col   14[0] @6271*NULL*
col   15[0] @6272*NULL*
col   16[2] @62732 
BBED> x /r
rowdata[915]                                @6210    
------------
flag@6210: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6211: 0x00
cols@6212:   17

col    0[2] @6213:  0xc1  0x02 
col   1[20] @6216:  0x5f  0x53  0x59  0x53  0x53  0x4d  0x55  0x31  0x5f  0x33 
 0x37  0x38  0x30  0x33  0x39  0x37  0x35  0x32  0x37  0x24 
col    2[2] @6237:  0xc1  0x02 
col    3[2] @6240:  0xc1  0x04 
col    4[3] @6243:  0xc2  0x02  0x1d 
col    5[4] @6247:  0xc3  0x64  0x2f  0x5a 
col    6[1] @6252:  0x80 
col    7[3] @6254:  0xc2  0x06  0x56 
col    8[2] @6258:  0xc1  0x5e 
col    9[1] @6261:  0x80 
col   10[2] @6263:  0xc1  0x02          ---十六进制展示为02,表示修改正确
col   11[2] @6266:  0xc1  0x03 
col   12[0] @6269*NULL*
col   13[0] @6270*NULL*
col   14[0] @6271*NULL*
col   15[0] @6272*NULL*
col   16[2] @6273:  0xc1  0x03
BBED> p *kdbr[2]
rowdata[1653]
-------------
ub1 rowdata[1653]                           @6948     0x2c
BBED> x /r
rowdata[1653]                               @6948    
-------------
flag@6948: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6949: 0x00
cols@6950:   17
col    0[2] @6951:  0xc1  0x03 
col   1[20] @6954:  0x5f  0x53  0x59  0x53  0x53  0x4d  0x55  0x32  0x5f  0x32 
 0x32  0x33  0x32  0x35  0x37  0x31  0x30  0x38  0x31  0x24 
col    2[2] @6975:  0xc1  0x02 
col    3[2] @6978:  0xc1  0x04 
col    4[3] @6981:  0xc2  0x02  0x2d 
col    5[4] @6985:  0xc3  0x64  0x2f  0x5c 
col    6[1] @6990:  0x80 
col    7[3] @6992:  0xc2  0x09  0x13 
col    8[3] @6996:  0xc2  0x03  0x0a 
col    9[1] @7000:  0x80 
col   10[2] @7002:  0xc1  0x04 
col   11[2] @7005:  0xc1  0x03 
col   12[0] @7008*NULL*
col   13[0] @7009*NULL*
col   14[0] @7010*NULL*
col   15[0] @7011*NULL*
col   16[2] @7012:  0xc1  0x03 
BBED> m /02 offset 7004
 File: /u01/test/test/system01.dbf (1)
 Block: 225              Offsets: 7004 to 7515           Dba:0x004000e1
------------------------------------------------------------------------
 0202c103 ffffffff 02c1032c 001102c1 04145f53 5953534d 55335f32 30393736 
 37373533 312402c1 0202c104 03c2023d 04c3642f 58018003 c2085b03 c2021f01 
 8002c104 02c103ff ffffff02 c1032c00 1102c105 135f5359 53534d55 345f3837 
 30343231 39383024 02c10202 c10403c2 024d04c3 5f154b01 8003c206 5603c202 
 0c018002 c10202c1 03ffffff ff02c103 2c001102 c106145f 53595353 4d55355f 
 31353237 34363930 33382402 c10202c1 0403c202 5d04c364 2f4f0180 03c20a35 
 03c2032d 018002c1 0402c103 ffffffff 02c1032c 001102c1 07145f53 5953534d 
 55365f32 34343333 38313439 382402c1 0202c104 03c20309 04c3642f 4c018003 
 c2083f03 c2021001 8002c104 02c103ff ffffff02 c1032c00 1102c108 145f5359 
 53534d55 375f3332 38363631 30303630 2402c102 02c10403 c2031904 c3642f55 
 018003c2 064802c1 60018002 c10402c1 03ffffff ff02c103 2c001102 c109145f 
 53595353 4d55385f 32303132 33383237 33302402 c10202c1 0403c203 2904c364 
 2f5e0180 03c2083e 03c20211 018002c1 0402c103 ffffffff 02c1032c 001102c1 
 0a135f53 5953534d 55395f39 37333934 34303538 2402c102 02c10403 c2033904 
 c35f1537 018003c2 084b03c2 020e0180 02c10202 c103ffff ffff02c1 032c0111 
 02c10b15 5f535953 534d5531 305f3335 35303937 38393433 2402c102 02c10403 
 <32 bytes per line>
BBED> x /r
rowdata[1709]                               @7004    
-------------
BBED-00210no row at this offset
BBED> p *kdbr[2]
rowdata[1653]
-------------
ub1 rowdata[1653]                           @6948     0x2c
BBED> x /r
rowdata[1653]                               @6948    
-------------
flag@6948: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6949: 0x00
cols@6950:   17
col    0[2] @6951:  0xc1  0x03 
col   1[20] @6954:  0x5f  0x53  0x59  0x53  0x53  0x4d  0x55  0x32  0x5f  0x32 
 0x32  0x33  0x32  0x35  0x37  0x31  0x30  0x38  0x31  0x24 
col    2[2] @6975:  0xc1  0x02 
col    3[2] @6978:  0xc1  0x04 
col    4[3] @6981:  0xc2  0x02  0x2d 
col    5[4] @6985:  0xc3  0x64  0x2f  0x5c 
col    6[1] @6990:  0x80 
col    7[3] @6992:  0xc2  0x09  0x13 
col    8[3] @6996:  0xc2  0x03  0x0a 
col    9[1] @7000:  0x80 
col   10[2] @7002:  0xc1  0x02 
col   11[2] @7005:  0xc1  0x03 
col   12[0] @7008*NULL*
col   13[0] @7009*NULL*
col   14[0] @7010*NULL*
col   15[0] @7011*NULL*
col   16[2] @7012:  0xc1  0x03 
......................省略后续部分的修改(理论上需要修改20次),与上述一样,只需修改offset即可............
注意:
1.修改为02状态,各状态的含义:1:DELETE,2:OFFLINE, 3:ONLINE,4:UNDEFINED,5:NEEDS RECOVERY,6:PARTLY AVAILABLE,其他表示:UNDEFINED
2.标红加粗部分,展现为1,比实际修改值小1.修改后,我们使用16进制确认,修改正确即可。
3.Offset需要在第10列漂移量上+2(或者11列偏移量-1)

(14)启动数据库,已经可以打开,检查数据
SQL> alter database open;
Database altered.
SQL> select count(*from dh.test;

  COUNT(*)
----------
    143691

(15)数据库打开后,完成扫尾工作
SQL> create undo tablespace undo1 datafile '/u01/test/test/undo1.dbf' size 50m;
Tablespace created.
SQL> show parameter undo
NAME                                 TYPE
------------------------------------ --------------------------------
VALUE
------------------------------
_undo_autotune                       boolean
FALSE
undo_management                      string
AUTO
undo_retention                       integer
1800
undo_tablespace                      string
UNDOTBS1
SQL> alter system set undo_tablespace='UNDO1';
System altered.
SQL> ALTER system SET "_smu_debug_mode" = 4;
System altered.
SQL> col str format a80
SQL> set linesize 200 pagesize 99                                                                                          
SQL> select 'drop rollback segment "'||segment_name||'";'  str from dba_rollback_segs a wherea.tablespace_name='UNDOTBS1';
no rows selected
SQL> drop tablespace undotbs1 including contents;
drop tablespace undotbs1 including contents
*
ERROR at line 1:
ORA-01561: failed to remove all objects in the tablespace specified

SQL> select 'drop rollback segment "'||name||'";'  str from undo$ where file#=3;

STR
--------------------------------------------------------------------------------
drop rollback segment "_SYSSMU1_3780397527$";
drop rollback segment "_SYSSMU2_2232571081$";
drop rollback segment "_SYSSMU3_2097677531$";
drop rollback segment "_SYSSMU4_1152005954$";
drop rollback segment "_SYSSMU5_1527469038$";
drop rollback segment "_SYSSMU6_2443381498$";
drop rollback segment "_SYSSMU7_3286610060$";
7 rows selected.
SQL> drop rollback segment "_SYSSMU1_3780397527$";
drop rollback segment "_SYSSMU2_2232571081$";
Rollback segment dropped.
SQL> 
Rollback segment dropped.
SQL> drop rollback segment "_SYSSMU3_2097677531$";
drop rollback segment "_SYSSMU4_1152005954$";
drop rollback segment "_SYSSMU5_1527469038$";
drop rollback segment "_SYSSMU6_2443381498$";
Rollback segment dropped.
SQL> drop rollback segment "_SYSSMU7_3286610060$";
Rollback segment dropped.
SQL> 
Rollback segment dropped.
SQL> 
Rollback segment dropped.
SQL> 
Rollback segment dropped.
SQL> 
SQL> 
SQL> drop tablespace undotbs1 including contents;
drop tablespace undotbs1 including contents
*
ERROR at line 1:
ORA-01561: failed to remove all objects in the tablespace specified
SQL> 
SQL> 
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
Database opened.
SQL> drop tablespace undotbs1 including contents;
drop tablespace undotbs1 including contents
*
ERROR at line 1:
ORA-01561: failed to remove all objects in the tablespace specified
SQL> select ts# from v$tablespace where name = 'UNDOTBS1';
       TS#
----------
         2
SQL> select count(*from seg$ where ts#=2;
  COUNT(*)
----------
        10
SQL> select count(*from undo$ where ts#=2;
  COUNT(*)
----------
         7
SQL> delete from seg$ where ts#=2;
10 rows deleted.
SQL> delete  from undo$ where ts#=2;
7 rows deleted.
SQL> commit;
Commit complete.
SQL> drop tablespace undotbs1 including contents;
Tablespace dropped.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 
SQL> 
SQL> startup
ORACLE instance started.
Total System Global Area 1369579520 bytes
Fixed Size                  2213216 bytes
Variable Size             905972384 bytes
Database Buffers          452984832 bytes
Redo Buffers                8409088 bytes
Database mounted.
Database opened.

0 0