[20190212]删除tab$记录的恢复3.txt

--//春节前几天做了删除tan$记录的测试,链接:
http://blog.itpub.net/267265/viewspace-2565245/=> [20190130]删除tab$记录的恢复.txt
http://blog.itpub.net/267265/viewspace-2565250/=> [20190130]删除tab$记录的恢复2.txt

--//实际上我一直认为能拷贝出来数据就ok了.这样恢复的数据库不能在使用,问题多多.
--//我继续测试实际上建表等操作都会报类似的:
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [94232], [6110], [], [], [], [], [], [], [], []
--//这样的错误.主要问题在于system块的检查更加严格.

--//今天尝试恢复6110,6111,6112之类的错误.

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

--//前面已经恢复只读状态exp操作是正常的.具体看前面的文章.
--//首先更正前面脚本的几个错误:http://blog.itpub.net/267265/viewspace-2565250/=> [20190130]删除tab$记录的恢复2.txt

57                 echo "x /rx dba $dba *kdbr[$begin]" | rlbbed | egrep "^^flag@.*: *0x7c" > /dev/null
--//原来写成echo "x /rx dba $dba *kdbr[$begin]" | rlbbed | egrep "^^flag@.*: 0x7c" > /dev/null ,可能出现多个空格的情况.
 58                 if [ $? -eq 0 ]
 59                 then
 60                     echo "dba=$dba;ckix_value=0" >> scan4a.txt
 61                 fi

$ cat scana.sh
#! /bin/bash
cat clearout.txt | while read dba
do
    echo set dba $dba
    echo -n "assign "
    echo -e  "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$"| egrep "ktbbhitl|ktbitflg" | cut -c11-21,55-60 | paste -d. - - | sed -e 's/   /=/'
--//这里写错,原来写成4204236,实际上应该是$dba,
    echo sum apply dba $dba
done

--//注:http://blog.itpub.net/267265/viewspace-2565250/=> [20190130]删除tab$记录的恢复2.txt 里面的脚本已经更正.

2.我前面做了冷备份.首先恢复冷备份:
$ /bin/cp -r /home/oracle/backup/book_20190122_bad/* /mnt/ramdisk/book/
*/

$ . scan.sh
process 1 start : 2019/02/12 08:45:44 scan dba 1,144 ,  create scan1.txt about ktetbdba,ktetbnbk
process 1 finish: 2019/02/12 08:45:44,enter continue...
process 2 start : 2019/02/12 08:45:45 scan block , get kdbtnrow,kdbtoffs ang grep kdbtnrow=0
process 2 finish: 2019/02/12 08:46:16,enter continue...
process 3 start : 2019/02/12 08:46:50 scan block , create bbed'script scan3_bbed.txt for modify delete of flag  and create scan4a.txt about block of ckix
process 3 finish: 2019/02/12 08:52:01,enter continue...
process 4 start : 2019/02/12 08:52:06 create bbed's scan4_bbed.txt for modify cluster of mref of value
process 4 finish: 2019/02/12 08:53:12,enter continue...
process 5 start : create bbed's scan5_bbed.txt for sum apply
process 5 finish: 2019/02/12 08:54:11,enter continue...

--//查看生成的bbed脚本:
$ cat scan4m_bbed.txt
assign dba 4288539 offset 8169 = 1
assign dba 4288546 offset 8145 = 1

--//前面我提到过这2块dba的不需要恢复(里面记录的scn不是这个事务产生的),或者讲scan4m_bbed.txt脚本记录的dba可能存在多恢复记录的情况.最好仔细检查.

$ grep -v 0x6c scan3_bbed.txt
assign /x dba 4194451 offset 7349 = 0x20
assign /x dba 4197642 offset 7888 = 0x20
assign /x dba 4207636 offset 7087 = 0x20
assign /x dba 4225801 offset 3621 = 0x4c
assign /x dba 4225801 offset 4436 = 0x4c
assign /x dba 4288537 offset 7717 = 0x4c
--//这3条记录存在行链接或者迁移的情况,前面已经解析不再说明.
--//修改scan3_bbed.txt文件,注解如下2行不需要恢复.
$ grep ^# scan3_bbed.txt
#assign /x dba 4288539 offset 7920 = 0x6c
#assign /x dba 4288546 offset 7851 = 0x6c

$ grep  0x6c scan3_bbed.txt | grep -v "^#" |wc
   2963   23704  124395

--//2963+3=2966,这样恢复的记录数量与实际情况相符.

3.执行生成的bbed脚本并修复块 6110,6111,6112错误.

bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/scan3_bbed.txt
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/scan4k_bbed.txt
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/scan5_bbed.txt

--//前面提到启动遇到如下错误,主要是因为延迟块提交的问题:
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [94232], [6110], [], [], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [9951], [6110], [], [], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [31548], [6110], [], [], [], [], [], [], [], []

--//编写脚本如下,主要获得延迟块提交的数据块,设置提交标识.并且将对应的ktbbhitl[N]._ktbitun._ktbitfsc=0.
--//这样会导致verify时出现如下错误,例子:
BBED> set dba 4204236
        DBA             0x004026cc (4204236 1,9932)

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

Block Checking: DBA = 4204236, Block Type = KTB-managed data block
data header at 0x7fb110a7b25c
kdbchk: space available on commit is incorrect
        tosp=5052 fsc=0 stb=0 avsp=4937
Block 9932 failed with check code 6111
--//解决方法就是assign kdbhtosp=kdbhavsp;sum apply就ok了.
--//我以前处理这个错误有点繁琐.实际上设置fsc=0,设置提交标识为快速提交标识0x2,在执行assign kdbhtosp=kdbhavsp,
--//这样记录里面lock标识不需要设置为0x0,这样简单许多.

$ cat scanb.sh
#! /bin/bash
# get dba of tailchk ,grep begin # line, save scan6.txt
# and then grep -v 0x5f5f06,save clearout.txt,other save notclearout.txt

grep dba scan3_bbed.txt | grep -v "^#" | cut -d" " -f4 | uniq | while read dba
do
        echo -n $dba :
        echo "p dba $dba offset 0 tailchk 8188"| rlbbed | grep "ub4 tailchk"
done >| scan6.txt

grep -v 0x5f5f06 scan6.txt >|  clearout.txt
grep    0x5f5f06 scan6.txt >|  notclearout.txt

# create modify ktbbhitl[N].ktbitflg , ktbbhitl[N]._ktbitun._ktbitfsc=0 and kdbhtosp=kdbhavsp of script.
cat clearout.txt | cut -d" " -f1 |while read dba
do
        echo set dba $dba
    echo -n "assign "
    echo -e  "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$"| egrep "ktbbhitl|ktbitflg" | cut -c11-21,55-60 | paste -d. - - | sed -e 's/   /=/'
    echo -n "assign "
    echo -e  "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$" | egrep "ktbbhitl"| cut -c11-21 | sed -e 's/$/._ktbitun._ktbitfsc=0/'
        echo "assign kdbhtosp=kdbhavsp"
    echo sum apply dba $dba
done >| clearout_bbed.txt

# create modify ktbbhitl[N]._ktbitun._ktbitfsc=0 and kdbhtosp=kdbhavsp of script.
cat notclearout.txt | cut -d" " -f1 |while read dba
do
        echo set dba $dba
#   echo -n "assign "
#   echo -e  "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$"| egrep "ktbbhitl|ktbitflg" | cut -c11-21,55-60 | paste -d. - - | sed -e 's/   /=/'
    echo -n "assign "
    echo -e  "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$" | egrep "ktbbhitl"| cut -c11-21 | sed -e 's/$/._ktbitun._ktbitfsc=0/'
        echo "assign kdbhtosp=kdbhavsp"
    echo sum apply dba $dba
done >| notclearout_bbed.txt

--//执行以上脚本:
$ . scanb.sh
$ grep  "ktbbhitl[1].ktbitflg=" clearout_bbed.txt | grep -v 0x0
$ echo $?
1
--//说明这些块都没有打上提交标识.

$ head -5 clearout_bbed.txt
set dba 4204236
assign ktbbhitl[1].ktbitflg=0x0002
assign ktbbhitl[1]._ktbitun._ktbitfsc=0
assign kdbhtosp=kdbhavsp
sum apply dba 4204236

--//使用vim执行:%s/ktbitflg=0x0/ktbitflg=0x2/.也就是设置提交标识.注意检查替换是否74行.
--//补充说明一下,我前面测试执行的是%s/=0x00/=0x20/,实际上提交标识仅仅占半个字节(4位),这样写有点问题,不过一般不会出现问题.
--//1块修改255条以上的情况在这里不会出现(至少对于这个表是如此).

$ head -5 clearout_bbed.txt
set dba 4204236
assign ktbbhitl[1].ktbitflg=0x2002
assign ktbbhitl[1]._ktbitun._ktbitfsc=0
assign kdbhtosp=kdbhavsp
sum apply dba 4204236

--//执行如下:
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/clearout_bbed.txt
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/notclearout_bbed.txt

$ dbv  file=/mnt/ramdisk/book/system01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Tue Feb 12 10:37:09 2019
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) : 64316
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 13442
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 4185
Total Pages Processed (Seg)  : 1
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 15337
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 393502590 (3.393502590)

--//现在OK了.
4.禁用sys.tab$的索引I_TAB1.

--//这样恢复,索引与表存在不一致情况,要禁用sys.tab$的索引I_TAB1.

BBED> x /rnnc dba 1,523 *kdbr[9]
rowdata[1269]                               @4910
-------------
flag@4910: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@4911: 0x01
cols@4912:    3
col    0[2] @4913: 33
col    1[2] @4916: 33
col  2[189] @4919: CREATE INDEX I_TAB1 ON TAB$(BOBJ#) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (  INITIAL 64K NEXT 1024K MINEXTENTS 1 MAXEXTENTS 2147483
645 PCTINCREASE 0 OBJNO 33 EXTENTS (FILE 1 BLOCK 312))

--//设置flag=3c,表示删除.
BBED> assign /x  dba 1,523 offset 4910= 0x3c
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 rowdata[0]                              @4910     0x3c

BBED> sum apply dba 1,523
Check value for File 1, Block 523:
current = 0x7e6b, required = 0x7e6b

BBED> verify dba 1,523
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 523

Block Checking: DBA = 4194827, Block Type = KTB-managed data block
data header at 0x6eee44
kdbchk: the amount of space used is not equal to block size
        used=4398 fsc=0 avsp=3525 dtl=8120
Block 523 failed with check code 6110
--//先不理会这个错误.

5.启动数据库看看:

SYS@book> startup pfile='/tmp/@.ora';
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> shutdown  immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@book> startup open read only pfile='/tmp/book.ora'
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.

--//注/tmp/book.ora最好加入修改如下:
*._system_trig_enabled=false
*.job_queue_processes=0

SYS@book> select * from sys.tab$ minus select * from orachk001;
no rows selected

SYS@book> select * from orachk001 minus select * from sys.tab$;
no rows selected

--//OK,几乎完美恢复.我执行如下select * from sh.sales;,顺利读出,没有任何问题.
--//现在建立删除表没有任何问题.

SCOTT@book> create table t as select * from all_objects;
Table created.

SCOTT@book> drop table t purge ;
Table dropped.

6.剩下恢复tab$.索引I_TAB1,写得有点长.另写一篇修复索引的帖子,感觉这步很难,也许要先放一放.
--//最后说明一点,我的是测试环境,也许真实的环境更加复杂.我可能还遗漏一些细节...^_^.

[20190212]删除tab$记录的恢复3.txt的更多相关文章

  1. [20190226]删除tab$记录的恢复6.txt

    [20190226]删除tab$记录的恢复6.txt --//春节前几天做了删除tan$记录的测试,链接:http://blog.itpub.net/267265/viewspace-2565245/ ...

  2. [20190225]删除tab$记录的恢复5.txt

    [20190225]删除tab$记录的恢复5.txt --//昨天下午看了链接https://blog.csdn.net/Enmotech/article/details/87834503,大概知道对 ...

  3. [20190130]删除tab$记录的恢复2.txt

    [20190130]删除tab$记录的恢复2.txt --//前面链接写好了脚本,开始测试删除后的恢复.千万不要在生产系统做这样的测试!!--//参考链接:http://blog.itpub.net/ ...

  4. [20190130]删除tab$记录的恢复.txt

    [20190130]删除tab$记录的恢复.txt --//网上提到许多删除tab$的案例,主要原因在于没有从官方正规渠道下载oracle版本,还有一些来自工具里面带有一些脚本删除tab$记录. -- ...

  5. [20180614]删除bootstrap$记录无法启动2.txt

    [20180614]删除bootstrap$记录无法启动2.txt --//前几天看链接http://www.xifenfei.com/2018/05/willfully-delete-bootstr ...

  6. [20190531]ORA-600 kokasgi1故障模拟与恢复(后续).txt

    [20190531]ORA-600 kokasgi1故障模拟与恢复(后续).txt --//http://blog.itpub.net/267265/viewspace-2646340/=>[2 ...

  7. [20180612]删除bootstrap$记录无法启动.txt

    [20180612]删除bootstrap$记录无法启动.txt --//前几天看链接http://www.xifenfei.com/2018/05/willfully-delete-bootstra ...

  8. [20190226]测试使用bbed恢复索引.txt

    [20190226]测试使用bbed恢复索引.txt --//上午做tab$删除恢复测试时发现,tab$的索引i_tab1很小.可以尝试使用bbed解决这个问题.--//首先在普通表上做一个测试看看. ...

  9. DNS添加/修改/查询/删除A记录

    #查询DNS可用类 Get-WmiObject -Namespace root\MicrosoftDNS -List #查询所有资源记录 $mydns = [WMIClass]"ROOT\M ...

随机推荐

  1. vSphere 软件组件

    vSphere 包括以下软件组件: ESXi 一种虚拟化平台,您可使用此平台将虚拟机创建为一组配置和磁盘文件,它们可共同执行物理机的所有功能. 通过 ESXi,可以运行虚拟机,安装操作系统,运行应用程 ...

  2. 呕心沥血之作,最多坑mysql5.7安装教程

    前言: 业务需要,需要数据库接binlog发数据变更消息,但是项目用到的数据库是mysql5.6,不支持,于是就有了接下来的一切一切,新的测试服务器上安装mysql5.7 安装步骤: 1.官网下载my ...

  3. MyEclipse2017破解设置与maven项目搭建

    下载 版本:MyEclipse2017 Stable 2.0 百度网盘链接:https://pan.baidu.com/s/1vpIMKq9FfMMbhXzkmft_8A 密码:xfbv myecli ...

  4. JavaScript基础回顾一(类型、值和变量)

    请看代码并思考输出结果 var scope = 'global'; function f(){ console.log(scope); var scope = 'local'; console.log ...

  5. JavaScript 系列博客(四)

    JavaScript 系列博客之(四) 前言 本篇介绍 JavaScript 中的对象.在第一篇博客中已经说到 JavaScript 是一种''对象模型''语言.所以可以这样说,对象是 JavaScr ...

  6. 【转载】C#工具类:FTP操作辅助类FTPHelper

    FTP是一个8位的客户端-服务器协议,能操作任何类型的文件而不需要进一步处理,就像MIME或Unicode一样.可以通过C#中的FtpWebRequest类.NetworkCredential类.We ...

  7. Spring MVC 学习总结(十一)——IDEA+Maven+多模块实现SSM框架集成

    一.SSM概要 与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC ...

  8. Jmter接口网站压力测试工具使用记录

    1.首先下载Jmeter 官方地址:http://jmeter.apache.org/ 2.安装Jmeter 把下载的文件进行解压,产生如下目录: 打开bin文件夹下的jmeter.bat文件及进入程 ...

  9. (5)Microsoft office Word 2013版本操作入门_标尺

    1.标尺 :左缩进,右缩进,悬挂缩进,首行缩进,阴影部分 可以左右拖拽调整边缘. 1.1  左缩进:默认缩进所在的段落,要缩进多段则需要多段落选中, 后拖动左缩进. 1.2 首行缩进缩进或者突出所选的 ...

  10. cas单点登录

    一般一家企业内部会有多个业务系统,多个系统相互协作,但每个系统都需要登陆密码,比如:权限系统,发布系统,配置系统,邮件系统等,用户使用每个系统都需要登陆操作,使用起来比较繁琐,工作效率低下.此时就需要 ...