ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 同事总结的Oracle8i UNDO损坏(ORA-01172及ORA-01151)情况下的数据库不完全恢复

同事总结的Oracle8i UNDO损坏(ORA-01172及ORA-01151)情况下的数据库不完全恢复

原创 Linux操作系统 作者:tolywang 时间:2007-10-13 00:00:00 0 删除 编辑

============
現象:
============


C:/>set nls_language=american

C:/>sqlplus "/ as sysdba"

SQL*Plus: Release 8.1.6.0.0 - Production on 星期四 10月 11 11:28:47 2007

(c) Copyright 1999 Oracle Corporation. All rights reserved.


連到:
Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production


SQL> alter database open;
alter database open
*
ERROR 在行 1:
ORA-01172: 繫線 1 的復原停滯在區塊 579 (檔案 2 的) 上
ORA-01151: 請使用媒體復原來復原區塊, 必要時請復原備份可利用備份資料來復原

-- 嘗試打開數據庫,報錯ORA-01172及ORA-01151,經檢查發現損壞的數據文件為回滾段所在數據文件.


============
開始處理:
============


SQL> select file#,name from v$datafile where file#=2;

FILE# NAME
---------- ----------------------------------------
2 D:/ORACLE/ORADATA/BCCHECK/RBS01.DBF

SQL> select * from v$recover_file;

沒有任何資料列被選取

SQL> shutdown immediate
ORA-01109: 尚未開啟此一資料庫


資料庫已卸載.
已關閉 ORACLE 執行項次.


-- 註釋掉ROLLBACK_SEGMENTS初始化參數設置.后以Restricted模式MOUNT數據庫.

#rollback_segments = ( RBS0, RBS1, RBS2, RBS3, RBS4, RBS5, RBS6 )

SQL> startup restrict mount
已啟動 ORACLE 執行項次.

Total System Global Area 219895052 bytes
Fixed Size 70924 bytes
Variable Size 75116544 bytes
Database Buffers 144629760 bytes
Redo Buffers 77824 bytes
資料庫已掛載.


-- Offline Drop掉損壞的rbs數據文件,然後嘗試打開數據庫.

SQL> alter database datafile 2 offline drop;

資料庫已被更改

SQL> alter database open;

資料庫已被更改

-- 嘗試刪除回滾段表空間

SQL> drop tablespace rbs including contents;
drop tablespace rbs including contents
*
ERROR 在行 1:
ORA-01548: active rollback segment 'RBS0' found, terminate dropping tablespace

-- 報錯ORA-01548,表明有活動回滾段
01548, 00000, "active rollback segment '%s' found, terminate dropping tablespace"
// *Cause: Tried to drop a tablespace that contains active rollback segment(s)
// *Action: Shutdown instances that use the active rollback segments in the
// tablespace and then drop the tablespace

SQL> select segment_name,tablespace_name,status from dba_rollback_segs;

SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ ----------------
SYSTEM SYSTEM ONLINE
RBS0 RBS NEEDS RECOVERY
RBS1 RBS NEEDS RECOVERY
RBS2 RBS NEEDS RECOVERY
RBS3 RBS NEEDS RECOVERY
RBS4 RBS NEEDS RECOVERY
RBS5 RBS NEEDS RECOVERY
RBS6 RBS NEEDS RECOVERY

選取了 8 列


-- 正常關閉數據庫加入隱含參數_corrupted_rollback_segments
SQL> shutdown immediate
資料庫關閉.
資料庫已卸載.
已關閉 ORACLE 執行項次.

-- 修改參數文件加入隱含參數
_corrupted_rollback_segments=(RBS0,RBS1,RBS2,RBS3,RBS4,RBS5,RBS6)

-- 后以restricted模式打開數據庫

SQL> startup restrict
已啟動 ORACLE 執行項次.

Total System Global Area 219895052 bytes
Fixed Size 70924 bytes
Variable Size 75116544 bytes
Database Buffers 144629760 bytes
Redo Buffers 77824 bytes
資料庫已掛載.
資料庫已開啟.
SQL> select segment_name,tablespace_name,status from dba_rollback_segs;

SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ ----------------
SYSTEM SYSTEM ONLINE
RBS0 RBS NEEDS RECOVERY
RBS1 RBS NEEDS RECOVERY
RBS2 RBS NEEDS RECOVERY
RBS3 RBS NEEDS RECOVERY
RBS4 RBS NEEDS RECOVERY
RBS5 RBS NEEDS RECOVERY
RBS6 RBS NEEDS RECOVERY

選取了 8 列

SQL> drop tablespace rbs including contents;
drop tablespace rbs including contents
*
ERROR 在行 1:
ORA-01548: active rollback segment 'RBS0' found, terminate dropping tablespace


-- 強制刪除所有需要恢復的回滾段

SQL> drop rollback segment rbs0;
倒回區段已被廢棄

SQL> drop rollback segment rbs1;
倒回區段已被廢棄

SQL> drop rollback segment rbs2;
倒回區段已被廢棄

SQL> drop rollback segment rbs3;
倒回區段已被廢棄

SQL> drop rollback segment rbs4;
倒回區段已被廢棄

SQL> drop rollback segment rbs5;
倒回區段已被廢棄

SQL> drop rollback segment rbs6;
倒回區段已被廢棄


SQL> select segment_name,tablespace_name,status from dba_rollback_segs;

SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ ----------------
SYSTEM SYSTEM ONLINE


-- 刪除包含損壞的數據文件的回滾段表空間
SQL> drop tablespace rbs including contents;

表格空間已被廢棄

-- 重建回滾段表空間及回滾段,並將回滾段Online.
SQL> create tablespace rbs datafile 'd:oracleoradatabccheckrbs02.dbf' size
200M autoextend off;

表格空間已被建立

SQL> create rollback segment rbs0 tablespace rbs;
倒回區段已被建立

SQL> create rollback segment rbs1 tablespace rbs;
倒回區段已被建立

SQL> create rollback segment rbs2 tablespace rbs;
倒回區段已被建立

SQL> create rollback segment rbs3 tablespace rbs;
倒回區段已被建立

SQL> create rollback segment rbs4 tablespace rbs;
倒回區段已被建立

SQL> create rollback segment rbs5 tablespace rbs;
倒回區段已被建立

SQL> create rollback segment rbs6 tablespace rbs;
倒回區段已被建立

SQL> alter rollback segment rbs0 online;
倒回區段已被更改

SQL> alter rollback segment rbs1 online;
倒回區段已被更改

SQL> alter rollback segment rbs2 online;
倒回區段已被更改

SQL> alter rollback segment rbs3 online;
倒回區段已被更改

SQL> alter rollback segment rbs4 online;
倒回區段已被更改

SQL> alter rollback segment rbs5 online;
倒回區段已被更改

SQL> alter rollback segment rbs6 online;
倒回區段已被更改

SQL> select segment_name,tablespace_name,status from dba_rollback_segs;

SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ ----------------
SYSTEM SYSTEM ONLINE
RBS0 RBS ONLINE
RBS1 RBS ONLINE
RBS2 RBS ONLINE
RBS3 RBS ONLINE
RBS4 RBS ONLINE
RBS5 RBS ONLINE
RBS6 RBS ONLINE

選取了 8 列

--正常關閉數據庫並在參數文件中註釋掉隱含參數_corrupted_rollback_segments,
--並在參數ROLLBACK_SEGMENTS中加入所有的回滾段。

SQL> shutdown immediate
資料庫關閉.
資料庫已卸載.
已關閉 ORACLE 執行項次.

init.ora
......
#_corrupted_rollback_segments=(RBS0,RBS1,RBS2,RBS3,RBS4,RBS5,RBS6)
rollback_segments = ( RBS0, RBS1, RBS2, RBS3, RBS4, RBS5, RBS6 )

SQL> startup
已啟動 ORACLE 執行項次.

Total System Global Area 219895052 bytes
Fixed Size 70924 bytes
Variable Size 75116544 bytes
Database Buffers 144629760 bytes
Redo Buffers 77824 bytes
資料庫已掛載.
資料庫已開啟.

SQL> select segment_name,tablespace_name,status from dba_rollback_segs;

SEGMENT_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ ----------------
SYSTEM SYSTEM ONLINE
RBS0 RBS ONLINE
RBS1 RBS ONLINE
RBS2 RBS ONLINE
RBS3 RBS ONLINE
RBS4 RBS ONLINE
RBS5 RBS ONLINE
RBS6 RBS ONLINE

選取了 8 列

SQL>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-84944/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13385040