首页 > 其他分享 >[20231020]rename IDL_UB1$后使用bbed的恢复.txt

[20231020]rename IDL_UB1$后使用bbed的恢复.txt

时间:2023-10-23 21:56:46浏览次数:34  
标签:rename NULL UB1 -- dba IDL book txt col

[20231020]rename IDL_UB1$后使用bbed的恢复.txt

--//继续前面的测试:
--//参考链接: [20231019]rename IDL_UB1$的恢复测试前准备.txt

1.环境:
SYS@book> @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

2.开始测试:

SYS@book> rename IDL_UB1$ to IDL_UB1X;
Table renamed.

SYS@book> alter system checkpoint;
System altered.

alter system checkpoint;
alter system checkpoint;

$ strings -t d /mnt/ramdisk/book/system01.dbf | grep 'IDL_UB1X'| awk '{print int($1/8192), " ",$1-int($1/8192)*8192, " " ,$2}'
351   3983   IDL_UB1X
375   3983   IDL_UB1X
86182   3867   IDL_UB1X

--//为了测试方便,我贴上前面的测试结果(删除多余部分),可以发现偏移都不对.
--//其中的86182对应一定是obj$.居然没有就地修改,位置发生了变动,包括索引.
--//如果关闭数据库,数据库可能无法启动.(注:我后面的测试说明可以正常启动,仅仅一些涉及包的命令无法正常使用)
--//原来的结果如下.
$ strings -t d /mnt/ramdisk/book/system01.dbf | grep 'IDL_UB1\$'| awk '{print int($1/8192), " ",$1-int($1/8192)*8192, " " ,$2}'
243   6325   IDL_UB1$
351   5692   IDL_UB1$
375   5692   IDL_UB1$

3.对比分析:
--//dba 1,243
BBED> x  /rnnncncntttnccnxnnncct dba 1,243 *kdbr[23]
rowdata[5215]                               @6311
-------------
flag@6311: 0x3c (KDRHFL, KDRHFF, KDRHFD, KDRHFH)
lock@6312: 0x01
cols@6313:    0
--//可以发现记录已经做了删除标识,KDRHFD表示删除标识。

BBED> x  /rnnncncntttnccnxnnncct dba 1,86182 *kdbr[6]
rowdata[0]                                  @3853
----------
flag@3853: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@3854: 0x01
cols@3855:   18

col    0[3] @3856: 225
col    1[3] @3860: 225
col    2[1] @3864: 0
col    3[8] @3866: IDL_UB1X
col    4[2] @3875: 1
col    5[0] @3878: *NULL*
col    6[2] @3879: 2
col    7[7] @3882: 2013-08-24 11:37:39
col    8[7] @3890: 2023-10-20 10:48:44
col    9[7] @3898: 2023-10-20 10:48:44
col   10[2] @3906: 1
col   11[0] @3909: *NULL*
col   12[0] @3910: *NULL*
col   13[1] @3911: 0
col   14[0] @3913: *NULL*
col   15[1] @3914: 0
col   16[2] @3916: 2
~~~~~~~~~~~~~~~~~~~
col   17[1] @3919: 0
--//正常应该是0x2c。

--//原来的dba =1,243的样子:
BBED> x  /rnnncncntttnccnxnnncct dba 1,243 *kdbr[23]
rowdata[5215]                               @6311
-------------
flag@6311: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6312: 0x00
cols@6313:   18

col    0[3] @6314: 225
col    1[3] @6318: 225
col    2[1] @6322: 0
col    3[8] @6324: IDL_UB1$
col    4[2] @6333: 1
col    5[0] @6336: *NULL*
col    6[2] @6337: 2
col    7[7] @6340: 2013-08-24 11:37:39
col    8[7] @6348: 2013-08-24 11:37:39
col    9[7] @6356: 2013-08-24 11:37:39
col   10[2] @6364: 1
col   11[0] @6367: *NULL*
col   12[0] @6368: *NULL*
col   13[1] @6369: 0
col   14[0] @6371: *NULL*
col   15[1] @6372: 0
col   16[2] @6374: 1
~~~~~~~~~~~~~~~~~~~~
col   17[1] @6377: 0
--//长度并没有变化,col 16值不同(事后检查spare1),可以猜测rename实际上先delete原来记录,然后在插入一条.并不是就地修改.导致
--//索引的位置也发生了不再原来位置,索引我仅仅改动最后1个字符,应该还在原来的块中.

BBED> x /rncncccnnn dba 1,351 *kd_off[36]
rowdata[1713]                               @5681
-------------
flag@5681:     0x01 (KDXRDEL)
lock@5682:     0x02
keydata[6]:    0x00  0x40  0x00  0xf3  0x00  0x17
data key:
col    0[1] @5690: 0
col    1[8] @5692: IDL_UB1$
col    2[2] @5701: 1
col    3[0] @5704: *NULL*
col    4[0] @5705: *NULL*
col    5[0] @5706: *NULL*
col    6[2] @5707: 2
col    7[1] @5710: 0
col    8[3] @5712: 225
--//现在flag@5681:     0x01 (KDXRDEL),标识删除.

BBED> x /rncncccnnn dba 1,351 *kd_off[37]
rowdata[4]                                  @3972
----------
flag@3972:     0x00 (NONE)
lock@3973:     0x02
keydata[6]:    0x00  0x41  0x50  0xa6  0x00  0x06
data key:
col    0[1] @3981: 0
col    1[8] @3983: IDL_UB1X
col    2[2] @3992: 1
col    3[0] @3995: *NULL*
col    4[0] @3996: *NULL*
col    5[0] @3997: *NULL*
col    6[2] @3998: 2
col    7[1] @4001: 0
col    8[3] @4003: 225
--//索引的恢复很简单设置flag对调就ok了.

BBED> x /rncnnnnccn dba 1,375 *kd_off[36]
rowdata[1713]                               @5681
-------------
flag@5681:     0x01 (KDXRDEL)
lock@5682:     0x02
keydata[6]:    0x00  0x40  0x00  0xf3  0x00  0x17
data key:
col    0[1] @5690: 0
col    1[8] @5692: IDL_UB1$
col    2[2] @5701: 1
col    3[2] @5704: 2
col    4[1] @5707: 0
col    5[0] @5709: *NULL*
col    6[0] @5710: *NULL*
col    7[0] @5711: *NULL*
col    8[3] @5712: 225
--//现在flag@5681:     0x01 (KDXRDEL),标识删除.

BBED> x /rncnnnnccn dba 1,375 *kd_off[37]
rowdata[4]                                  @3972
----------
flag@3972:     0x00 (NONE)
lock@3973:     0x02
keydata[6]:    0x00  0x41  0x50  0xa6  0x00  0x06
data key:
col    0[1] @3981: 0
col    1[8] @3983: IDL_UB1X
col    2[2] @3992: 1
col    3[2] @3995: 2
col    4[1] @3998: 0
col    5[0] @4000: *NULL*
col    6[0] @4001: *NULL*
col    7[0] @4002: *NULL*
col    8[3] @4003: 225

--//有了以上相关信息恢复就很简单了.
--//恢复对应数据块243块号,在86182块做删除标识,恢复原来的索引指向(块号351,375).

4.关闭数据库看看,开始bbed恢复测试:
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@book> startup
ORACLE instance started.
Total System Global Area  643084288 bytes
Fixed Size                  2255872 bytes
Variable Size             205521920 bytes
Database Buffers          427819008 bytes
Redo Buffers                7487488 bytes
Database mounted.
Database opened.
--//实际上数据库open一点问题都没有.

SYS@book> @ ddl scott.dept
BEGIN dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'PRETTY',true); END;

*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist

--//实际一些包会报错.也就是实际上  select * from obj$ where name ='IDL_UB1X';输出正常.
--//但是如果你调用一些包就出现问题.
SYS@book> @ rowid AAAYD0AAIAAMqfEAAF
       || DBMS_ROWID.ROWID_BLOCK_NUMBER ('AAAYD0AAIAAMqfEAAF')
          *
ERROR at line 13:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist

--//实际上恢复就变得很简单了.直接修改数据字段obj$字段就ok了.但是我的目的是使用bbed完成恢复,继续操作。
--//在bbed下执行执行如下操作。
assign dba 1,243   offset 6311 = 0x2c
assign dba 1,86182 offset 3853 = 0x3c

assign dba 1,351   offset 5681 =0x0
assign dba 1,351   offset 3972 =0x1

assign dba 1,375   offset 5681 =0x0
assign dba 1,375   offset 3972 =0x1

5.修复数据块的一致性.
--//然后开始修复数据块的一致性.
--//dba 1,243
BBED> set dba 1,243
        DBA             0x004000f3 (4194547 1,243)

BBED> sum apply
Check value for File 1, Block 243:
current = 0x73b6, required = 0x73b6

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 243

Block Checking: DBA = 4194547, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: the amount of space used is not equal to block size
        used=7298 fsc=66 avsp=822 dtl=8120
Block 243 failed with check code 6110

--//简单公式:
--//code 6110
--//avsp = dtl-used-fsc
--//code 6111
--//tosp = avsp+stb+fsc

--//avsp = dtl-used-fsc
--//avsp= 8120-7298-66 = 756

BBED> assign kdbh.kdbhavsp=756
sb2 kdbhavsp                                @78       756

BBED> sum apply
Check value for File 1, Block 243:
current = 0x7274, required = 0x7274

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 243

Block Checking: DBA = 4194547, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: space available on commit is incorrect
        tosp=890 fsc=66 stb=0 avsp=756
Block 243 failed with check code 6111

--//tosp = avsp+stb+fsc
--//tosp= 756+0+66  = 822
BBED> assign kdbh.kdbhtosp=822
sb2 kdbhtosp                                @80       822

BBED> sum apply
Check value for File 1, Block 243:
current = 0x7238, required = 0x7238

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 243

--//其它块基本类似.不再具体说明.

--//dba 1,86182
BBED> set dba 1,86182
        DBA             0x004150a6 (4280486 1,86182)

BBED> sum apply
Check value for File 1, Block 86182:
current = 0x84ea, required = 0x84ea

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 86182

Block Checking: DBA = 4280486, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: the amount of space used is not equal to block size
        used=3098 fsc=0 avsp=4956 dtl=8120
Block 86182 failed with check code 6110

--//avsp =8120-3098-0 = 5022
BBED> assign kdbh.kdbhavsp=5022
sb2 kdbhavsp                                @78       5022

BBED> sum apply
Check value for File 1, Block 86182:
current = 0x8428, required = 0x8428

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 86182

Block Checking: DBA = 4280486, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: avsp(5022) > tosp(4956)
Block 86182 failed with check code 6128

BBED> assign kdbh.kdbhtosp=5022
sb2 kdbhtosp                                @80       5022

BBED> sum apply
Check value for File 1, Block 86182:
current = 0x84ea, required = 0x84ea

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 86182

Block Checking: DBA = 4280486, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: space available on commit is incorrect
        tosp=5022 fsc=0 stb=2 avsp=5022
Block 86182 failed with check code 6111

--//tosp=5022+0+2=5024.
BBED> assign kdbh.kdbhtosp=5024
sb2 kdbhtosp                                @80       5024

BBED> sum apply
Check value for File 1, Block 86182:
current = 0x84d4, required = 0x84d4

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 86182

--//dba 1,351
BBED> set dba 1,351
        DBA             0x0040015f (4194655 1,351)

BBED> sum apply
Check value for File 1, Block 351:
current = 0xa100, required = 0xa100

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 351

--//dba 1,375
BBED> set dba 1,375
        DBA             0x00400177 (4194679 1,375)

BBED> sum apply
Check value for File 1, Block 375:
current = 0x1923, required = 0x1923

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 375
--//索引不需要恢复.很好理解长度都没有变化。

6.看看恢复情况:
SYS@book> startup
ORACLE instance started.
Total System Global Area  643084288 bytes
Fixed Size                  2255872 bytes
Variable Size             205521920 bytes
Database Buffers          427819008 bytes
Redo Buffers                7487488 bytes
Database mounted.
Database opened.
SYS@book> @ ddl scott.dept
C300
------------------------------------------------------------------------
CREATE TABLE "SCOTT"."DEPT"
   (    "DEPTNO" NUMBER(2,0),
        "DNAME" VARCHAR2(14),
        "LOC" VARCHAR2(13),
         CONSTRAINT "PK_DEPT" PRIMARY KEY ("DEPTNO")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE
   ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;

SYS@book> @ rowid AAAYD0AAIAAMqfEAAF
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     98548          8    3319748          5  0x232A7C4           8,3319748            alter system dump datafile 8 block 3319748 ;

--//没有任何问题.检查看看:
SYS@book> validate index i_obj2;
Index analyzed.

SYS@book> validate index i_obj5;
Index analyzed.

SYS@book> select * from obj$ where name ='IDL_UB1$'
  2  @ pr
==============================
OBJ#                          : 225
DATAOBJ#                      : 225
OWNER#                        : 0
NAME                          : IDL_UB1$
NAMESPACE                     : 1
SUBNAME                       :
TYPE#                         : 2
CTIME                         : 2013-08-24 11:37:39
MTIME                         : 2013-08-24 11:37:39
STIME                         : 2013-08-24 11:37:39
STATUS                        : 1
REMOTEOWNER                   :
LINKNAME                      :
FLAGS                         : 0
OID$                          :
SPARE1                        : 0
SPARE2                        : 1
SPARE3                        : 0
SPARE4                        :
SPARE5                        :
SPARE6                        :
PL/SQL procedure successfully completed.

SYS@book> analyze table IDL_UB1$ validate structure cascade;
Table analyzed.
--//OK.实际上最简单还是直接修改数据字典obj$,我的测试可以关闭数据库重启在修改数据字段应该没有任何问题,bbed恢复纯粹为了练
--//习.

$ dbv file=/mnt/ramdisk/book/system01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Fri Oct 20 11:52:54 2023
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
DBVERIFY - Verification starting : FILE = /mnt/ramdisk/book/system01.dbf
DBVERIFY - Verification complete

Total Pages Examined         : 97280
Total Pages Processed (Data) : 64260
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 13456
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 4206
Total Pages Processed (Seg)  : 1
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 15358
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 392188896 (3.392188896)

7.总结:
--//如果rename后修改长度不等长,情况要复杂一点,不过鉴于数据库能正常重启并open,修改数据字典也许更加简单。
--//后续rename后修改长度不等长的情况测试就不作了。

标签:rename,NULL,UB1,--,dba,IDL,book,txt,col
From: https://www.cnblogs.com/lfree/p/17783567.html

相关文章

  • [20231020]增加字段的问题.txt
    [20231020]增加字段的问题.txt--//测试生产系统遇到的增加字段的相关问题.非常容易混乱,我还是给自己测试看看,加强记忆.1.环境:[email protected]:1521/orcl>@[email protected]:1521/orcl>@pr==============================PORT_STRING                 ......
  • [20231020]为什么刷新缓存后输出记录顺序发生变化5.txt
    [20231020]为什么刷新缓存后输出记录顺序发生变化5.txt--//前几天做了单表刷新缓存后输出记录顺序发生变化的情况,今天测试2个表的情况。--//我遇到一个奇怪的现象,做一个记录,我无法使用10046跟踪.1.环境:[email protected]:1521/orcl>@[email protected]:1521/orcl>@pr=======......
  • 【实测有效】.epub文件如何批量转换为word/AZW3/MOBI/DOCX/RTF/TXT/HTMLZ? 附工具下载
    常见电子书格式有很多种,其中有一种.epub格式,这种格式的文件比较多,也比较容易找到,阅读器也有多款软件支持。国内用的相对多点的比如ApabiReader。有时候,.epub文件明明是正常的,但ApabiReader却会报错而无法打开。上篇优爱酷分享了如何将.epub文件转换为可编辑的word,但是手动操作比......
  • CmakeList.txt语法
    CmakeList语法PROJECT(hello)#PROJECT(名称,语言):指定工程名称和支持的语言#PROJECT(hello,CCXX):指定了工程名称,支持C和C++SET(SRC_LISTmain.cpp)#SET():用来显示指定变量#SET(SRC_LISTmain.cpptest.cpp)MESSAGE(STATUS"ThisisBINARYdir"${HELLO_BINARY_......
  • php读取txt随机一行一个数据输出
    php读取txt随机一行一个数据输出,代码如下<?phpfunctiongetline($file){$i=0;do{$data=file($file);$num=count($data);$id=mt_rand(0,$num-1);$shuju_text=chop($data[$id]);$i=strlen($shuju_text);}while($i<1);ech......
  • 使用python将txt文件中的ip地址转换成当地城市名称
    具体代码importreimportrequestsimportconcurrent.futures#用于匹配IPv4地址的正则表达式ipv4_pattern=re.compile(r'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b')#用于发送API请求并获取城市信息的函数defget_city_info(ip):response=requests.get(f'http://ip-......
  • 使用python对txt文件的日期格式进行清洗
    我使用的Java对文件日期进行清洗,看到友友用的python清洗,就问了问应该如何做,代码是能看懂,但是若是要求我自己一步一步写的话,应该不太行~具体代码importrefromdatetimeimportdatetime#读取文件withopen('result3.txt','r')asfile:data=file.read()#使用正......
  • 递归查找目录下的所有txt文件
    #include<dirent.h>#include<fcntl.h>#include<stdio.h>#include<stdlib.h>#include<string.h>#include<sys/stat.h>#include<sys/types.h>#include<unistd.h>intgetTxtNum(constchar*path){//打开目录......
  • c++如何读取txt文件内容
    一、c++文件流:fstream //文件流ifstream //输入文件流ofstream //输出文件流 二、文件路径的表示1、绝对路径:inf.open("d://DEV_C++//LogFile//游泳数据//LUYINGYAN1039_SensorLog.txt");   注意:双斜线"\\" 2、相对路径:对相对路径而言,路......
  • [20230922]dc命令复杂学习3.txt
    [20230922]dc命令复杂学习3.txt1.问题提出:--//前一段时间简单学习了dc,累加的例子:$cata.txt1111222233334444$cata.txt|dc-f--e"[+z1<r]srz1<rp"11110$dc-fa.txt-e"[+z1<r]srz1<rp"11110--//实际上如果累加数据量很大,这样的执行效率很低的,因为每次都要判断堆......