<?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; 释放句柄</title>
	<atom:link href="https://www.xifenfei.com/tag/%e9%87%8a%e6%94%be%e5%8f%a5%e6%9f%84/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>Sun, 22 Nov 2026 15:21:14 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>利用oradebug释放被删除文件空间</title>
		<link>https://www.xifenfei.com/2012/03/%e5%88%a9%e7%94%a8oradebug%e9%87%8a%e6%94%be%e8%a2%ab%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%a9%ba%e9%97%b4.html</link>
		<comments>https://www.xifenfei.com/2012/03/%e5%88%a9%e7%94%a8oradebug%e9%87%8a%e6%94%be%e8%a2%ab%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%a9%ba%e9%97%b4.html#comments</comments>
		<pubDate>Sat, 03 Mar 2012 14:02:01 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[oradebug]]></category>
		<category><![CDATA[释放句柄]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=2596</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2012/03/%e5%88%a9%e7%94%a8oradebug%e9%87%8a%e6%94%be%e8%a2%ab%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%a9%ba%e9%97%b4.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/2012/03/%e5%88%a9%e7%94%a8oradebug%e9%87%8a%e6%94%be%e8%a2%ab%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%a9%ba%e9%97%b4.html" target="_blank">利用oradebug释放被删除文件空间</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在很多时候，检查系统时候发现，由于某个Oracle的trace文件导致磁盘空间告警，因为业务需要不能让数据库down下来。这个时候你想到的方法可能是直接删除掉这个trace文件，如果是win系统，那恭喜你这样做可以解决问题；如果是linux/unix系统，那就等着事故的发生吧。在linux/unix中，如果直接rm掉oracle进程的某个文件(该进程还存在)，文件句柄不会释放，即磁盘使用空间不会释放。可以通过df命名看到磁盘的空间释放释放。下面通过对lgwr进程的一系列操作，使用oradebug来释放oracle进程句柄，从而达到释放oracle某个被删除的trace文件的磁盘空间<br />
<strong>一、查找lgwr进程的trace文件</strong></p>
<pre class="brush: bash; title: ; notranslate">
[oracle@localhost /]$ cd $ORACLE_BASE/admin/$ORACLE_SID/bdump
[oracle@localhost bdump]$ pwd
/opt/oracle/admin/mcrm/bdump
[oracle@localhost bdump]$ ls -l|grep lgwr
-rw-r----- 1 oracle oinstall 32133 Dec 22 21:00 mcrm_lgwr_3485.trc
-rw-r----- 1 oracle oinstall  3713 Oct  8 07:13 mcrm_lgwr_3489.trc
-rw-r----- 1 oracle oinstall 22507 Mar  3 06:00 mcrm_lgwr_3598.trc
-rw-r----- 1 oracle oinstall  8441 Sep 15 10:29 mcrm_lgwr_4963.trc
[oracle@localhost bdump]$ ps -ef|grep lgwr
oracle    1056 30718  0 21:10 pts/3    00:00:00 grep lgwr
oracle    3598     1  0  2011 ?        00:04:10 ora_lgwr_mcrm
[oracle@localhost bdump]$ df |grep /opt
/dev/sda6             37798668  33312588   2534988  93% /opt
[oracle@localhost bdump]$ du -s .
948     .
</pre>
<p>从这里得出几点结论：<br />
1.当前lgwr进程的spid为：3598<br />
2.当前lgwr进程产生的trace文件大小为：22507B<br />
3.包含该trace文件的分区大小使用大小为：33312588KB<br />
4.bdump目录大小为：948KB<br />
<br />
<strong>二、删除lgwr进程对应trace文件</strong></p>
<pre class="brush: bash; title: ; notranslate">
[oracle@localhost bdump]$ rm mcrm_lgwr_3598.trc
[oracle@localhost bdump]$ du -s .
924     .
[oracle@localhost bdump]$ df |grep /opt
/dev/sda6             37798668  33312588   2534988  93% /opt

[oracle@localhost bdump]$ ls -l /proc/3598/fd|grep lgwr   
l-wx------ 1 oracle oinstall 64 Mar  3 20:54 2 -&gt; /opt/oracle/admin/mcrm/bdump/mcrm_lgwr_3598.trc (deleted)
</pre>
<p>从这里得出结论：<br />
1.bdump目录当前大小变为：924KB(大约等于948KB-22507B)<br />
2.包含该trace文件的分区大小使用大小依然为：33312588KB(没有因为删除trace文件而释放空间)<br />
<br />
<strong>三、释放被删除trace文件空间</strong></p>
<pre class="brush: sql; title: ; notranslate">
[oracle@localhost bdump]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 3 21:12:41 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL&gt; !ls -l /proc/3598/fd|grep lgwr  
l-wx------ 1 oracle oinstall 64 Mar  3 20:54 2 -&gt; /opt/oracle/admin/mcrm/bdump/mcrm_lgwr_3598.trc (deleted)

SQL&gt;  oradebug setospid 3598
Oracle pid: 6, Unix process pid: 3598, image: oracle@localhost.localdomain (LGWR)
SQL&gt; oradebug flush;    
Statement processed.
SQL&gt; oradebug close_trace;
Statement processed.
SQL&gt; !ls -l /proc/3598/fd|grep lgwr  

SQL&gt; !df |grep /opt
/dev/sda6             37798668  33312564   2535012  93% /opt

SQL&gt; exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
</pre>
<p>从这里可以得出结论：<br />
1.包含该trace文件的分区大小使用大小为：33312564KB(大约等于948KB-22507B)<br />
2./proc/spid/fd下面的句柄已经释放<br />
3.总这里可以看出使用oradebug可以真正释放oracle进程磁盘使用空间</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/07/mount%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b9%9f%e5%8f%af%e8%83%bd%e6%9c%89localno%e7%9a%84%e8%bf%9b%e7%a8%8b.html" rel="bookmark" class="crp_title">mount数据库也可能有LOCAL=NO的进程</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/%e6%81%a2%e5%a4%8d%e8%a2%abrm%e6%84%8f%e5%a4%96%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae%e6%96%87%e4%bb%b6.html" rel="bookmark" class="crp_title">恢复被rm意外删除数据文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/%e5%9d%97%e4%bf%ae%e6%94%b9%e8%b7%9f%e8%b8%aa%e7%89%b9%e6%80%a7block-change-tracking.html" rel="bookmark" class="crp_title">块修改跟踪特性(Block Change Tracking)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/01/%e5%85%b3%e4%ba%8ewallet%e5%8a%a0%e5%af%86%e7%9a%84%e5%87%a0%e4%b8%aa%e6%b5%8b%e8%af%95.html" rel="bookmark" class="crp_title">关于wallet加密的几个测试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2019/05/ora-00470.html" rel="bookmark" class="crp_title">ORA-00470: LGWR process terminated with error</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/04/%e4%bd%bf%e7%94%a8oradebug-hang%e4%bd%8f%e6%9f%90%e4%b8%aa%e8%bf%9b%e7%a8%8b.html" rel="bookmark" class="crp_title">使用oradebug hang住某个进程</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/some-indexes-or-index-subpartitions-of-table-vas-tab_pub_calllog-have-been-marked-unusable.html" rel="bookmark" class="crp_title">Some indexes or index [sub]partitions of table VAS.TAB_PUB_CALLLOG have been marked unusable</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2020/05/ora-21779.html" rel="bookmark" class="crp_title">ORA-21779错误处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2019/02/ora-07217.html" rel="bookmark" class="crp_title">ORA-07217: sltln: environment variable cannot be evaluated.</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/10/sys%e7%94%a8%e6%88%b7%e5%af%86%e7%a0%81%e5%90%ab-sqlplus%e7%99%bb%e5%bd%95%e6%95%b0%e6%8d%ae%e5%ba%93%e8%af%a1%e5%bc%82%e4%ba%8b%e4%bb%b6%e5%88%86%e6%9e%90.html" rel="bookmark" class="crp_title">sys用户密码含$ sqlplus登录数据库诡异事件分析</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/ipfirst%e4%bd%9c%e7%94%a8%e8%af%b4%e6%98%8e.html" rel="bookmark" class="crp_title">IP=FIRST作用说明</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/sqlnet-authentication_services%e5%8f%82%e6%95%b0%e8%af%b4%e6%98%8e.html" rel="bookmark" class="crp_title">SQLNET.AUTHENTICATION_SERVICES参数说明</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2012/03/%e5%88%a9%e7%94%a8oradebug%e9%87%8a%e6%94%be%e8%a2%ab%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%a9%ba%e9%97%b4.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
