您好,登錄后才能下訂單哦!
客戶那邊的數(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;
免責(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)容。