Home Database Mysql Tutorial 使用bbed修改文件头,推进scn,恢复offlinedrop的数据文件

使用bbed修改文件头,推进scn,恢复offlinedrop的数据文件

Jun 07, 2016 pm 04:13 PM
use Revise recover document

最近处理了一起由于用户操作错误导致的数据库无法打开的情况。 用户数据库为windows 64bit,数据库版本为11.2.0.1,非归档模式。由于异常断电,数据库无法正常打开,而且经过用户的判断使用了错误的offline drop操作。导致数据库打开后,日志文件切换过多,

最近处理了一起由于用户操作错误导致的数据库无法打开的情况。

用户数据库为windows 64bit,数据库版本为11.2.0.1,非归档模式。由于异常断电,数据库无法正常打开,而且经过用户的判断使用了错误的offline drop操作。导致数据库打开后,日志文件切换过多,无法使用recover命令。

因为中间没有做其他操作,所以接到case后,这里将受损的几个数据文件copy到linux下使用bbed进行修改,再copy回windows,成功跳过recover,打开了offline drop的数据文件。

情景还原:

sys@UTF8A> select name ,checkpoint_change# from v$datafile ;
 
NAME                                              CHECKPOINT_CHANGE#
--------------------------------------------------------------------
/u01/apps/oracle/oradata/utf8a/system01.dbf                   1040256
/u01/apps/oracle/oradata/utf8a/sysaux01.dbf                   1040256
/u01/apps/oracle/oradata/utf8a/undotbs01.dbf                  1040256
/u01/apps/oracle/oradata/utf8a/users01.dbf                    1039896
 
 
sys@UTF8A> select sequence#, group#,first_change#,statusfrom v$log ;
 
 SEQUENCE#    GROUP# FIRST_CHANGE# STATUS
---------- ---------- -----------------------------
       19          1       1040256 CURRENT
       17          2       1040250 INACTIVE
       18          3       1040253 INACTIVE
 
 
sys@UTF8A> recover datafile 4  ;
ORA-00279: change 1039896 generated at03/30/2015 09:31:05 needed for thread 1
ORA-00289: suggestion :/u01/apps/oracle/product/11.2.0/dbhome_1/dbs/arch1_12_827004096.dbf
ORA-00280: change 1039896 for thread 1 isin sequence #12
 
 
Specify log: {<RET>=suggested |filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log'/u01/apps/oracle/product/11.2.0/dbhome_1/dbs/arch1_12_827004096.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file ordirectory
Additional information: 3
 
 
ORA-00308: cannot open archived log'/u01/apps/oracle/product/11.2.0/dbhome_1/dbs/arch1_12_827004096.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file ordirectory
Additional information: 3
Copy after login


sequence已经过去,无法执行恢复,所以这里只能使用bbed修改文件头了。归档以及备份真的很重要。

block为8192。

flist:

1/u01/apps/oracle/oradata/utf8a/system01.dbf 754974720

2/u01/apps/oracle/oradata/utf8a/sysaux01.dbf 566231040

3/u01/apps/oracle/oradata/utf8a/undotbs01.dbf 83886080

4/u01/apps/oracle/oradata/utf8a/users01.dbf 9175040

如何初始化bbed环境,以及各种bbed版本的下载,见我的博客

http://blog.csdn.net/renfengjun/article/details/7944629

这里不再重复赘述。

先关闭数据库并且启动到mount状态。

sys@UTF8A> selectfile#,change#,online_status from v$recover_file ;
 
    FILE#    CHANGE# ONLINE_
---------- ---------- -------
        4    1039896 OFFLINE
 
sys@UTF8A> select name ,checkpoint_change# from v$datafile ;
 
NAME                                              CHECKPOINT_CHANGE#
--------------------------------------------------------------------
/u01/apps/oracle/oradata/utf8a/system01.dbf                   1041564
/u01/apps/oracle/oradata/utf8a/sysaux01.dbf                   1041564
/u01/apps/oracle/oradata/utf8a/undotbs01.dbf                  1041564
/u01/apps/oracle/oradata/utf8a/users01.dbf                    1039896
Copy after login


记得修改前先备份所有的数据库文件。

BBED> set file 4
       FILE#           4
 
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes                   @484    
  struct kcvcpscn, 8 bytes                @484    
      ub4 kscnbas                           @484      0x000fde18
     ub2 kscnwrp                          @488      0x0000
  ub4 kcvcptim                            @492      0x34321859
  ub2 kcvcpthr                            @496      0x0001
  union u, 12 bytes                       @500    
     struct kcvcprba, 12 bytes            @500    
        ub4 kcrbaseq                      @500      0x0000000c
        ub4 kcrbabno                      @504      0x00000015
        ub2 kcrbabof                      @508      0x0010
  ub1 kcvcpetb[0]                          @512      0x02
  ub1 kcvcpetb[1]                         @513      0x00
  ub1 kcvcpetb[2]                         @514      0x00
  ub1 kcvcpetb[3]                         @515      0x00
  ub1 kcvcpetb[4]                         @516      0x00
  ub1 kcvcpetb[5]                         @517      0x00
  ub1 kcvcpetb[6]                         @518      0x00
  ub1 kcvcpetb[7]                         @519      0x00
 
Copy after login

注意offset 484 , kscnbas为数据文件现在的scn。

使用计算器计算后0x000fde18,得到的十进制数字为1039896,确认无误,只要修改scn为最新的1041564,即可打开损坏的数据文件。

BBED> d /v dba 4,1 offset 484 count 16
 File: /u01/apps/oracle/oradata/utf8a/users01.dbf(4)
 Block: 1      Offsets:  484 to  499 Dba:0x01000001
-------------------------------------------------------
 18de0f00 00000000 59183234 01000000 l ......Y.24....
 
 <16 bytes per line>
 
Copy after login


因为是这里为linux x64 ,为little endian。

1039896=18de0f00

1041564=9ce40f00

直接修改即可。

BBED> set【本文来自鸿网互联 (http://www.68idc.cn)】 mode edit
       MODE            Edit
 
BBED> m /x 9ce40f dba 4,1 offset 484
 File:/u01/apps/oracle/oradata/utf8a/users01.dbf (4)
 Block: 1                Offsets:  484 to 499           Dba:0x01000001
------------------------------------------------------------------------
 9ce40f00 00000000 59183234 01000000
 
 <32 bytes per line>
 
 
 
BBED> m /x 9ce40f dba 4,1 offset 484
 File: /u01/apps/oracle/oradata/utf8a/users01.dbf(4)
 Block: 1                Offsets:  484 to 499           Dba:0x01000001
------------------------------------------------------------------------
 9ce40f00 00000000 59183234 01000000
 
 <32 bytes per line>
 
BBED> sum
Check value for File 4, Block 1:
current = 0x5f67, required = 0x65e3
 
BBED> sum apply
Check value for File 4, Block 1:
current = 0x65e3, required = 0x65e3
Copy after login


完成任务

 
sys@UTF8A> alter database datafile 4online ;
 
Database altered.
 
sys@UTF8A> selectfile#,change#,online_status from v$recover_file ;
 
    FILE#    CHANGE# ONLINE_
---------- ---------- -------
        4    1041564 ONLINE
 
sys@UTF8A> alter database datafile 4online ;
 
Database altered.
 
sys@UTF8A> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4:'/u01/apps/oracle/oradata/utf8a/users01.dbf'
 
 
sys@UTF8A> recover datafile 4 ;
Media recovery complete.
sys@UTF8A> alter database open ;
 
Database altered.
 
sys@UTF8A> select * from scott.emp where rownum<2 ;
 
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM    DEPTNO
---------- ---------- --------- ---------- --------- -------------------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
Copy after login


完成后记得逻辑导出所有用户数据,并且完善备份计划。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to change the personal name in the group on DingTalk_How to modify the personal name in the group on DingTalk How to change the personal name in the group on DingTalk_How to modify the personal name in the group on DingTalk Mar 29, 2024 pm 08:41 PM

1. First open DingTalk. 2. Open the group chat and click the three dots in the upper right corner. 3. Find my nickname in this group. 4. Click to enter to modify and save.

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

How to restore chat spark on TikTok How to restore chat spark on TikTok Mar 16, 2024 pm 01:25 PM

On Douyin, a short video platform full of creativity and vitality, we can not only enjoy a variety of exciting content, but also have in-depth communications with like-minded friends. Among them, chat sparks are an important indicator of the intensity of interaction between the two parties, and they often inadvertently ignite the emotional bonds between us and our friends. However, sometimes due to some reasons, the chat spark may be disconnected. So what should we do if we want to restore the chat spark? This tutorial guide will bring you a detailed introduction to the content strategy, hoping to help everyone. How to restore the spark of Douyin chat? 1. Open the Douyin message page and select a friend to chat. 2. Send messages and chat to each other. 3. If you send messages continuously for 3 days, you can get the spark logo. On a 3-day basis, send pictures or videos to each other

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? Mar 14, 2024 pm 02:07 PM

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box &quot;Error 0x80004005: Unspecified Error&quot; will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

See all articles