dataguard利用從庫的檔案恢復主庫發生異常的資料檔案。

foxmile發表於2008-07-03
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\zero>cd \

C:\>sqlplus "/ as sysdba"

SQL*Plus: Release 10.1.0.2.0 - Production on 星期四 7月 3 11:25:59 2008

Copyright (c) 1982, 2004, Oracle.  All rights reserved.


連線到:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

SYS@zero>select name from v$datafile;

NAME
--------------------------------------------------------------------------------
D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\SYSTEM01.DBF
D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\UNDOTBS01.DBF
D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\SYSAUX01.DBF
D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\USERS01.DBF
D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\MOF.ORA

已選擇5行。

SYS@zero>create tablespace block
  2  datafile 'D:\oracle\product\10.1.0\oradata\zero\block.dbf'
  3  size 1M
  4  extent management local;

表空間已建立。


SYS@zero>alter user dbmon default tablespace block;

使用者已更改。

SYS@zero>alter user dbmon quota unlimited on block;

使用者已更改。

SYS@zero>conn dbmon/dbmon
已連線。
DBMON@zero>create table blk as select* from dba_users;

表已建立。

DBMON@zero>insert into blk select *  from blk;

已建立27行。

DBMON@zero>/

已建立54行。

DBMON@zero>/

已建立108行。

DBMON@zero>/

已建立216行。

DBMON@zero>/

已建立432行。

DBMON@zero>/

已建立864行。

DBMON@zero>/

已建立1728行。

DBMON@zero>/

已建立3456行。

DBMON@zero>/
insert into blk select *  from blk
*
第 1 行出現錯誤:
ORA-01653: 表 DBMON.BLK 無法透過 8 (在表空間 BLOCK 中) 擴充套件


DBMON@zero>commit;

提交完成。

DBMON@zero>alter system checkpoint;

系統已更改。


DBMON@zero>select count(1) from blk;

  COUNT(1)
----------
      6912

已選擇 1 行。

DBMON@zero>conn / as sysdba
已連線。
SYS@zero>shutdown immediate;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SYS@zero>startup;
ORACLE 例程已經啟動。

Total System Global Area  171966464 bytes
Fixed Size                   787988 bytes
Variable Size             145488364 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
資料庫裝載完畢。
資料庫已經開啟。
SYS@zero>alter system switch logfile;

系統已更改。

SYS@zero>alter system switch logfile;

系統已更改。

SYS@zero>shutdown immediate;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SYS@zero>startup;
ORACLE 例程已經啟動。

Total System Global Area  171966464 bytes
Fixed Size                   787988 bytes
Variable Size             145488364 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
資料庫裝載完畢。
資料庫已經開啟。

SYS@zero>shutdown immediate;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SYS@zero>startup;
ORACLE 例程已經啟動。

Total System Global Area  171966464 bytes
Fixed Size                   787988 bytes
Variable Size             145488364 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
資料庫裝載完畢。
資料庫已經開啟。
SYS@zero>alter system switch logfile;

系統已更改。

SYS@zero>select count(1) from dbmon.blk;

  COUNT(1)
----------
      6912

已選擇 1 行。

SYS@zero>shutdown immediate;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。

----用Ultredit編輯資料檔案,隨便更改幾個字元
SYS@zero>startup;
ORACLE 例程已經啟動。

Total System Global Area  171966464 bytes
Fixed Size                   787988 bytes
Variable Size             145488364 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
資料庫裝載完畢。
資料庫已經開啟。
SYS@zero>select count(1) from dbmon.blk;
select count(1) from dbmon.blk
                           *
第 1 行出現錯誤:
ORA-01578: ORACLE 資料塊損壞 (檔案號 6, 塊號 37)
ORA-01110: 資料檔案 6: 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\BLOCK.DBF'


SYS@zero>host dbv D:\oracle\product\10.1.0\oradata\zero\BLOCK.DBF blocksize=8192

DBVERIFY: Release 10.1.0.2.0 - Production on 星期四 7月 3 13:33:04 2008

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

LRM-00108: 定位引數值 'D:\oracle\product\10.1.0\oradata\zero\BLOCK.DBF' 無效

DBV-00001: 非法的命令列語法 - 語法分析錯誤 = (108)

SYS@zero>host dbv file=D:\oracle\product\10.1.0\oradata\zero\BLOCK.DBF blocksize=8192

DBVERIFY: Release 10.1.0.2.0 - Production on 星期四 7月 3 13:34:21 2008

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

DBVERIFY - 開始驗證: FILE = D:\oracle\product\10.1.0\oradata\zero\BLOCK.DBF
頁 37 標記為損壞
Corrupt block relative dba: 0x01800025 (file 6, block 37)
Bad check value found during dbv:
Data in bad block:
 type: 6 format: 2 rdba: 0x01800025
 last change scn: 0x0000.1641efb0 seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xefb00601
 check value in block header: 0x7b42
computed block checksum: 0x7000



DBVERIFY - 驗證完成

檢查的頁總數: 128
處理的頁總數 (資料): 118
失敗的頁總數 (資料): 0
處理的頁總數 (索引): 0
失敗的頁總數 (索引): 0
處理的頁總數 (其它): 9
處理的總頁數 (段)  : 0
失敗的總頁數 (段)  : 0
空的頁總數: 0
標記為損壞的總頁數: 1
流入的頁總數: 0


C:\Documents and Settings\zero>rman target /

恢復管理器: 版本10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle.  All rights reserved.

連線到目標資料庫: ZERO (DBID=102364873)

RMAN> backup validate datafile 6;

啟動 backup 於 03-7月 -08
正在使用目標資料庫控制檔案替代恢復目錄
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=139 devtype=DISK
通道 ORA_DISK_1: 啟動全部資料檔案備份集
通道 ORA_DISK_1: 正在指定備份集中的資料檔案
輸入資料檔案 fno=00006 name=D:\ORACLE\PRODUCT\10.1.0\ORADATA\ZERO\BLOCK.DBF
通道 ORA_DISK_1: 備份集已完成, 經過時間:00:00:02
完成 backup 於 03-7月 -08

RMAN>


SYS@zero>select * from v$database_block_corruption;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         6         37          1                  0 CHECKSUM

已選擇 1 行。

SYS@zero>

SYS@zero>shutdown immediate;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。

----從從庫複製檔案到主庫
SYS@zero>startup mount;
ORACLE 例程已經啟動。

Total System Global Area  171966464 bytes
Fixed Size                   787988 bytes
Variable Size             145488364 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
資料庫裝載完畢。
SYS@zero>
SYS@zero>recover database;
ORA-00279: 更改 373421106 (在 07/03/2008 11:52:40 生成) 對於執行緒 1 是必需的
ORA-00289: 建議: C:\ARC_ZERO\00090_0658778574_001.ARC
ORA-00280: 更改 373421106 (用於執行緒 1) 在序列 #90 中


指定日誌: {=suggested | filename | AUTO | CANCEL}
C:\arc_zero\00090_0658778574_001.ARC
ORA-00279: 更改 373421107 (在 07/03/2008 12:00:25 生成) 對於執行緒 1 是必需的
ORA-00289: 建議: C:\ARC_ZERO\00091_0658778574_001.ARC
ORA-00280: 更改 373421107 (用於執行緒 1) 在序列 #91 中
ORA-00278: 此恢復不再需要日誌檔案 'C:\arc_zero\00090_0658778574_001.ARC'


指定日誌: {=suggested | filename | AUTO | CANCEL}
C:\arc_zero\00091_0658778574_001.ARC
ORA-00279: 更改 373424933 (在 07/03/2008 13:27:03 生成) 對於執行緒 1 是必需的
ORA-00289: 建議: C:\ARC_ZERO\00092_0658778574_001.ARC
ORA-00280: 更改 373424933 (用於執行緒 1) 在序列 #92 中
ORA-00278: 此恢復不再需要日誌檔案 'C:\arc_zero\00091_0658778574_001.ARC'


指定日誌: {=suggested | filename | AUTO | CANCEL}
C:\arc_zero\00092_0658778574_001.ARC
已應用的日誌。
完成介質恢復。
SYS@zero>
SYS@zero>alter database open;

資料庫已更改。

SYS@zero>select count(1) from dbmon.blk;

  COUNT(1)
----------
      6912

已選擇 1 行。

SYS@zero>














來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/79499/viewspace-368988/,如需轉載,請註明出處,否則將追究法律責任。

相關文章