oracle模块损坏,Oracle中模拟及修复数据块损坏
Oracle中模擬及修復(fù)數(shù)據(jù)塊損壞,itpub link:
http://www.itpub.net/showthread.php?threadid=201766[@more@]Oracle中模擬及修復(fù)數(shù)據(jù)塊損壞
itpub link:
http://www.itpub.net/showthread.php?threadid=201766
1.插入數(shù)據(jù)
E:Oracleora92bin>sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on 星期一 3月 8 20:27:15 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
連接到:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
E:ORACLEORADATAEYGLESYSTEM01.DBF
E:ORACLEORADATAEYGLEUNDOTBS01.DBF
E:ORACLEORADATAEYGLEEYGLE01.DBF
SQL> create tablespace block
2 datafile 'e:oracleoradataeygleblock.dbf'
3 size 1M
4 extent management local;
表空間已創(chuàng)建。
SQL> alter user eygle default tablespace block;
用戶已更改。
SQL> alter user eygle quota unlimited on block;
用戶已更改。
SQL> connect eygle/eygle
已連接。
SQL> create table t as select * from dba_users;
表已創(chuàng)建。
SQL> insert into t select * from t;
已創(chuàng)建8行。
SQL> /
已創(chuàng)建16行。
SQL> /
已創(chuàng)建32行。
SQL> /
已創(chuàng)建64行。
SQL> /
已創(chuàng)建128行。
SQL> /
已創(chuàng)建256行。
SQL> /
已創(chuàng)建512行。
SQL> /
已創(chuàng)建1024行。
SQL> /
已創(chuàng)建2048行。
SQL> /
已創(chuàng)建4096行。
SQL> /
insert into t select * from t
*
ERROR 位于第 1 行:
ORA-01653: 表EYGLE.T無法通過8(在表空間BLOCK中)擴展
SQL> commit;
提交完成。
SQL> alter system checkpoint;
系統(tǒng)已更改。
SQL> select count(*) from t;
COUNT(*)
----------
8192
SQL> connect / as sysdba
已連接。
SQL> shutdown immediate
數(shù)據(jù)庫已經(jīng)關(guān)閉。
已經(jīng)卸載數(shù)據(jù)庫。
ORACLE 例程已經(jīng)關(guān)閉。
2.損壞數(shù)據(jù)文件
關(guān)閉數(shù)據(jù)庫后用Ultredit編輯數(shù)據(jù)文件,隨便更改幾個字符.然后啟動數(shù)據(jù)庫.
SQL> startup
ORACLE 例程已經(jīng)啟動。
Total System Global Area 101785252 bytes
Fixed Size 454308 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
數(shù)據(jù)庫裝載完畢。
數(shù)據(jù)庫已經(jīng)打開。
SQL> select count(*) from eygle.t;
select count(*) from eygle.t
*
ERROR 位于第 1 行:
ORA-01578: ORACLE 數(shù)據(jù)塊損壞(文件號4,塊號35)
ORA-01110: 數(shù)據(jù)文件 4: 'E:ORACLEORADATAEYGLEBLOCK.DBF'
SQL>
此時如果查詢該表,會出現(xiàn)錯誤,數(shù)據(jù)塊損壞無法讀取.
有個內(nèi)部工具BBED也可以用來編輯數(shù)據(jù)塊的內(nèi)容
3.使用DBV檢查數(shù)據(jù)文件
E:Oracleoradataeygle>dbv file=block.dbf blocksize=8192
DBVERIFY: Release 9.2.0.4.0 - Production on 星期一 3月 8 20:48:50 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
DBVERIFY - 驗證正在開始 : FILE = block.dbf
標記為損壞的頁35
***
Corrupt block relative dba: 0x01000023 (file 4, block 35)
Bad check value found during dbv:
Data in bad block -
type: 6 format: 2 rdba: 0x01000023
last change scn: 0x0000.00049097 seq: 0x1 flg: 0x06
consistency value in tail: 0x90970601
check value in block header: 0xd6cb, computed block checksum: 0x2c0a
spare1: 0x0, spare2: 0x0, spare3: 0x0
***
標記為損壞的頁69
***
Corrupt block relative dba: 0x01000045 (file 4, block 69)
Bad check value found during dbv:
Data in bad block -
type: 6 format: 2 rdba: 0x01000045
last change scn: 0x0000.00049097 seq: 0x1 flg: 0x06
consistency value in tail: 0x90970601
check value in block header: 0x33d1, computed block checksum: 0x653
spare1: 0x0, spare2: 0x0, spare3: 0x0
***
DBVERIFY - 驗證完成
檢查的頁總數(shù) :128
處理的頁總數(shù)(數(shù)據(jù)):117
失敗的頁總數(shù)(數(shù)據(jù)):0
處理的頁總數(shù)(索引):0
失敗的頁總數(shù)(索引):0
處理的頁總數(shù)(其它):9
處理的總頁數(shù) (段) : 0
失敗的總頁數(shù) (段) : 0
空的頁總數(shù) :0
標記為損壞的總頁數(shù):2
匯入的頁總數(shù) :0
dbv檢測到壞塊.
4.尋求恢復(fù)
在這種情況下,如果有備份,需要從備份中恢復(fù)
如果沒有備份,那么壞塊部分的數(shù)據(jù)肯定要丟失了
在這個時候?qū)С鍪遣辉试S的:
E:>exp eygle/eygle file=t.dmp tables=t
Export: Release 9.2.0.4.0 - Production on 星期一 3月 8 20:54:15 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
連接到: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
已導(dǎo)出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即將導(dǎo)出指定的表通過常規(guī)路徑 ...
. . 正在導(dǎo)出表 T
EXP-00056: 遇到 ORACLE 錯誤 1578
ORA-01578: ORACLE 數(shù)據(jù)塊損壞(文件號4,塊號35)
ORA-01110: 數(shù)據(jù)文件 4: 'E:ORACLEORADATAEYGLEBLOCK.DBF'
導(dǎo)出成功終止,但出現(xiàn)警告。
5.恢復(fù)步驟
當然,對于不同的情況需要區(qū)別對待
首先你需要檢查損壞的對象,使用以下SQL:
SQL> SELECT tablespace_name, segment_type, owner, segment_name
2 FROM dba_extents
3 WHERE file_id = 4
4 and 35 between block_id AND block_id + blocks - 1
5 ;
TABLESPACE_NAME SEGMENT_TYPE OWNER SEGMENT_NAME
---------------------------------------------------------------------------
BLOCK TABLE EYGLE T
如果損失的是數(shù)據(jù),ok
我們可以設(shè)置內(nèi)部事件,使exp跳過這些損壞的block
SQL> ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10';
系統(tǒng)已更改。
note:
ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10' ;
內(nèi)部事件,設(shè)置在全表掃描時跳過損壞的數(shù)據(jù)塊.
然后我們可以導(dǎo)出未損壞的數(shù)據(jù)
SQL> host
Microsoft Windows XP [版本 5.1.2600]
(C) 版權(quán)所有 1985-2001 Microsoft Corp.
E:
E:>exp eygle/eygle file=t.dmp tables=t
Export: Release 9.2.0.4.0 - Production on 星期一 3月 8 20:57:13 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
連接到: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
已導(dǎo)出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即將導(dǎo)出指定的表通過常規(guī)路徑 ...
. . 正在導(dǎo)出表 T 8036 行被導(dǎo)出
在沒有警告的情況下成功終止導(dǎo)出。
這時候數(shù)據(jù)成功導(dǎo)出.
然后我們可以drop table,recreate,然后導(dǎo)入數(shù)據(jù)
本例中
我們損失了
8192 - 8036 = 156 行數(shù)據(jù)
SQL> connect eygle/eygle
已連接。
SQL> drop table t;
表已丟棄。
SQL> host
Microsoft Windows XP [版本 5.1.2600]
(C) 版權(quán)所有 1985-2001 Microsoft Corp.
E:Oracleora92bin>cd
E:>imp eygle/eygle file=t.dmp tables=t
Import: Release 9.2.0.4.0 - Production on 星期一 3月 8 21:12:38 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
連接到: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
經(jīng)由常規(guī)路徑導(dǎo)出由EXPORT:V09.02.00創(chuàng)建的文件
已經(jīng)完成ZHS16GBK字符集和AL16UTF16 NCHAR 字符集中的導(dǎo)入
. 正在將EYGLE的對象導(dǎo)入到 EYGLE
. . 正在導(dǎo)入表 "T" 8036行被導(dǎo)入
成功終止導(dǎo)入,但出現(xiàn)警告。
E:>exit
SQL> select count(*) from t;
COUNT(*)
----------
8036
完成數(shù)據(jù)恢復(fù)
來自 “ ITPUB博客 ” ,鏈接:http://blog.itpub.net/509190/viewspace-819829/,如需轉(zhuǎn)載,請注明出處,否則將追究法律責任。
總結(jié)
以上是生活随笔為你收集整理的oracle模块损坏,Oracle中模拟及修复数据块损坏的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ftok file php,Linux和
- 下一篇: oracle号码段拆开,知道号段起止,如