找出11g undo 回滚段名称

联系:手机(13429648788)  QQ(107644445)

链接:https://www.orasos.com/%e6%89%be%e5%87%ba11g-undo-%e5%9b%9e%e6%bb%9a%e6%ae%b5%e5%90%8d%e7%a7%b0.html

标题:找出11g undo 回滚段名称

作者:惜分飞©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

当数据库启动的时报undo相关异常,很多情况下我们不得不使用隐含参数来处理(_offline_rollback_segments和_corrupted_rollback_segments),而这个就需要明确异常的undo回滚段名称。在11g中,undo回滚段的名称发生了改变,在11g之前的版本中,回滚段名称是”_SYSTEMn$”之类,而到了11g回滚段的名称变为了”_SYSTEMn_时间戳$”,因为时间戳我们不知道,所以我们不能通过n的值,来确定回滚段的名称,从而也就不能很明确的使用_offline_rollback_segments和_corrupted_rollback_segments来标明异常回滚段。既然回滚段的名称我们可以通过dba_rollback_segs视图来查询,那么我们可以根据这个视图找到对应的回滚段是存储在哪张基表中,下面为dba_rollback_segs视图对应的sql语句

select un.name, decode(un.user#,1,'PUBLIC','SYS'),
       ts.name, un.us#, f.file#, un.block#,
       s.iniexts * ts.blocksize,
       decode(bitand(ts.flags, 3), 1, to_number(NULL),
                                      s.extsize * ts.blocksize),
       s.minexts, s.maxexts,
       decode(bitand(ts.flags, 3), 1, to_number(NULL),
                                      s.extpct),
       decode(un.status$, 2, 'OFFLINE', 3, 'ONLINE',
                          4, 'UNDEFINED', 5, 'NEEDS RECOVERY',
                          6, 'PARTLY AVAILABLE', 'UNDEFINED'),
       decode(un.inst#, 0, NULL, un.inst#), un.file#
from sys.undo$ un, sys.seg$ s, sys.ts$ ts, sys.file$ f
where un.status$ != 1
  and un.ts# = s.ts#
  and un.file# = s.file#
  and un.block# = s.block#
  and s.type# in (1, 10)
  and s.ts# = ts.ts#
  and un.ts# = f.ts#
  and un.file# = f.relfile#

通过观察,我们知道回滚段信息是存储在sys.undo$中(name字段表示回滚段名称,status$字段表示回滚段状态[1:DELETE,2:OFFLINE,3:ONLINE,4:UNDEFINED,5:NEEDS RECOVERY,6:PARTLY AVAILABLE,其他表示:UNDEFINED]),通过这个视图我们需要找的到status$为5所对应name。
找这些值较简易的方法就是通过odu抽取sys.undo$表中数据,然后在其他库上还原,然后通过sql语句查询
1.设置odu参数(config.txt)
output_format dmp,其他参数根据你的实际情况设置

2.填写system表空间对应的数据文件(control.txt)

[oracle@localhost odu]$ more control.txt 
#ts #fno   #rfno     filename                                          block_size
1     1      1       /u01/oradata/first/system01.dbf

3.odu导出数据

ODU> unload table sys.undo$

Unloading table: UNDO$,object ID: 15
Unloading segment,storage(Obj#=15 DataObj#=15 TS#=0 File#=1 Block#=224 Cluster=0)
21 rows unloaded

4.导入至新库

imp chf/xifenfei file=C:\Users\XIFENFEI\Downloads\SYS_UNDO$.dmp FROMUSER=SYS TOUSER=CHF

5.查询需要处理的回滚段

--数据库版本10g及其以上版本
set pagesize 0 feedback off verify off heading off echo off linesize 1000
select WMSYS.WM_CONCAT(name) from UNDO$ where status$=5;

--数据库版本9i及其以下版本(自己拼接)
set pagesize 0 feedback off verify off heading off echo off 
select name from UNDO$ where status$=5;

现在已经找出来了需要处理的回滚段,其他数据库恢复步骤与以前数据库相同。

2 thoughts on “找出11g undo 回滚段名称

  1. _OFFLINE_ROLLBACK_SEGMENTS is a unsupported init.ora parameter which can allow you to cause logical database corruption.

    _CORRUPTED_ROLLBACK_SEGMENTS is more dangerous parameter than _OFFLINE_ROLLBACK_SEGMENTS. It basically prevents access to the listed rollback segments headers and assumes all transactions in them are committed. This can very easily cause logical database corruption.

  2. 以前的strings命令找出相应回滚段方法测试

    [oracle@localhost odu]$ strings /u01/oradata/first/system01.dbf | grep _SYSSMU | cut -d $ -f 1 | sort -u >/tmp/system.txt
    [oracle@localhost odu]$ more /tmp/system.txt 
                  and substr(drs.segment_name,1,7) != '_SYSSMU' 
    D'              and substr(drs.segment_name,1,7) != ''_SYSSMU'' ' );
    _SYSSMU10_3459578018
    _SYSSMU10_4131489474
    _SYSSMU11_1017459875
    _SYSSMU12_537332688
    _SYSSMU1_3133714326
    _SYSSMU13_856144422
    _SYSSMU14_1282242678
    _SYSSMU15_3732347774
    _SYSSMU1_592353410
    _SYSSMU16_3892484933
    _SYSSMU17_2605132257
    _SYSSMU18_1698028356
    _SYSSMU19_1313888654
    _SYSSMU20_1688883760
    _SYSSMU2_849237456
    _SYSSMU2_967517682
    _SYSSMU3_1204390606
    _SYSSMU3_50029197
    _SYSSMU4_1003442803
    _SYSSMU4_2580388194
    _SYSSMU5_3406574735
    _SYSSMU5_538557934
    _SYSSMU6_162144149
    _SYSSMU6_2897970769
    _SYSSMU7_2865732393
    _SYSSMU7_3517345427
    _SYSSMU8_1312276615
    _SYSSMU8_3901294357
    _SYSSMU9_1735643689
    _SYSSMU9_2252183395
    

    在这里可以看出,每个回滚段都有两个(时间戳不一样),在使用的时候,我们就不能确定使用哪个比较合适(因为不知道哪个此时真正的需要的回滚段,而在spfile中同时标明一个回滚段的两个名称,前面一个会被覆盖),由此可以看出,这种方法暂时不太合适(而且在win的系统中很难使用,即使第三方工具可以打开system表空间数据文件,要找到相关内容并非易事,而且也可以有类此linux中现象出现)

Comments are closed.