<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; oracle删除恢复</title>
	<atom:link href="https://www.xifenfei.com/tag/oracle%e5%88%a0%e9%99%a4%e6%81%a2%e5%a4%8d/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Thu, 29 Oct 2026 15:31:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>rm -rf误删Oracle数据库恢复</title>
		<link>https://www.xifenfei.com/2024/05/rm-rf-oracle-recovery.html</link>
		<comments>https://www.xifenfei.com/2024/05/rm-rf-oracle-recovery.html#comments</comments>
		<pubDate>Thu, 16 May 2024 11:47:38 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[非常规恢复]]></category>
		<category><![CDATA[oracle删除恢复]]></category>
		<category><![CDATA[oracle碎片]]></category>
		<category><![CDATA[rm -rf恢复]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10757</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2024/05/rm-rf-oracle-recovery.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2024/05/rm-rf-oracle-recovery.html" target="_blank">rm -rf误删Oracle数据库恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>有客户把虚拟化环境中装有oracle数据库的linux操作系统,由于操作失误在/下面执行了rm  -rf *，导致所有文件被删除,系统无法启动.客户希望要求恢复出其中的Oracle数据库.由于是虚拟化环境,然后客户直接从虚拟化平台下载下来磁盘文件,通过工具加载和分析确认是一个xfs的文件系统<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516190746.png"><img src="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516190746.png" alt="20240516190746" width="819" height="387" class="alignnone size-full wp-image-10758" /></a><br />
<hr />
使用工具进一步扫描分析,找到部分数据文件<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516190505.png"><img src="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516190505.png" alt="20240516190505" width="792" height="636" class="alignnone size-full wp-image-10759" /></a><br />
<hr />
这里可以获取到两个信息:<br />
1. 尝试恢复oracle的control01.ctl文件,然后通过该文件尝试分析其他数据文件位置,运气不错该文件恢复出来是好的,直接加载到新库查询v$datafile,分析出来所有数据文件信息<br />
2. 这里有一个非常不幸的信息,oracle最核心的system01.dbf文件大小明显异常,进一步分析该文件信息,结论是该文件无法通过反删除方式进行恢复<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2024/05/20240515223607.png"><img src="https://www.xifenfei.com/wp-content/uploads/2024/05/20240515223607.png" alt="20240515223607" width="716" height="483" class="alignnone size-full wp-image-10760" /></a><br />
<hr />
先把可以os层面可以恢复的数据恢复出来,并且检查坏块情况<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516191836.png"><img src="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516191836.png" alt="20240516191836" width="335" height="603" class="alignnone size-full wp-image-10761" /></a><br />
<hr />
对于异常的system文件,有两个处理方法:<br />
1. 通过阅览被删除的文件，发现客户有5月14日1点左右的rman备份,通过恢复软件中完整度提示,大概率应该没有什么问题,但是分析发现部分归档日志损坏无法完整恢复<br />
2. 通过对磁盘做碎片,恢复出来该数据文件,参考以往文章:<br />
<a href="https://www.xifenfei.com/2019/12/dbca-delete-and-rm-database-recovery.html" title="dbca删除库和rm删库恢复" rel="noopener" target="_blank">dbca删除库和rm删库恢复</a><br />
<a href="https://www.xifenfei.com/2018/05/datafile-size-0k-recovery.html" title="Oracle 数据文件大小为0kb或者文件丢失恢复" rel="noopener" target="_blank">Oracle 数据文件大小为0kb或者文件丢失恢复</a><br />
通过这个方法运气不错,恢复出来该库的system01.dbf文件非常完整0丢失</p>
<pre class="brush: bash; title: ; notranslate">
[oracle@localhost oradata]$ dbv file=system01.dbf

DBVERIFY: Release 19.0.0.0.0 - Production on Thu May 15 23:26:57 2024

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/oradata/system01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 199680
Total Pages Processed (Data) : 113988
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 26869
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 40253
Total Pages Processed (Seg)  : 1
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 18570
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 658228557 (0.658228557)
</pre>
<p>完成上述恢复工作之后,目前确认只有sysaux01.dbf有8026个block损坏,但是该表空间不涉及业务数据,尝试在新的系统中直接修改路径并open库</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; recover database;
ORA-00283: recovery session canceled due to errors
ORA-38760: This database instance failed to turn on flashback database


SQL&gt; alter database flashback off;

Database altered.

SQL&gt; recover database;
Media recovery complete.
SQL&gt; alter database open;

Database altered.
</pre>
<p>运气不错,数据库直接open成功,现在处理sysaux01.dbf中的损坏文件:<br />
1. 确认该文件具体坏块开始位置:<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516193650.png"><img src="https://www.xifenfei.com/wp-content/uploads/2024/05/20240516193650.png" alt="20240516193650" width="1200" height="574" class="alignnone size-full wp-image-10762" /></a><br />
<hr />
2. 由于坏块在文件中比较靠后,分析实际存储数据最后的位置</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select max(block_id+blocks) from dba_extents where file_id=3;

MAX(BLOCK_ID+BLOCKS)
--------------------
             3493120
</pre>
<p>最后存储数据的位置小于坏块的位置,证明坏块部分是没有存储数据的,直接resize掉坏块部分</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; alter database datafile '/u01/oradata/sysaux01.dbf' resize 27290m;

Database altered.
</pre>
<p>然后dbv该数据文件,确认没有任何问题</p>
<pre class="brush: bash; title: ; notranslate">
[oracle@localhost trace]$ dbv file=/u01/oradata/sysaux01.dbf

DBVERIFY: Release 19.0.0.0.0 - Production on Wed May 15 22:43:00 2024

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/oradata/sysaux01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 3493120
Total Pages Processed (Data) : 1516833
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 1868832
Total Pages Failing   (Index): 0
Total Pages Processed (Lob)  : 56577
Total Pages Failing   (Lob)  : 0
Total Pages Processed (Other): 32107
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 18771
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 658223915 (0.658223915)
</pre>
<p>使用rman检测全库,也确定没有任何问题</p>
<pre class="brush: sql; title: ; notranslate">
[oracle@localhost trace]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Wed May 15 22:43:58 2024
Version 19.15.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: XIFENFEI (DBID=2912535091)

RMAN&gt; 

RMAN&gt; 

RMAN&gt; backup validate check logical database skip inaccessible;

Starting backup at 15-MAY-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=278 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
………………
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
32   OK     0              6273         6400            370625094 
  File Name: /u01/oradata/xff_com.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0               
  Index      0              0               
  Other      0              127             

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
33   OK     0              163752       832000          627920639 
  File Name: /u01/oradata/XFF_DATA_202312231.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              374296          
  Index      0              285002          
  Other      0              8950            

Finished backup at 15-MAY-24

[oracle@localhost trace]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed May 15 22:47:44 2024
Version 19.15.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.15.0.0.0

SQL&gt; select * from v$database_block_corruption ;

no rows selected

SQL&gt; 
</pre>
<p>至此对于这次rm -rf /*的故障实现了Oracle数据库完美恢复,数据0丢失.</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/07/dbv-controlfile.html" rel="bookmark" class="crp_title">需要注意:dbv 检测controlfile可能不准</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/ora-01578%e5%9d%8f%e5%9d%97%e8%a7%a3%e5%86%b32.html" rel="bookmark" class="crp_title">ORA-01578坏块解决(2)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/09/obet-repair-oracle-block.html" rel="bookmark" class="crp_title">obet快速修复oracle 位图损坏块</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/09/%e5%81%87%e5%9d%8f%e5%9d%97%e5%bc%95%e8%b5%b7%e6%81%90%e6%85%8c.html" rel="bookmark" class="crp_title">假坏块引起恐慌</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/06/ora-00756-ora-10567-0-lost-recovery.html" rel="bookmark" class="crp_title">ORA-00756 ORA-10567故障数据0丢失恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html" rel="bookmark" class="crp_title">rman制造坏块,bbed修复坏块</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/ora-01578%e5%9d%8f%e5%9d%97%e8%a7%a3%e5%86%b31.html" rel="bookmark" class="crp_title">ORA-01578坏块解决(1)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/%e4%bd%bf%e7%94%a8dd%e5%a4%8d%e5%88%b6asm%e4%b8%ad%e6%96%87%e4%bb%b6.html" rel="bookmark" class="crp_title">使用dd复制asm中文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/undo%e5%9d%8f%e5%9d%97%e5%af%bc%e8%87%b4%e6%95%b0%e6%8d%ae%e5%ba%93%e5%bc%82%e5%b8%b8%e7%bb%88%e6%ad%a2%e6%a1%88%e4%be%8b.html" rel="bookmark" class="crp_title">undo坏块导致数据库异常终止案例</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/09/dul%e6%8a%bd%e5%8f%96%e5%bc%82%e5%b8%b8asm%e6%96%87%e4%bb%b6.html" rel="bookmark" class="crp_title">密码保护：dul抽取异常asm文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/09/bbed-ora-1578.html" rel="bookmark" class="crp_title">bbed解决ORA-01578</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/04/segment-header-ora-1578.html" rel="bookmark" class="crp_title">segment header异常对象删除处理</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2024/05/rm-rf-oracle-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
