[20160329]bbed修复offline的数据文件.txt

简介: [20160329]bbed修复offline的数据文件.txt --测试数据库,不小心将一个数据文件offline了,archivelog也删除了(主要磁盘空间紧张,做了一次整理)。

[20160329]bbed修复offline的数据文件.txt

--测试数据库,不小心将一个数据文件offline了,archivelog也删除了(主要磁盘空间紧张,做了一次整理)。
--自己测试修复看看,顺便做一个记录。

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

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                             TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------- ----------------
    1        13227498080 2016-03-29 11:44:35                7       13227286650 ONLINE               999 NO  /mnt/ramdisk/book/system01.dbf   SYSTEM
    2        13227498080 2016-03-29 11:44:35             1834       13227286650 ONLINE               995 NO  /mnt/ramdisk/book/sysaux01.dbf   SYSAUX
    3        13227498080 2016-03-29 11:44:35           923328       13227286650 ONLINE               915 NO  /mnt/ramdisk/book/undotbs01.dbf  UNDOTBS1
    4        13227498080 2016-03-29 11:44:35            16143       13227286650 ONLINE               999 NO  /mnt/ramdisk/book/users01.dbf    USERS
    5        13227498080 2016-03-29 11:44:35           952916       13227286650 ONLINE               912 NO  /mnt/ramdisk/book/example01.dbf  EXAMPLE
    6        13227498080 2016-03-29 11:44:35          1314508       13227286650 ONLINE               928 NO  /mnt/ramdisk/book/sugar01.dbf    SUGAR
    7        13227287392 2016-03-25 17:13:07      13227207527       13227286650 OFFLINE               20 YES /mnt/ramdisk/book/tea01.dbf      TEA
7 rows selected.

--我估计CHECKPOINT_CHANGE# 修改为13227498080 就ok了。测试看看。安全起见做一个备份:
$ cp tea01.dbf_ORG tea01.dbf

SYS@book> @ &r/10to16 13227287392

10 to 16 HEX   REVERSE16
-------------- -----------------------------------
0000314686360 0x60636814-03000000

SYS@book> @ &r/10to16 13227498080

10 to 16 HEX   REVERSE16
-------------- -----------------------------------
00003146b9a60 0x609a6b14-03000000

SCOTT@book> @ &r/bbvi 7 1
BVI_COMMAND
--------------------------------------------------
bvi -b 8192 -s 8192 /mnt/ramdisk/book/tea01.dbf

$ cp tea01.dbf tea01.dbf_ORG

2.使用bvi打开,修改0x60636814=>0x609a6b14

BBED> set dba 7,1
        DBA             0x01c00001 (29360129 7,1)

BBED> p kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x14686360

BBED> set dba 1,1
        DBA             0x00400001 (4194305 1,1)

BBED> p kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x146b9a60

--换1种修改模式算是学习。使用bbed的assign命令。
BBED> assign file 7 block 1 offset 484= file 1 block 1 offset 484;
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 pad                                     @484      0x60

BBED> set dba 1,1
        DBA             0x00400001 (4194305 1,1)

BBED> p kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x146b9a60

BBED> set dba 7,1
        DBA             0x01c00001 (29360129 7,1)

BBED> p kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x14686360

--仔细检查发现没改,仅仅修改最后1个字节,实际上这里正好一样(看不出来)。
BBED> help assign
ASSIGN[/x|d|u|o] <target spec>=<source spec>
<target spec> : [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
<source spec> : [ value | <target spec options> ]

BBED> assign dba 7,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas = dba 1,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas;
ub4 kscnbas                                 @484      0x146b9a60

BBED> p kcvfh.kcvfhckp.kcvcpscn.kscnbas dba 1,1
ub4 kscnbas                                 @484      0x146b9a60

BBED> p kcvfh.kcvfhckp.kcvcpscn.kscnbas dba 7,1
ub4 kscnbas                                 @484      0x146b9a60

--ok现在一样了。
BBED> sum apply dba 7,1
Check value for File 7, Block 1:
current = 0xdedb, required = 0xdedb

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


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED

3.重启到mount状态:
SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                            TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- ------------------------------- ----------------
    1        13227498080 2016-03-29 11:44:35                7       13227286650 ONLINE               999 NO  /mnt/ramdisk/book/system01.dbf  SYSTEM
    2        13227498080 2016-03-29 11:44:35             1834       13227286650 ONLINE               995 NO  /mnt/ramdisk/book/sysaux01.dbf  SYSAUX
    3        13227498080 2016-03-29 11:44:35           923328       13227286650 ONLINE               915 NO  /mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
    4        13227498080 2016-03-29 11:44:35            16143       13227286650 ONLINE               999 NO  /mnt/ramdisk/book/users01.dbf   USERS
    5        13227498080 2016-03-29 11:44:35           952916       13227286650 ONLINE               912 NO  /mnt/ramdisk/book/example01.dbf EXAMPLE
    6        13227498080 2016-03-29 11:44:35          1314508       13227286650 ONLINE               928 NO  /mnt/ramdisk/book/sugar01.dbf   SUGAR
    7        13227498080 2016-03-25 17:13:07      13227207527       13227286650 OFFLINE               20 YES /mnt/ramdisk/book/tea01.dbf     TEA
7 rows selected.
--现在一致了,recover看看。

SYS@book> recover datafile 7;
Media recovery complete.

alter database open read only ;

SYS@book> select owner,segment_name from dba_segments where tablespace_name='TEA';
OWNER  SEGMENT_NAME
------ --------------------
SCOTT  EMPX

SYS@book> select * from scott.empx ;
select * from scott.empx
                    *
ERROR at line 1:
ORA-00376: file 7 cannot be read at this time
ORA-01110: data file 7: '/mnt/ramdisk/book/tea01.dbf'

SYS@book> alter database datafile 7 online ;
Database altered.

SYS@book> select * from scott.empx where rownum<=1;
       EMPNO ENAME      JOB                MGR HIREDATE                     SAL         COMM       DEPTNO
------------ ---------- --------- ------------ ------------------- ------------ ------------ ------------
        7369 YYYY       CLERK             7902 1980-12-17 00:00:00          800                        20

目录
相关文章
|
测试技术 数据库
[20180202]备库数据文件offline.txt
[20180202]备库数据文件offline.txt --//今天测试,不小心导致日志无法应用.我想把主库文件拷贝过去,做了备库数据文件offline. --//恢复遇到问题,做一个记录.
1268 0
|
Oracle 关系型数据库 Linux
[20170803]如何查看dg的redo应用率.txt
[20170803]如何查看dg的redo应用率.txt --//昨天别人问的问题,实际上如果安装配置DGMGRL,在11.2.0.4下变得很简单.直接执行: 1.环境: SYS@xxxxdg2> @ &r/ver1 PORT_STRING       ...
838 0
|
Oracle 关系型数据库 数据库管理
[20170411]bbed计算redo检查和.txt
[20170411]bbed计算redo检查和.txt --前一阵子做测试,需要一个计算器做异或的操作,链接http://blog.itpub.net/267265/viewspace-2134945/ --正好前几天开会遇到熟人,谈起我写的脚本很实用。
921 0
|
Oracle 关系型数据库 Linux
[20161212]备份archivelog.txt
[20161212]备份archivelog.txt --许多人都知道如果执行backup database plus archivelog;实际上是先执行如下: 1.
729 0
|
Oracle 关系型数据库 数据库
[20161019]数据文件offline与open resetlog
[20161019]数据文件offline与open resetlog.txt --上午做了数据文件offline后恢复到那个scn号,恢复到该数据文件的LAST_CHANGE#的scn值。
701 0
|
Oracle 关系型数据库 测试技术
[20160816]11G dataguard坏块修复.txt
[20160816]11G dataguard坏块修复.txt --11GR2 不仅仅支持在备库在只读的情况下,日志应用(ACTIVE Data Guard),还提供主备库的坏块修复.
1053 0
|
Oracle 关系型数据库 数据库
[20160721]rman与undo表空间备份.txt
[20160721]rman与undo表空间备份.txt --//UNDO表空间主要用于存储前镜像数据,这些数据在回滚以及恢复过程中可能被用到。 --//一般生产数据库的UNDO表空间可能会变得非常巨大,甚至包括多个数据文件,而备份完整的UNDO数据文件在恢复时一般可能用到的比 --//例很小。
851 0