大家好,又见面了,我是全栈君。
[20161111]数据文件的第0块2.txt
–如果数据文件的第0块是OS块信息,以前的测试如果rman做备份集都不会备份。
–如果这块损坏,里面讲问题不大,你甚至可以不修复,如果在线resize就ok了,当然重建控制文件就出现问题。
–而且解决也很简单,就是建立一样大小的数据文件,然后copy回去。做一个测试例子:
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
—————————— ————– ——————————————————————————–
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
CREATE TABLESPACE SUGAR DATAFILE
‘/mnt/ramdisk/book/sugar01.dbf’ SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
create table t1 tablespace sugar as select rownum id ,lpad(‘A’,32,’A’) name from dual connect by level<=1e5;
alter system checkpoint;
CREATE TABLESPACE TEA DATAFILE
‘/mnt/ramdisk/book/tea01.dbf’ SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
–昨天的测试无法在bbed下使用copy file 7 block 0 to file 6 block 0,实际上无法识别数据文件6的os头。这样变成了block=1.
2.重新测试:
SCOTT@book> alter tablespace sugar offline ;
Tablespace altered.
SCOTT@book> alter tablespace tea offline ;
Tablespace altered.
–设置数据文件6 sugar01.dbf的第0块全为0.
3.使用bbed修复:
BBED> copy file 7 block 0 to file 6 block 0
BBED-00309: out of range block number (0)
–实际上晚上在回家的路上才想起来问题在那里。我以前在windows下使用bbed,也遇到修改11g的数据文件,访问block必须加1,实际上
–就是无法识别11g数据文件的块头。
BBED> dump /v file 7 block 0 count 256 offset 0
File: /mnt/ramdisk/book/tea01.dbf (7)
Block: 0 Offsets: 0 to 255 Dba:0x01c00000
———————————————————————————————————–
00a20000 0000c0ff 00000000 00000000 66ee0000 00200000 00140000 7d7c7b7a l …………….f…. ……}|{z
a0810000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
<32 bytes per line>
BBED> dump /v file 6 block 1 count 256 offset 0
BBED-00309: out of range block number (0)
BBED> dump /v file 6 block 1 count 256 offset 0
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 1 Offsets: 0 to 255 Dba:0x01800001
———————————————————————————————————–
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l …………………………..
<32 bytes per line>
— 这样要在bbed下执行应该是(不过还是要小心,至少仔细看一下里面的内容,避免错误)。
— 而且我遇到奇怪的问题每次按照如下顺序执行:
dump /v file 7 block 0 count 256 offset 0
dump /v file 6 block 1 count 256 offset 0
dump /v file 6 block 1 count 256 offset 0
–第2步总是报错BBED-00309: out of range block number (0),但是我反过来就没有问题。
dump /v file 6 block 1 count 256 offset 0
dump /v file 7 block 0 count 256 offset 0
— 注意一定要在执行copy前看一下里面的内容,避免写入错误的位置,还是不推荐这种操作模式。
copy file 7 block 0 to file 6 block 1
BBED> copy file 7 block 0 to file 6 block 1
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 1 Offsets: 0 to 255 Dba:0x01800001
————————————————————————————————————————————————
00a20000 0000c0ff 00000000 00000000 66ee0000 00200000 00140000 7d7c7b7a a0810000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<64 bytes per line>
–补充如果这样顺序执行,到copy是第1次出错,第2次ok:
dump /v file 6 block 1 count 256 offset 0
dump /v file 7 block 0 count 256 offset 0
BBED> copy file 7 block 0 to file 6 block 1
BBED-00309: out of range block number (0)
BBED> copy file 7 block 0 to file 6 block 1
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 1 Offsets: 0 to 255 Dba:0x01800001
————————————————————————————————————————————————
00a20000 0000c0ff 00000000 00000000 66ee0000 00200000 00140000 7d7c7b7a a0810000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<64 bytes per line>
–完成后退出bbed,再看一下,步骤略。
4.检查是否正常:
SCOTT@book> alter tablespace sugar online ;
Tablespace altered.
SCOTT@book> select count(*) from t1;
COUNT(*)
———-
100000
总结:
还是不推荐这样操作,仅仅为了了解学习的必要。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/108788.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...