溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

sysaux表空間數(shù)據(jù)庫(kù)塊損壞/游離塊的修復(fù)

發(fā)布時(shí)間:2020-05-13 03:13:02 來源:網(wǎng)絡(luò) 閱讀:678 作者:三國(guó)冷 欄目:數(shù)據(jù)庫(kù)

  客戶那邊的數(shù)據(jù)庫(kù)久無人維護(hù),近期反映服務(wù)器空間不夠。在檢查服務(wù)器空間時(shí),我又偶然發(fā)現(xiàn)了數(shù)據(jù)庫(kù)的備份出現(xiàn)問題。

  經(jīng)檢查是數(shù)據(jù)庫(kù)sysaux表空間存在一個(gè)壞塊,存在壞塊的表是WRH$_ENQUEUE_STAT,在測(cè)試庫(kù)上查詢數(shù)據(jù)后,我確定該表的數(shù)據(jù)對(duì)整個(gè)系統(tǒng)的運(yùn)行影響不大。

  此時(shí)沒有RMAN備份可以使用,block recover無法使用。于是決定將表刪除重建。不過這么做之后,原有的數(shù)據(jù)塊反而變成了游離塊。為了修復(fù)游離塊,我就在測(cè)試庫(kù)上開始做測(cè)試。

1、模擬數(shù)據(jù)庫(kù)損壞

1)模擬數(shù)據(jù)庫(kù)的損壞可以使用ddbd,該工具的配置可以參考以下鏈接:

http://www.cnblogs.com/jyzhao/p/5139584.html

2)模擬要損壞的塊

select file_id,block_id from dba_extents where segment_name='WRH$_ENQUEUE_STAT';

結(jié)果是file_id=2,block_id=4440

modify /x 62 file 2 block 4440 offset 255;

3)rman命令中,執(zhí)行 backup validate database或者 backup validate datafile 2;

使用視圖v$database_block_corruption查看backup操作發(fā)現(xiàn)的損壞的塊。

select * from v$database_block_corruption;

4)表刪除并且重建,發(fā)現(xiàn)file2 4440變成了游離塊

select * from dba_extents where file_id=2 and 4440 between block_id-1 and block_id+1;#查詢無數(shù)據(jù)

2、壞塊修復(fù)

1)表空間修改為不能自動(dòng)增長(zhǎng)

alter database datafile 2 autoextend off;

2)在sysaux上創(chuàng)建實(shí)體表

create table test(id varchar(50)) tablespace sysaux;

3)插入數(shù)據(jù)直到報(bào)ORA01653的錯(cuò)誤,連insert into test values('aaaaaaaaaa')都執(zhí)行失敗

insert into test values('aaaaaaaaaa');

commit;


insert into test

select *

from test;

commit;


4)再創(chuàng)建一張實(shí)體表

create table test_2(id varchar(50)) tablespace sysaux;

-- 查看file 2 block_id 4440 是否有數(shù)據(jù)

select * from dba_extents where file_id=2 and 4440 between block_id-1 and block_id+1;#模擬到此步,file 2 block_id 4440查詢出來為test_2的數(shù)據(jù)。


5)刪除測(cè)試表

drop table test_1;

drop table test;


6)表空間增長(zhǎng)模式改為自動(dòng)增長(zhǎng)

alter database datafile 2 autoextend on;


7) 在RMAN中測(cè)試備份,可以正常執(zhí)行全備。

RMAN>backup incremental level 0 database;


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI