<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.6" -->
<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/"
	>

<channel>
	<title>oracle</title>
	<link>http://www.maroc-it.ma/blogs/fahd</link>
	<description>Un blog utilisant WordPress</description>
	<pubDate>Thu, 21 Aug 2008 16:42:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.6</generator>
	<language>en</language>
			<item>
		<title>Stuck Concurrent Requests</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=70</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=70#comments</comments>
		<pubDate>Thu, 21 Aug 2008 16:36:23 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle 10g</category>

		<category>tips &amp; tricks</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=70</guid>
		<description><![CDATA[Background: Concurrent programs may be incompatible with other programs which means they cannot execute at the same time. If the stuck concurrent request has such rules defined, then programs it is incompatible with will not run until the problem is solved.
There are 2 ways to do this, update the table manually or run the Oracle [...]]]></description>
			<content:encoded><![CDATA[<p>Background: Concurrent programs may be incompatible with other programs which means they cannot execute at the same time. If the stuck concurrent request has such rules defined, then programs it is incompatible with will not run until the problem is solved.</p>
<p>There are 2 ways to do this, update the table manually or run the Oracle provided cmclean.sql script. Depending on the method you choose, you&#8217;ll need the request id.</p>
<p>programs are currently being executed. With the help of your users, find the request id in question and make note of it. The recommended approach from Oracle will be:</p>
<p>1.  Kill the database sessions for the requests.  (In our case there weren&#8217;t any.)<br />
2.  Shutdown the concurrent managers.<br />
3.  Run the cmclean.sql script Note: 134007.1<br />
4.  Start your concurrent managers.</p>
<p>The other method is to update the bad rows in the fnd_concurrent_requests table manually.</p>
<p>1. Query up the concurrent process that is stuck and make note of it&#8217;s Request ID.<br />
2. Log onto unix as applmgr and Log onto SQL*Plus as APPS.<br />
3. Perform this update statement:<br />
update fnd_concurrent_requests<br />
set phase_code = &#8216;C&#8217;,<br />
status_code = &#8216;X&#8217;<br />
where request_id = &#038;request_id;<br />
This statement will set the request to completed terminated<br />
4. should return a value of &#8220;1 row updated&#8221;.  If so then commit the change, if not, rollback and find the error.<br />
5. Check the concurrent process in the application and it should now be set to Completed Terminated.</p>
<p>For a list of status, phase_codes and what they mean, refer to Note: 297909.1.</p>
<p>The benefit to updating the fnd_concurrent_requests table manually is that no downtime is required.</p>
<p>Thanks for Reading.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=70</wfw:commentRss>
		</item>
		<item>
		<title>Rebuilding Indexes</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=69</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=69#comments</comments>
		<pubDate>Wed, 09 Jul 2008 14:47:56 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle Technical</category>

		<category>Oracle 10g</category>

		<category>sql/sh scripts</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=69</guid>
		<description><![CDATA[The simplest way to rebuild and index is:
Alter index  rebuild tablespace ;
This also has the advantage of not preventing the index from being used whilst it is being rebuilt. The tablespace must be specified otherwise the index will be rebuilt in the current users default tablespace.
Rebuilding the index also allows new storage parameters to [...]]]></description>
			<content:encoded><![CDATA[<p>The simplest way to rebuild and index is:</p>
<blockquote><p><code>Alter index <index-name> rebuild tablespace <index-tablespace>;</code></p></blockquote>
<p>This also has the advantage of not preventing the index from being used whilst it is being rebuilt. The tablespace must be specified otherwise the index will be rebuilt in the current users default tablespace.</p>
<p>Rebuilding the index also allows new storage parameters to be assigned to the index.</p>
<p>If the index is corrupt, it must be dropped and recreated.</p>
<ol type="i" start="1">
<li>Firstly, identify the original creation parameters:
<pre>SELECT COLUMN_NAME FROM USER_IND_COLUMNS
WHERE INDEX_NAME = 'index_name';</pre>
<pre>SELECT TABLE_NAME, UNIQUENESS, TABLESPACE_NAME,
INITIAL_EXENT, NEXT_EXTENT, MIN_EXTENTS, MAX_EXTENTS,
PCT_INCREASE, PCT_FREE
FROM USER_INDEXES WHERE INDEX_NAME = 'index_name';</pre>
<p>The above will give you the columns on which the index is based.</li>
<li>And then drop the index and recreate it:
<pre>Drop index <index-name>;</pre>
<pre>Create [UNIQUE] index <index-name>
On
<table-name>( <column-1> [ , <column-n> ] )
tablespace
<tablespace>PCTFREE
<pct-free>
STORAGE (
NEXT <size>K
INITIAL <size>K
PCTINCREASE
<pct_increase>
MIN_EXTENTS <min_extents>
MAX_EXTENTS <max_extents> );</pre>
</li>
</ol>
<p><span style="font-size: 10pt; font-family: Times New Roman">Today, a  battle is raging between the “academics” who do not believe that indexes should  be rebuilt without expensive studies and the “pragmatists” who rebuild indexes  on a schedule because their end-users report faster response times. </span></p>
<p>I highly recommend Reading up on the differences between these two different approaches.</p>
<p>-Thanks for reading and come back again.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=69</wfw:commentRss>
		</item>
		<item>
		<title>STATSPACK 101 - introduction</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=68</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=68#comments</comments>
		<pubDate>Mon, 23 Jun 2008 17:58:13 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Non classé</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=68</guid>
		<description><![CDATA[More articles to come on this subject, this is just a small introduction.
To effectively perform reactive tuning, it is vital to have an established baseline for later comparison when the system is running poorly. Without a baseline data point, it becomes very difficult to identify what a new problem is attributable to: Has the volume [...]]]></description>
			<content:encoded><![CDATA[<p>More articles to come on this subject, this is just a small introduction.<br />
To effectively perform reactive tuning, it is vital to have an established baseline for later comparison when the system is running poorly. Without a baseline data point, it becomes very difficult to identify what a new problem is attributable to: Has the volume of transactions on the system increased? Has the transaction profile or application changed? Has the<br />
number of users increased?</p>
<p>Statspack fundamentally differs from the well known UTLBSTAT/UTLESTAT tning scripts by collecting more information, and also by storing the performance statistics permanently in Oracle tables, which can later be used for reporting and analysis. The data collected can be analyzed using the report provided, which includes an &#8216;instance health and load&#8217; summary page, high resource SQL statements, as well as the traditional wait events and initialization parameters.</p>
<p>Statspack improves on the existing UTLBSTAT/UTLESTAT performance scripts in the following ways:</p>
<p>- Statspack collects more data, including high resource SQL (and the optimizer execution plans for those statements)</p>
<p>- Statspack pre-calculates many ratios useful when performance tuning, such as cache hit ratios, per transaction and per<br />
second statistics (many of these ratios must be calculated manually when using BSTAT/ESTAT)</p>
<p>- Permanent tables owned by PERFSTAT store performance statistics; instead of creating/dropping tables each time, data is inserted into the pre-existing tables. This makes historical data comparisons easier</p>
<p>- Statspack separates the data collection from the report generation. Data is collected when a &#8217;snapshot&#8217; is taken; viewing the data collected is in the hands of the performance engineer when he/she runs the performance report</p>
<p>- Data collection is easy to automate using either dbms_job or an OS utility</p>
<p>NOTE: The term &#8217;snapshot&#8217; is used to denote a set of statistics gathered at a single time, identified by a unique Id which includes the snapshot number (or snap_id). This term should not be confused with Oracle&#8217;s Snapshot Replication technology.</p>
<p><strong>How does Statspack work?<br />
</strong><br />
Statspack is a set of SQL, PL/SQL and SQL*Plus scripts which allow the collection, automation, storage and viewing of performance data. A user is automatically created by the installation script - this user, PERFSTAT, owns all objects needed by this package. This user is granted limited query-only privileges on the V$views required for performance tuning.</p>
<p>Statspack users will become familiar with the concept of a &#8217;snapshot&#8217;. &#8217;snapshot&#8217; is the term used to identify a single collection of performance data. Each snapshot taken is identified by a &#8217;snapshot id&#8217; which is a unique number generated at the time the snapshot is taken; each time a new collection is taken, a new snap_id is generated.</p>
<p>The snap_id, along with the database identifier (dbid) and instance number (instance_number) comprise the unique key for a snapshot (using this unique combination allows storage of multiple instances of a Clustered database in the same tables).</p>
<p>Once snapshots are taken, it is possible to run the performance report. The performance report will prompt for the two snapshot id&#8217;s the report will process. The report produced calculates the activity on the instance between the two snapshot periods specified, in a similar way to the BSTAT/ESTAT report; to compare - the first snap_id supplied can be considered the equivalent of running BSTAT; the second snap_id specified can be considered the equivalent of ESTAT. Unlike BSTAT/ESTAT which can by its nature only compare two static data points, the report can compare any two snapshots specified.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=68</wfw:commentRss>
		</item>
		<item>
		<title>Resizing your TEMP Tablespace</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=67</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=67#comments</comments>
		<pubDate>Tue, 27 May 2008 20:02:51 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle Technical</category>

		<category>Oracle 10g</category>

		<category>sql/sh scripts</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=67</guid>
		<description><![CDATA[Temporary tablespaces are used to manage space for database sort operations and for storing global temporary tables. For example, if you join two large tables, and Oracle cannot do the sort in memory (see SORT_AREA_SIZE initialisation parameter), space will be allocated in a temporary tablespace for doing the sort operation. Other SQL operations that might [...]]]></description>
			<content:encoded><![CDATA[<p>Temporary tablespaces are used to manage space for database sort operations and for storing global temporary tables. For example, if you join two large tables, and Oracle cannot do the sort in memory (see SORT_AREA_SIZE initialisation parameter), space will be allocated in a temporary tablespace for doing the sort operation. Other SQL operations that might require disk sorting are: CREATE INDEX, ANALYZE, Select DISTINCT, ORDER BY, GROUP BY, UNION, INTERSECT, MINUS, Sort-Merge joins, etc.</p>
<p>The DBA should assign a temporary tablespace to each user in the database to prevent them from allocating sort space in the SYSTEM tablespace.</p>
<p>In Here we focus on the resize operation rather than Creation:</p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">To resize TEMP, you must drop and recreate it.  You cannot drop the temporary temp tablespace, so these commands create a temporary temp tablespace, then drop and recreate temp with the new size.</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">CREATE TEMPORARY TABLESPACE temp1 TEMPFILE<br />
&#8216;/u08/oracledbf/zwebt/temp101.dbf&#8217; SIZE 800M<br />
EXTENT MANAGEMENT LOCAL<br />
uniform size 1M;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"> </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">alter database default temporary tablesp@ace temp1;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"> </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">drop tablespace temp including contents and datafiles;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"> </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! ls /u*/oracledbf/zwebt/temp0*.dbf</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! rm /u*/oracledbf/zwebt/temp0*.dbf</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"> </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">CREATE TEMPORARY TABLESPACE temp TEMPFILE </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">&#8216;/u08/oracledbf/zwebt/temp01.dbf&#8217; SIZE 2048M</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">EXTENT MANAGEMENT LOCAL</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">uniform size 1M;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"> </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">alter database default temporary tablespace temp;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"> </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">drop tablespace temp1 including contents and datafiles;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt"><br />
! ls /u*/oracledbf/zwebt/temp10*.dbf</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! rm /u*/oracledbf/zwebt/temp10*.dbf</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><strong>HERE IS TO REVERT THESE CHANGES:</strong></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal">
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">CREATE TEMPORARY TABLESPACE temp1 TEMPFILE<br />
&#8216;/u08/oracledbf/zwebt/temp101.dbf&#8217; SIZE 800M<br />
EXTENT MANAGEMENT LOCAL<br />
uniform size 1M;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">alter database default temporary tablespace temp1; </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">drop tablespace temp including contents and datafiles;      </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! ls /u*/oracledbf/zwebt/temp0*.db       </span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! rm /u*/oracledbf/zwebt/temp0*.dbf<br />
</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">CREATE TEMPORARY TABLESPACE temp TEMPFILE<br />
&#8216;/u08/oracledbf/zwebt/temp01.dbf&#8217; SIZE 800M<br />
EXTENT MANAGEMENT LOCAL<br />
uniform size 1M;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">alter database default temporary tablespace temp;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">drop tablespace temp1 including contents and datafiles;</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! ls /u*/oracledbf/zwebt/temp10*.dbf</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal"><span style="font-size: 10pt">! rm /u*/oracledbf/zwebt/temp10*.dbf</span></p>
<p style="margin-bottom: 0.0001pt; line-height: 12pt" class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=67</wfw:commentRss>
		</item>
		<item>
		<title>Optamize Your UNDO Tablespace</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=66</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=66#comments</comments>
		<pubDate>Fri, 23 May 2008 18:42:38 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle Technical</category>

		<category>sql/sh scripts</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=66</guid>
		<description><![CDATA[Starting in Oracle9i, rollback segments are re-named undo logs. Traditionally               transaction undo information was stored in Rollback Segments until a commit or               rollback statement was issued, at [...]]]></description>
			<content:encoded><![CDATA[<p>Starting in Oracle9i, rollback segments are re-named undo logs. Traditionally               transaction undo information was stored in Rollback Segments until a commit or               rollback statement was issued, at which point it was made available for overlaying.</p>
<p><span lang="de-ch">It is worth to tune the following important               parameters</span></p>
<ol>
<li><span lang="de-ch">T</span><span lang="en-us">he size of the UNDO tablespace</span></li>
<li><span lang="de-ch">T</span><span lang="en-us">he UNDO_RETENTION parameter</span></li>
</ol>
<p class="header"><span lang="de-ch">Actual Undo Size</span></p>
<blockquote>
<p class="courier">SELECT SUM(a.bytes) &#8220;UNDO_SIZE&#8221;<br />
FROM v$datafile a,<br />
v$tablespace b,<br />
dba_tablespaces c<br />
WHERE c.contents = &#8216;UNDO&#8217;<br />
AND c.status = &#8216;ONLINE&#8217;<br />
AND b.name = c.tablespace_name<br />
AND a.ts# = b.ts#;</p>
<p class="courier"><font color="#0000ff"> UNDO_SIZE<br />
&#8212;&#8212;&#8212;-<br />
<span lang="de-ch"> </span> 209715200</font></p></blockquote>
<p class="header"><span lang="de-ch">Undo Blocks per Second</span></p>
<blockquote>
<p class="courier">SELECT MAX(undoblks/((end_time-begin_time)*3600*24))<span lang="de-ch"><br />
</span>  &#8220;UNDO_BLOCK_PER_SEC&#8221;<br />
FROM v$undostat;</p>
<p class="courier"><font color="#0000ff">UNDO_BLOCK_PER_SEC<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
3.12166667</font></p></blockquote>
<p class="header"><span lang="de-ch">DB Block Size</span></p>
<blockquote>
<p class="courier">SELECT TO_NUMBER(value) &#8220;DB_BLOCK_SIZE [KByte]&#8221;<br />
FROM v$parameter<br />
WHERE name = &#8216;db_block_size&#8217;;</p>
<p class="courier"><font color="#0000ff">DB_BLOCK_SIZE [Byte]<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
4096</font></p></blockquote>
<p class="header"><span lang="de-ch">Optimal Undo Retention</span></p>
<blockquote>
<p class="courier"><strong>209<span lang="de-ch">&#8216;</span>715<span lang="de-ch">&#8216;</span>200 <span lang="de-ch">/ (</span>3.12166667 <span lang="de-ch">* 4&#8242;096) = 16&#8242;401 [Sec]</span></strong></p>
<p><span lang="de-ch">Using Inline Views, you can do all in one query!</span></p>
<p class="courier"><strong>SELECT <font color="#008000">d.undo_size</font>/(1024*1024) &#8220;ACTUAL UNDO SIZE               [MByte]&#8221;,<br />
SUBSTR(<font color="#ff0000">e.value</font>,1,25) &#8220;UNDO RETENTION [Sec]&#8221;,<br />
ROUND((<font color="#008000">d.undo_size</font>               / (to_number(<font color="#0000ff">f.value</font>) *<br />
<span lang="de-ch">     </span>  <font color="#ff00ff">g.undo_block_per_sec</font>))) &#8220;OPTIMAL UNDO RETENTION [Sec]&#8221;<br />
FROM <font color="#008000">(<br />
SELECT SUM(a.bytes) undo_size<br />
FROM v$datafile a,<br />
v$tablespace b,<br />
dba_tablespaces c<br />
WHERE c.contents = &#8216;UNDO&#8217;<br />
AND c.status =               &#8216;ONLINE&#8217;<br />
AND b.name =               c.tablespace_name<br />
AND a.ts# = b.ts#<br />
) d,</font><br />
<font color="#ff0000">v$parameter e,</font><br />
<font color="#0000ff">v$parameter f,</font><br />
<font color="#800000">(</font><font color="#ff00ff"><br />
SELECT               MAX(undoblks/((end_time-begin_time)*3600*24))<br />
<span lang="de-ch">            </span>                undo_block_per_sec<br />
FROM v$undostat<br />
) g</font><br />
WHERE <font color="#ff0000">e.name</font> = &#8216;undo_retention&#8217;<br />
AND <font color="#0000ff">f.name</font> = &#8216;db_block_size&#8217;<br />
<span lang="de-ch">/</span></strong></p>
<p class="courier"><font color="#0000ff"><span lang="de-ch">ACTUAL UNDO SIZE [MByte]<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
200</span></font></p>
<p><font color="#0000ff">UNDO RETENTION [Sec]<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
10800</font></p>
<p><font color="#0000ff">OPTIMAL UNDO RETENTION [Sec]<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
16401</font></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=66</wfw:commentRss>
		</item>
		<item>
		<title>Bringing up Oracle DB after a Machine Crash</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=65</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=65#comments</comments>
		<pubDate>Wed, 12 Mar 2008 18:53:04 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle Technical</category>

		<category>Oracle 10g</category>

		<category>sql/sh scripts</category>

		<category>tips &amp; tricks</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=65</guid>
		<description><![CDATA[
The following steps explain what needs to take place in order to recover from a crash where a DB control file gets corrupted:
The likely error thrown in this scenario is as follow:
Fri Mar  7 22:00:46 2008
Hex dump of (file 0, block 1) in trace file /u01/app/oracle/admin/teng/bdump/teng_j001_9438.trc
Corrupt block relative dba: 0x00000001 (file 0, block 1)
Bad [...]]]></description>
			<content:encoded><![CDATA[<pre></pre>
<pre>The following steps explain what needs to take place in order to recover from a crash where a DB control file gets corrupted:</pre>
<pre>The likely error thrown in this scenario is as follow:</pre>
<pre>Fri Mar  7 22:00:46 2008
Hex dump of (file 0, block 1) in trace file /u01/app/oracle/admin/teng/bdump/teng_j001_9438.trc
Corrupt block relative dba: 0x00000001 (file 0, block 1)
Bad check value found during control file header read
Data in bad block:
type: 21 format: 2 rdba: 0x00000001
last change scn: 0x0000.00000000 seq: 0x1 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x00001501
check value in block header: 0xf8de
computed block checksum: 0x1501</pre>
<pre><font><font face="courier">Problem Description:
====================

The OS crashed and at the time two instances were running.

After correcting the OS issue then you try to start the instance(s)
and upon mounting the database you receive the following errors:

ORA-00227: corrupt block detected in controlfile: (block %s, # blocks %s)
Cause: A block header corruption or checksum error was detected on
reading the controlfile.
Action: Use the CREATE CONTROLFILE or RECOVER DATABASE USING BACKUP
CONTROLFILE command.

ORA-00202: control file: <name>
Cause: This message reports the name of the file involved in other
messages.
Action: See the associated messages for a description of the problem.

Problem Explanation:
====================

Control file is corrupt.

Solution Description:
=====================

Try to use one of the mirrored copies of the control file. You should have
mirrored images of your control file. Oracle recommends at least 2 mirrored
copies. Their locations should be listed in your &#8220;init<sid>.ora&#8221; file.

Try using one of these mirrored control files to enable you to bring up the
database by copying one of them over the bad one.

Or

Comment out the bad control file from the &#8220;control_files&#8221; parameter in your
&#8220;init.ora&#8221; file and try bringing up the database with one of your mirrored
control files.

If the above doesn&#8217;t work, then all control files are corrupt and you must
create a new control file.

Take a backup of the control files from the last backup and follow steps
below to recreate a good control file.

===========
OPTION ONE
===========

1. The alert log should identify which control file it is trying to use.

See error ora-202.
>  Note this (control1).

2. Make a backup of control files as they are now.

cp controlfiles controlfile.bk

3. Take one of the other control files and copy over the bad control file
noted above.

If this does not work, then proceed to the next step.

==============
OPTION TWO
==============

Comment the bad control file from the control_files parameter.

In the init.ora:

control_file = comment out the one listed in alert log from ora-202.

Try starting the instance.

If you receive the same errors as previously with the name of the control file
changed to controlfile2, then go to the next option.

=============
OPTION THREE
=============

Issue:
1. Shutdown immediate.

2. Startup nomount pfile= <location of init.ora>.

3. Alter database mount;

4. Alter database backup controlfile to trace;

5. Shutdown.

6. Check for trace file:

Either in user_dump_dest = trace file with latest time stamp; nothing
or background_dump_dest.

The file name should be:  ora
<process#>.trc.

This should contain a script to recreate the control file.

7. Save file as control.sql.

8. Edit file to start with:  startup nomount.

9. Check Oracle_sid : should be set to correct sid.

10. Svrmgrl>  connect internal

11. @control.sql

You will reeceive a message: Stmt processed.

waiting on svrmgrl prompt

12. Svrmgrl media recovery complete

svrmgrl> select sysdate from dual; june 4, 1999

Database is up and open.

13. Select on main application table:

sqlplus :  connected ok.

Solution Explanation:
=====================

If all the control files are corrupt, then you will need to create a new control
file to be able to bring up your database.</font></font></pre>
<pre>Once again Thanks for reading <img src='http://www.maroc-it.ma/blogs/fahd/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  !</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=65</wfw:commentRss>
		</item>
		<item>
		<title>Re-Organizing your tablespace</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=64</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=64#comments</comments>
		<pubDate>Tue, 26 Feb 2008 19:57:44 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle Technical</category>

		<category>Oracle 10g</category>

		<category>tips &amp; tricks</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=64</guid>
		<description><![CDATA[You have a tablespace that is growing out of control and you need to re org.
this is a very lengthy subject but below are the steps you ll need to take in order to rename your datafiles, you can then trun off autoextend, and run a monitoring script to either:
1) Resize a current datafile and [...]]]></description>
			<content:encoded><![CDATA[<p>You have a tablespace that is growing out of control and you need to re org.</p>
<p>this is a very lengthy subject but below are the steps you ll need to take in order to rename your datafiles, you can then trun off autoextend, and run a monitoring script to either:</p>
<p><strong>1)</strong> Resize a current datafile and adding extra KB<br />
<strong>2)</strong> Addin a new datafile with a given # of KB.</p>
<p>Here is an example: (remember you can only do this if you are sys)<br />
sqlplus &#8220;/ as sysdba&#8221;<br />
shutdown immediate;<br />
!mv /p03/oracledbf/pan/AWPDR.dbf /p03/oracledbf/pan/AWPDR01.dbf<br />
!mv /p03/oracledbf/pan/AWMBeanDB.dbf /p03/oracledbf/pan/AWMBeanDB01.dbf<br />
!mv /p03/oracledbf/pan/AWMSUI.dbf /p03/oracledbf/pan/AWMSUI01.dbf<br />
startup mount;</p>
<p>alter database rename file &#8216;/p03/oracledbf/pan/AWPDR.dbf&#8217; TO &#8216;/p03/oracledbf/pan/AWPDR01.dbf&#8217;;<br />
alter database rename file &#8216;/p03/oracledbf/pan/AWMBeanDB.dbf&#8217; TO &#8216;/p03/oracledbf/pan/AWMBeanDB01.dbf&#8217;;<br />
alter database rename file &#8216;/p03/oracledbf/pan/AWMSUI.dbf&#8217; TO &#8216;/p03/oracledbf/pan/AWMSUI01.dbf&#8217;;</p>
<p>alter database datafile &#8216;/p03/oracledbf/pan/AWPDR01.dbf&#8217; autoextend off;<br />
alter database datafile &#8216;/p03/oracledbf/pan/AWMBeanDB01.dbf&#8217; autoextend off;<br />
alter database datafile &#8216;/p03/oracledbf/pan/AWMSUI01.dbf&#8217; autoextend off;</p>
<p>alter database open;</p>
<p>To Verify:<br />
col file_name format a50;<br />
select file_name, autoextensible from dba_data_files;<br />
clear columns;<br />
eof</p>
<p>As always Thanks for reading <img src='http://www.maroc-it.ma/blogs/fahd/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=64</wfw:commentRss>
		</item>
		<item>
		<title>Splash Screen</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=63</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=63#comments</comments>
		<pubDate>Tue, 19 Feb 2008 17:15:50 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle 10g</category>

		<category>tips &amp; tricks</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=63</guid>
		<description><![CDATA[Every Database should have the screen below, It would let everyone know how important this is  
The only thing a DBA has to get right is recovery.  In order to do that, they need the backups.

-Again Thanks for reading 

]]></description>
			<content:encoded><![CDATA[<p>Every Database should have the screen below, It would let everyone know how important this is <img src='http://www.maroc-it.ma/blogs/fahd/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The only thing a DBA has to get right is recovery.  In order to do that, they need the backups.</p>
<p><img align="middle" src="http://i124.photobucket.com/albums/p35/amyjorgensen/GraveWarning.jpg" /></p>
<p>-Again Thanks for reading <img src='http://www.maroc-it.ma/blogs/fahd/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=63</wfw:commentRss>
		</item>
		<item>
		<title>Command line is the s***t</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=61</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=61#comments</comments>
		<pubDate>Sat, 09 Feb 2008 18:16:44 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Oracle 10g</category>

		<category>sql/sh scripts</category>

		<category>tips &amp; tricks</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=61</guid>
		<description><![CDATA[because when you own it, you own the world.  You can literally do anything you want (given you have that privilege of course)&#8230;
1. Quick, what does the following Unix/Linux command do?
ls -R &#124; grep &#8220;:$&#8221; &#124; sed -e &#8217;s/:$//&#8217; -e &#8217;s/[^-][^\/]*\//&#8211;/g&#8217; -e &#8217;s/^/   /&#8217; -e &#8217;s/-/&#124;/&#8217;
If you said, &#8220;Well, that&#8217;s obvious; it [...]]]></description>
			<content:encoded><![CDATA[<p>because when you own it, you own the world.  You can literally do anything you want (given you have that privilege of course)&#8230;</p>
<p><strong>1.</strong> Quick, what does the following Unix/Linux command do?</p>
<p><em>ls -R | grep &#8220;:$&#8221; | sed -e &#8217;s/:$//&#8217; -e &#8217;s/[^-][^\/]*\//&#8211;/g&#8217; -e &#8217;s/^/   /&#8217; -e &#8217;s/-/|/&#8217;</em></p>
<p>If you said, &#8220;<em>Well, that&#8217;s obvious; it shows a graphical representation of the current sub-directories.</em>&#8220;, you&#8217;d be correct.</p>
<p><strong>2.</strong> You can use the command to create a program called <strong>tree</strong> that would work something like the following:</p>
<p>[ fayoubi@mars - Saturday, February 09, 2008 - 12:11:04 PM]<br />
[ /home/fayoubi ]  dba/scripts/tree.sh</p>
<p>/home/fayoubi<br />
.<br />
|-dba<br />
|&#8212;cfg_refresh<br />
|&#8212;junk<br />
|&#8212;onetime<br />
|&#8212;scripts<br />
|&#8212;snaps<br />
|&#8212;&#8211;2006_07<br />
|&#8212;&#8212;-nic<br />
|&#8212;&#8212;-nie<br />
|&#8212;&#8212;-nij<br />
|&#8212;&#8211;2006_11<br />
|&#8212;&#8212;-nic<br />
|&#8212;&#8212;-nie<br />
|&#8212;&#8212;-nij<br />
|&#8212;&#8211;2007_03<br />
|&#8212;&#8212;-nic<br />
|&#8212;&#8212;-nie<br />
|&#8212;&#8211;2007_08<br />
|&#8212;&#8211;2007_09<br />
|&#8212;&#8211;2007_q1<br />
|&#8212;&#8211;2007_q2<br />
|&#8212;&#8212;-nic<br />
|&#8212;&#8212;-nie<br />
|&#8212;&#8211;2007_q4<br />
|&#8212;&#8212;-nic<br />
|&#8212;&#8212;-nie<br />
|&#8212;&#8211;2008_q1<br />
|&#8212;&#8212;-nic<br />
|&#8212;&#8212;-nie<br />
|&#8212;Training<br />
|-example<br />
|&#8212;yourdir<br />
|&#8212;&#8211;mydir<br />
|-junk<br />
|-nipw<br />
|-tempdir<br />
|-tmp<br />
|-Vignette<br />
|-web</p>
<p>[ fayoubi@mars - Saturday, February 09, 2008 - 12:11:07 PM]<br />
[ /home/fayoubi ]</p>
<p><strong>3.</strong> Here is the code ready to go in a shell script:</p>
<pre>#!/bin/sh
#######################################################
#  UNIX TREE                                          #
#                                                     #
#  Displays Structure of Directory Hierarchy          #
#  -------------------------------------------------  #
#  This tiny script uses "ls", "grep", and "sed"      #
#  in a single command to show the nesting of         #
#  sub-directories.                                   #
#                                                     #
#  Setup:                                             #
#     % cd ~/apps/tree                                #
#     % chmod u+x tree.sh                             #
#     % ln -s ~/apps/tree/tree.sh ~/bin/tree          #
#                                                     #
#  Usage:                                             #
#     % tree [directory]                              #
#                                                     #
#  Examples:                                          #
#     % tree                                          #
#     % tree /etc/opt                                 #
#     % tree ..                                       #
#                                                     #
#######################################################

echo
if [ "$1" != "" ]  #if parameter exists, use as base folder
then cd "$1"
fi
pwd
ls -R | grep ":$" |
sed -e 's/:$//' -e 's/[^-][^/]*//--/g' -e 's/^/   /' -e 's/-/|/'
# 1st sed: remove colons
# 2nd sed: replace higher level folder names with dashes
# 3rd sed: indent graph three spaces
# 4th sed: replace first dash with a vertical bar
if [ `ls -F -1 | grep "/" | wc -l` = 0 ]   # check if no folders
then echo "   -> no sub-directories"
fi
echo
exit</pre>
<p>That&#8217;s it.</p>
<p>Again y&#8217;all, thanks for reading. <img src='http://www.maroc-it.ma/blogs/fahd/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=61</wfw:commentRss>
		</item>
		<item>
		<title>Turn ARCHIVE LOGGING ON OFF</title>
		<link>http://www.maroc-it.ma/blogs/fahd/?p=59</link>
		<comments>http://www.maroc-it.ma/blogs/fahd/?p=59#comments</comments>
		<pubDate>Thu, 31 Jan 2008 21:47:01 +0000</pubDate>
		<dc:creator>fahd</dc:creator>
		
		<category>Non classé</category>

		<guid isPermaLink="false">http://www.maroc-it.ma/blogs/fahd/?p=59</guid>
		<description><![CDATA[This is a two-step process. email if you have questions: fayoubi@gmail.com
STEP ONE : Modify your initSID.ora
Modify your initSID.ora to include the following three lines:
log_archive_start   = true
log_archive_dest    = /mount_point/oradata/SID/ARCHIVE/arch
log_archive_format  = _%s.arc
log_archive_start: This parameter specifies whether archiving should be started automatically when the database is started.
log_archive_dest: This value specifies the default location of the file to be [...]]]></description>
			<content:encoded><![CDATA[<p>This is a two-step process. email if you have questions: fayoubi@gmail.com</p>
<p><strong>STEP ONE</strong> : Modify your initSID.ora</p>
<p>Modify your initSID.ora to include the following three lines:</p>
<p>log_archive_start   = true<br />
log_archive_dest    = /mount_point/oradata/SID/ARCHIVE/arch<br />
log_archive_format  = _%s.arc</p>
<p>log_archive_start: This parameter specifies whether archiving should be started automatically when the database is started.</p>
<p>log_archive_dest: This value specifies the default location of the file to be used when archiving redo log files.</p>
<p>log_archive_format: This parameter is used to specify the default file name format for the archive log files, this value is appended to the log_archive_dest value ( %s is the log sequence number ).</p>
<p><strong>STEP TWO</strong> : Starting archive logging</p>
<p>The final step to starting archive logging, involves an Oracle SQL*DBA command which is run when the database is mounted but not open.</p>
<p>With the database shut down, use one of the many DBA tools available to manually start the database ( I still prefer to use SQL*DBA ) and execute the following sequence of commands:</p>
<p>startup mount exclusive<br />
connect internal<br />
alter database archivelog;<br />
alter database open;</p>
<p>Now check to ensure archive logging is running. Whilst still connected internal, execute the command archive log list as shown below:</p>
<p>SQLDBA> archive log list<br />
Database log mode              ARCHIVELOG<br />
Automatic archival             ENABLED<br />
Archive destination            /mount_point/oradata/SID/ARCHIVE/arch<br />
Oldest online log sequence     2<br />
Current log sequence           3<br />
SQLDBA></p>
<p>As usual thanks for reading <img src='http://www.maroc-it.ma/blogs/fahd/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maroc-it.ma/blogs/fahd/?feed=rss2&amp;p=59</wfw:commentRss>
		</item>
	</channel>
</rss>
