[zt] 如何處理Oracle資料庫中的壞塊[final]
oracle的資料塊有固定的格式和結構,分三層: cache layer、transaction layer和data layer.
對資料塊進行讀寫操作時,做一致性檢查:
–block type
–dba
–scn
–header and tail
發現不一致,標記為壞塊。
壞塊有兩種: 物理壞塊和邏輯壞塊。
壞塊產生的影響:資料字典表、回滾段表、臨時段和使用者資料表和索引。
應用報錯:
–ora-1578
–ora-600 and trace file in bdump directory
第一個引數[2000]-[8000]
range block layer
-------------------------------------------
cache layer 2000 – 4000
transaction layer 4000 – 6000
data layer 6000 - 8000
壞塊產生的原因:
oracle呼叫標準c的系統函式,對資料塊進行讀寫操作:
- bad i/o, h/w, firmware.
- operating system i/o or caching problems.
- memory or paging problems.
- disk repair utilities.
- part of a datafile being overwritten.
- third part software incorrectly attempting to access oracle used heap.
- oracle or operating system bug.
表中壞塊的處理方法:
(1).收集相關資訊:
ora-1578 file# (rfn) block#
ora-1110 file# (afn) block#
ora-600 file# (afn) block#
select file_name,tablespace_name,file_id “afn”, relative_fno “rfn” from dba_data_files;
select file_name,tablespace_name,file_id, relative_fno “rfn” from dba_temp_files;
9i tempfiles afn=file_id+value of db_files
(2).確定受影響的物件:
select tablespace_name, segment_type, owner, segment_name, partition_name from dba_extents where file_id =
if on tempfile, no data return;
(3).根據物件型別,確定處理方法:
objects of sys
rollback
temporary segment
index and index partition
cluster |
partition | ===>表中壞塊的處理
table |
(4).選擇合適的方法搶救表中的資料:
recover datafile
recover block only (9i)
透過rowid range scan 儲存資料
使用dbms_repair
使用event
表中壞塊的處理方法一:恢復資料檔案
資料庫為歸檔方式,有完整的物理備份
offline the affected data file
alter database datafile name_file offline;
儲存有壞塊的檔案,restore 備份。
if different from the old location
alter database rename file old_name to new_name;
recover the datafile
recover datafile name_of_file;
online the file/s
alter database datafile name_of_file online;
表中壞塊的處理方法二:block recover
需求
(1).資料庫9.2
(2).catalog 和rman
(3).資料庫為歸檔方式,有完整的物理備份
(4).使用rman的blockrecover命令
rman>run{blockrecover
datafile 3 block 4,5;}
能強制使用某個scn號之前的備份,恢復資料塊。
rman>run{blockrecover
datafile 3 block 4,5 restore until sequence 7402;}
表中壞塊的處理方法三:rowid range scan
使用dbms_rowid 確定壞塊的rowid range
low_rid inside the corrupt block:
select dbms_rowid.rowid_create(1,
hi_rid after the corrupt block:
dbms_rowid.rowid_create(1,
建一個臨時表
create table salvage_table as select * from corrupt_tab where 1=2;
儲存未損壞的資料
insert into salvage_table select /*+ rowid(a) */ * from
insert into salvage_table select /*+ rowid(a) */ * from
重建table,index,foreign constrain table.
表中壞塊的處理方法四:add 10231 event
在session 或database級設10231 event,做全表掃描時,能跳過壞塊.
session level:
alter session set events 10231 trace name context forever,level 10;
create table salvage_emp as select * from corrupt_emp;
database level:
event="10231 trace name context forever, level 10"
表中壞塊的處理方法五:dbms_repair
標記有壞塊的表,做全表掃描時,能跳過壞塊.
execute dbms_repair.skip_corrupt_blocks(
儲存表中資料
export the table.
create table salvage_emp as select * from corrupt_emp;
表中壞塊的處理方法六:檢查索引
檢查表上的索引和primary key foreign key約束
select owner,index_name, index_type from dba_indexes where table_owner=‘xxxx and table_name=xxxx;
select owner,constraint_name,constraint_type,table_name from dba_constraints where wner=xxx and table_name=xxx and
constraint_type=p;
select owner,constraint_name,constraint_type,table_name from dba_constraints where r_owner=xxxx and r_constraint_name=
怎麼預先發現壞塊:
(1).export utility
exp system/manager full=y log=exp_db_chk.log file=/dev/null volsize=100g
does not detect disk corruptions above the high water mark
does not detect corruptions in indexes
does not detect all corruptions in the data dictionary
analyze table tablename validate structure cascade
performs the block checks ,but does not mark blocks as corrupt.
it also checks that table and index entries match.
any problems found are reported into the user session trace file in user_dump_dest.
能定期對一些重要的表作檢查.
(2).dbv檢查資料檔案
show parameter db_block_size
select bytes/2048 from v$datafile where file#=5;
dbv file=/dev/rdsk/r1.dbf blocksize=2048 end=5120
dbv expects a filename extension. if on raw dev
ln -s /dev/rdsk/mydevice /tmp/mydevice.dbf
now use dbv against /tmp/mydevice.dbf
---
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-674775/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何處理Oracle資料庫中的壞塊問題(轉)Oracle資料庫
- 一次ORACLE資料庫undo壞塊處理Oracle資料庫
- Oracle壞塊處理Oracle
- Oracle資料庫處理壞塊問題常用命令Oracle資料庫
- Oracle資料庫出現ORA-19566 LOB壞塊的處理記錄Oracle資料庫
- 一個簡單易用的資料庫壞塊處理方案資料庫
- Oracle資料庫壞塊典型案例分析Oracle資料庫
- 【BLOCK】Oracle壞塊處理命令參考BloCOracle
- Oracle資料庫壞塊典型案例擴充Oracle資料庫
- Oracle資料庫中的逐行處理問題NEOracle資料庫
- 修改Oracle資料庫字符集(zt)Oracle資料庫
- MySQL資料庫InnoDB壞頁處理修復MySql資料庫
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- oracle 普通表空間資料檔案壞塊Oracle
- 一次壞塊的處理過程(一)
- 一次壞塊的處理過程(二)
- oracle壞塊(二)Oracle
- MySQL資料庫INNODB表損壞修復處理過程分享MySql資料庫
- 學習這篇Oracle資料庫檔案壞塊損壞的恢復方法,擴充你的知識面Oracle資料庫
- Oracle日常問題處理-資料庫無法啟動Oracle資料庫
- 伺服器Oracle資料庫損壞修復伺服器Oracle資料庫
- oracle遊標批次處理資料Oracle
- 【LINUX】Oracle資料庫 linux磁碟頭資料損壞修復LinuxOracle資料庫
- go 如何處理資料庫返回的多結果集Go資料庫
- 執行在容器中Postgres資料庫資料損壞後如何恢復?資料庫
- ORACLE資料庫中如何插入生僻字Oracle資料庫
- Oracle資料庫不同損壞級別的恢復詳解Oracle資料庫
- java 如何簡單快速處理 json 中的資料JavaJSON
- java 如何簡單快速處理 xml 中的資料JavaXML
- [20190718]12c壞塊處理一例.txt
- 銀河麒麟系統安裝ORACLE資料庫問題處理Oracle資料庫
- Oracle資料庫中遇到的坑Oracle資料庫
- python中多程式處理資料庫連線的問題Python資料庫
- 常見的wait等待事件及處理(zt)AI事件
- Oracle資料庫中convert()函式,在瀚高資料庫中如何替換使用?Oracle資料庫函式
- Polars提供Javascript的資料處理庫 - levelupJavaScript
- 資料庫故障處理優質文章彙總(含Oracle、MySQL、MogDB等)資料庫OracleMySql
- SYBASE資料庫dbcc命令詳解(zt)資料庫
- oracle redo各種狀態(inactive、active、current)損壞的處理方式Oracle Redo