温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

sysaux表空间数据库块损坏/游离块的修复

发布时间:2020-05-13 03:13:02 来源:网络 阅读:669 作者:三国冷 栏目:数据库

  客户那边的数据库久无人维护,近期反映服务器空间不够。在检查服务器空间时,我又偶然发现了数据库的备份出现问题。

  经检查是数据库sysaux表空间存在一个坏块,存在坏块的表是WRH$_ENQUEUE_STAT,在测试库上查询数据后,我确定该表的数据对整个系统的运行影响不大。

  此时没有RMAN备份可以使用,block recover无法使用。于是决定将表删除重建。不过这么做之后,原有的数据块反而变成了游离块。为了修复游离块,我就在测试库上开始做测试。

1、模拟数据库损坏

1)模拟数据库的损坏可以使用ddbd,该工具的配置可以参考以下链接:

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

2)模拟要损坏的块

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

结果是file_id=2,block_id=4440

modify /x 62 file 2 block 4440 offset 255;

3)rman命令中,执行 backup validate database或者 backup validate datafile 2;

使用视图v$database_block_corruption查看backup操作发现的损坏的块。

select * from v$database_block_corruption;

4)表删除并且重建,发现file2 4440变成了游离块

select * from dba_extents where file_id=2 and 4440 between block_id-1 and block_id+1;#查询无数据

2、坏块修复

1)表空间修改为不能自动增长

alter database datafile 2 autoextend off;

2)在sysaux上创建实体表

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

3)插入数据直到报ORA01653的错误,连insert into test values('aaaaaaaaaa')都执行失败

insert into test values('aaaaaaaaaa');

commit;


insert into test

select *

from test;

commit;


4)再创建一张实体表

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

-- 查看file 2 block_id 4440 是否有数据

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的数据。


5)删除测试表

drop table test_1;

drop table test;


6)表空间增长模式改为自动增长

alter database datafile 2 autoextend on;


7) 在RMAN中测试备份,可以正常执行全备。

RMAN>backup incremental level 0 database;


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI