<?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>DBA survival BLOG &#187; Oracle Database</title>
	<atom:link href="http://www.ludovicocaldara.net/dba/category/oracledb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ludovicocaldara.net/dba</link>
	<description>Keep DBA job simple. Thanks.</description>
	<lastBuildDate>Sat, 01 Oct 2011 20:06:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Dog eat Dog&#8230; Oracle deletes itself by mistake!</title>
		<link>http://www.ludovicocaldara.net/dba/dog-eat-dog-oracle-deletes-itself-by-mistake/</link>
		<comments>http://www.ludovicocaldara.net/dba/dog-eat-dog-oracle-deletes-itself-by-mistake/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 18:47:05 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[rman]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=122</guid>
		<description><![CDATA[While implementing the backup on a new DB inherited from a customer, I scheduled our standard backup &#8220;type disk&#8221; procedure through rman, on Windows. The morning after I saw that the &#8220;delete obsolete&#8221; tried to delete ALL CURRENT DATAFILES!! i criteri di conservazione RMAN verranno applicati al comando i criteri di conservazione RMAN sono impostati [...]]]></description>
			<content:encoded><![CDATA[<p>While implementing the backup on a new DB inherited from a customer, I scheduled our standard backup &#8220;type disk&#8221; procedure through rman, on Windows.<br />
The morning after I saw that the &#8220;delete obsolete&#8221; tried to delete ALL CURRENT DATAFILES!!</p>
<p><code>i criteri di conservazione RMAN verranno applicati al comando<br />
i criteri di conservazione RMAN sono impostati su una ridondanza 1<br />
canale allocato: ORA_DISK_1<br />
canale ORA_DISK_1: sid=29 devtype=DISK<br />
Eliminazione dei seguenti backup e copie obsoleti:<br />
Tipo                 Chiave Ora fine          Nome file/Handle<br />
-------------------- ------ ------------------ --------------------<br />
Set di backup        917    28-GIU-11<br />
...<br />
Set di backup        927    29-GIU-11<br />
Backup piece       1005   29-GIU-11          H:\ORACLE\BACKUP\ORAPERSP\RMAN\SPFILEBCK_20110629<br />
Copia file di dati  14     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\INDX01.DBF<br />
Copia file di dati  16     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\TOOLS01.DBF<br />
Copia file di dati  17     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\USERS01.DBF<br />
Copia file di dati  18     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\DRSYS01.DBF<br />
Copia file di dati  19     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\EXAMPLE01.DBF<br />
Copia file di dati  20     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\ODM01.DBF<br />
Copia file di dati  21     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\XDB01.DBF<br />
Copia file di dati  22     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\CWMLITE01.DBF<br />
Copia file di dati  23     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\TBLDATI01.ORA<br />
Copia file di dati  24     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\TBLINDEX01.ORA<br />
Copia file di dati  25     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\OEM_REPOSITORY1.ORA<br />
Copia file di dati  26     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\SYSTEM01.DBF<br />
Copia file di dati  27     29-NOV-10          E:\ORACLE\ORADATA\ORAPERSP\UNDOTBS01.DBF<br />
backup piece eliminata<br />
...<br />
backup piece eliminata<br />
handle di backup piece=H:\ORACLE\BACKUP\ORAPERSP\RMAN\C-2220366420-20110628-02 recid=990 stamp=755031582<br />
backup piece eliminata<br />
handle di backup piece=H:\ORACLE\BACKUP\ORAPERSP\RMAN\C-2220366420-20110629-00 recid=1002 stamp=755130872<br />
backup piece eliminata<br />
handle di backup piece=H:\ORACLE\BACKUP\ORAPERSP\RMAN\CTL_20110629 recid=1004 stamp=755130883<br />
backup piece eliminata<br />
handle di backup piece=H:\ORACLE\BACKUP\ORAPERSP\RMAN\SPFILEBCK_20110629 recid=1005 stamp=755130885<br />
RMAN-00571: ===========================================================<br />
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============<br />
RMAN-00571: ===========================================================<br />
RMAN-03009: failure of delete command on ORA_DISK_1 channel at 06/29/2011 22:34:55<br />
ORA-19584: file E:\ORACLE\ORADATA\ORAPERSP\INDX01.DBF già in usoRecovery Manager ha terminato.<br />
</code></p>
<p>That&#8217;s because all current datafiles were registered into recovery catalog as backup copy. With a recovery redundancy of 1, all datafiles were set as obsolete!  But since it&#8217;s windows, a delete command doesn&#8217;t delete datafiles if they are already in use. What it was on unix? We had just luck!</p>
<p>Then we had to uncatalog all copies.</p>
<p><code><br />
RMAN> list copy;</p>
<p>la specifica non corrisponde a nessuno dei log di archivio del Recovery Catalog</p>
<p>Lista di copie del file di dati<br />
Chiave     SCN Ckp file S Ora di completamento    Nome Ora ckp<br />
------- ---- - -------------------- ---------- -------------------- ----<br />
26      1    X 29-NOV-10            18535127593 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\SYSTEM01.DBF<br />
27      2    X 29-NOV-10            18535127762 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\UNDOTBS01.DBF<br />
14      3    X 29-NOV-10            18535122625 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\INDX01.DBF<br />
16      4    X 29-NOV-10            18535123721 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\TOOLS01.DBF<br />
17      5    X 29-NOV-10            18535124423 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\USERS01.DBF<br />
18      6    X 29-NOV-10            18535124439 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\DRSYS01.DBF<br />
19      7    X 29-NOV-10            18535124453 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\EXAMPLE01.DBF<br />
20      8    X 29-NOV-10            18535124554 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\ODM01.DBF<br />
21      9    X 29-NOV-10            18535125790 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\XDB01.DBF<br />
22      10   X 29-NOV-10            18535125874 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\CWMLITE01.DBF<br />
23      11   X 29-NOV-10            18535125887 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\TBLDATI01.ORA<br />
24      12   X 29-NOV-10            18535126750 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\TBLINDEX01.ORA<br />
25      13   X 29-NOV-10            18535127211 29-NOV-10            E:\ORACLE\ORADATA\ORAPERSP\OEM_REPOSITORY1.ORA<br />
</code></p>
<p><code><br />
RMAN> change copy of datafile 1..N uncatalog;</p>
<p>copia non catalogata del file di dati<br />
filename di copia del file di dati=E:\ORACLE\ORADATA\ORAPERSP\INDX01.DBF recid=14 stamp=736336991<br />
Oggetti 1 non catalogati<br />
...<br />
</code></p>
<p>until no &#8220;obsolete&#8221; current datafile were reported!</p>
<p><code><br />
RMAN> report obsolete;</p>
<p>i criteri di conservazione RMAN verranno applicati al comando<br />
i criteri di conservazione RMAN sono impostati su una ridondanza 1<br />
non sono stati trovati backup obsoleti<br />
</code></p>
<p>Lesson learned: never schedule delete obsolete without actually checking what could be deleted!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/dog-eat-dog-oracle-deletes-itself-by-mistake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10gR2 RAC hangs and &#8220;KSV master wait&#8221;</title>
		<link>http://www.ludovicocaldara.net/dba/ksv-master-wait/</link>
		<comments>http://www.ludovicocaldara.net/dba/ksv-master-wait/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 09:44:52 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[autoextend]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[hang]]></category>
		<category><![CDATA[RAC]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=98</guid>
		<description><![CDATA[We recently migrated a customer&#8217;s 10gR2 RAC on AIX6.1 from GPFS+HACMP to a &#8220;basic&#8221; Clusterware with datafiles over ASM. After (many) problems related to various installation bugs (the list of requirements for AIX is very long, incomplete and requires many one-off patches to complete), we had a problem during an import of a new schema: [...]]]></description>
			<content:encoded><![CDATA[<p>We recently migrated a customer&#8217;s 10gR2 RAC on AIX6.1 from GPFS+HACMP to a &#8220;basic&#8221; Clusterware with datafiles over ASM.<br />
After (many) problems related to various installation bugs (the list of requirements for AIX is very long, incomplete and requires many one-off patches to complete), we had a problem during an import of a new schema: the import hung with no apparent wait events. We found that the event it was waiting for was classified as &#8216;Idle&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; <span style="color: #993333; font-weight: bold;">SELECT</span> sid<span style="color: #66cc66;">,</span> username<span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">STATUS</span><span style="color: #66cc66;">,</span> event<span style="color: #66cc66;">,</span> wait_class<span style="color: #66cc66;">,</span> program <span style="color: #993333; font-weight: bold;">FROM</span> gv$session;
&nbsp;
 SID USERNAME   <span style="color: #993333; font-weight: bold;">STATUS</span>   EVENT                WAIT_CLASS PROGRAM
<span style="color: #808080; font-style: italic;">---- ---------- -------- -------------------- ---------- ----------------------------------------</span>
<span style="color: #66cc66;">...</span>
 <span style="color: #cc66cc;">135</span> SYS        ACTIVE   KSV master wait      Idle       imp@trndcsaixdb1 <span style="color: #66cc66;">&#40;</span>TNS V1<span style="color: #66cc66;">-</span>V3<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">...</span></pre></div></div>

<p>The on ASM instance:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; @wait10g
&nbsp;
SID USERNAME   MACHINE         PROGRAM              EVENT                  SEQ#           P1  S_IN_WAIT STATE               <span style="color: #993333; font-weight: bold;">STATUS</span>
<span style="color: #808080; font-style: italic;">---- ---------- --------------- -------------------- -------------------- ------ ------------ ---------- ------------------- --------</span>
<span style="color: #cc66cc;">201</span> SYS        trndcsaixdb1    oracle@trndcsaixdb1  enq: FA <span style="color: #66cc66;">-</span> access file      <span style="color: #cc66cc;">6</span>   <span style="color: #cc66cc;">1178664965</span>        <span style="color: #cc66cc;">744</span> WAITING             ACTIVE</pre></div></div>

<p>The problem was related to datafile resize (we use autoextend) and according to MOS, we were encountering a bug:</p>
<p>Bug 11712836: RESIZING DATAFILE HUNG WAITING FOR KSV MASTER WAIT IN RAC</p>
<p>Shutting down one instance solved the problem. Now we have to avoid autoextend&#8230;&#8230;. We never encountered this bug in many 10.2.0.4 rac installations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/ksv-master-wait/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle capacity planning with RRDTOOL</title>
		<link>http://www.ludovicocaldara.net/dba/oracle-capacity-planning-with-rrdtool/</link>
		<comments>http://www.ludovicocaldara.net/dba/oracle-capacity-planning-with-rrdtool/#comments</comments>
		<pubDate>Mon, 25 May 2009 16:18:50 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[awr]]></category>
		<category><![CDATA[Capacity Planning]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[rrdtool]]></category>
		<category><![CDATA[workload]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=68</guid>
		<description><![CDATA[RRDize everything, chapter 2 Oracle Database Server has the most powerful system catalog that allows to query almost any aspect inside an oracle instance. You can query many v$ fixed views at regular intervals and populate many RRD files through rrdtool: space usage, wait events. system statistics and so on&#8230; Since release 10.1 Oracle has [...]]]></description>
			<content:encoded><![CDATA[<p><strong>RRDize everything, chapter 2</strong></p>
<p>Oracle Database Server has the most powerful system catalog that allows to query almost any aspect inside an oracle instance.<br />
You can query many <em>v$</em> fixed views at regular intervals and populate many RRD files through <a href="http://oss.oetiker.ch/rrdtool/">rrdtool</a>: space usage, wait events. system statistics and so on&#8230;</p>
<p>Since release 10.1 Oracle has introduced <a href="www.oracle.com/technology/pub/articles/10gdba/week6_10gdba.html">Automatic Workload Repository</a>, a finer version of old good Statspack.<br />
No matter if you are using AWR or statspack, you can rely on their views to collect data for your RRDs.</p>
<p>If you are administering a new instance and you haven&#8217;t collected its statistics so far, you can query (as example) the DBA_HIST_BG_EVENT_SUMMARY view to gather all AWR data about wait events. Historical views could be useful also to collect historical data once a week rather than query the fixed views every few minutes doing the hard work twice (you and AWR).</p>
<p>The whole process of gathering performance data and update rrd files can be resumed into the following steps:</p>
<p>- connect to the database<br />
- query the AWR&#8217;s views<br />
- build and execute an rrdtool update command<br />
- check if rrd file exists or create it<br />
- update the rrd file</p>
<p>The less rrdtool update commands you will execute, the better the whole process will perform.<br />
Do it in a language you are comfortable with and that supports easily connection descriptors.</p>
<p>Since I&#8217;m very comfortable with php, I did it this way.</p>
<p>This is a very basilar script that works greatly for me with good performances:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/php -f
</span><span style="color: #339933;">&lt;</span> ?php                                         
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WD'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/opt/oracle/awr'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cs</span>         <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'argv'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span>       <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mymonitoruser'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pass</span>       <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mystrongpassword'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">/* open a new connection */</span>
<span style="color: #000088;">$ds</span> <span style="color: #339933;">=</span> oci_connect<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cs</span><span style="color: #009900;">&#41;</span>
        or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cannot connect to Oracle Database &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* setting client nls environment */</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;alter session set nls_timestamp_format='MM/DD/YY HH24:MI'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> oci_parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_free_statement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                         
&nbsp;
<span style="color: #666666; font-style: italic;">/* create directory that will contain rrds (if not exists) */</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/wait'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/wait'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                   
&nbsp;
<span style="color: #666666; font-style: italic;">/* function to create new RRDs */</span>
<span style="color: #000000; font-weight: bold;">function</span> createRRD<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$interval</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$hb</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$interval</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//heartbeat</span>
        <span style="color: #000088;">$cmd</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;rrdtool create &quot;</span><span style="color: #339933;">.</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/wait/<span style="color: #006699; font-weight: bold;">${name}</span>.rrd -s &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$interval</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; <span style="color: #000099; font-weight: bold;">\
</span>                -b <span style="color: #000099; font-weight: bold;">\&quot;</span>now -3month<span style="color: #000099; font-weight: bold;">\&quot;</span> DS:waits:DERIVE:<span style="color: #006699; font-weight: bold;">$hb</span>:0:U <span style="color: #000099; font-weight: bold;">\
</span>                DS:mswaited:DERIVE:<span style="color: #006699; font-weight: bold;">$hb</span>:0:U <span style="color: #000099; font-weight: bold;">\
</span>                RRA:AVERAGE:0.5:1:1440 RRA:AVERAGE:0.5:30:336 <span style="color: #000099; font-weight: bold;">\
</span>                RRA:AVERAGE:0.5:120:372 RRA:AVERAGE:0.5:720:730 <span style="color: #000099; font-weight: bold;">\
</span>                RRA:MIN:0.5:1:1440 RRA:MIN:0.5:30:336 <span style="color: #000099; font-weight: bold;">\
</span>                RRA:MIN:0.5:120:372 RRA:MIN:0.5:720:730 <span style="color: #000099; font-weight: bold;">\
</span>                RRA:MAX:0.5:1:1440 RRA:MAX:0.5:30:336 <span style="color: #000099; font-weight: bold;">\
</span>                RRA:MAX:0.5:120:372 RRA:MAX:0.5:720:730 <span style="color: #000099; font-weight: bold;">\
</span>                RRA:LAST:0.5:1:1440&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//print $cmd.&quot;\n&quot;;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">passthru</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>                                                                              
&nbsp;
<span style="color: #666666; font-style: italic;">/* take the snapshot frequency from dba_hist_wr_control
 to create the RDD with correct heartbeat value */</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'select extract(hour from snap_interval)*3600 +
extract(minute from snap_interval)*60 as SEED from DBA_HIST_WR_CONTROL'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> oci_parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> oci_fetch_assoc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$interval</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SEED'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_free_statement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                              
&nbsp;
<span style="color: #666666; font-style: italic;">/* statement definition that will collect
 all snapshots for a certain wait event with more than
 a certain amonut of time waited.
 Gathering ALL EVENTS could be time consuming and useless.
 I fetch rows ordered by event_name rather
 then by date because I can update many values
 into the same rrd with very few rrdupdate commands
*/</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'select s.END_INTERVAL_TIME END_INTERVAL_TIME,
    g.EVENT_NAME, g.WAIT_CLASS, g.TOTAL_WAITS,
    round(g.TIME_WAITED_MICRO/1000) MS
  from DBA_HIST_SNAPSHOT s,
   dba_hist_bg_event_summary g,
   v$instance i
 where s.SNAP_ID=g.SNAP_ID and g.wait_class!=\'Idle\'
  and g.TIME_WAITED_MICRO&amp;gt;100000
  and s.instance_number=i.instance_number
  and s.instance_number=g.instance_number
 order by 2,1'</span><span style="color: #339933;">;</span>                                      
&nbsp;
<span style="color: #666666; font-style: italic;">/* default prefetch size (148) matches default snapshot retention (24hx7dd) */</span>
<span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> oci_parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_set_prefetch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">148</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$oldevent</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> oci_fetch_assoc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$oldevent</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'EVENT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//NEW EVENT DETECTED: WILL START A NEW UPDATE CMD</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">/* not the first occurrence,
                         I bet there's something in my buffer */</span>
                        <span style="color: #990000;">passthru</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000088;">$cleanName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;([^[:alnum:]_-])&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'EVENT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">// if there is no rrd for this event, I create a new one</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/wait/<span style="color: #006699; font-weight: bold;">${cleanName}</span>.rrd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        createRRD<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cleanName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$interval</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cs</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #666666; font-style: italic;">/*
                * I initialize a new update command. This string act as a buffer: I append many
                * values to be updated so I'll update many values in a single command line:
                * less forks of rrdtool and less file opens: the whole update process has an
                * enormous improvement.
                */</span>
                <span style="color: #000088;">$precmd</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;rrdtool update &quot;</span><span style="color: #339933;">.</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/wait/<span style="color: #006699; font-weight: bold;">${cleanName}</span>.rrd &quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$lastcmd</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;rrdtool info &quot;</span><span style="color: #339933;">.</span>WD<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cs</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/wait/<span style="color: #006699; font-weight: bold;">${cleanName}</span>.rrd&quot;</span><span style="color: #339933;">.</span>
                        <span style="color: #0000ff;">&quot;| grep last_update | awk '{print <span style="color: #000099; font-weight: bold;">\$</span>NF}'&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$last</span><span style="color: #339933;">=</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span>`<span style="color: #000088;">$lastcmd</span>`<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%s</span> - <span style="color: #009933; font-weight: bold;">%s</span> - last: <span style="color: #009933; font-weight: bold;">%d</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'EVENT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cleanName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$last</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$cmd</span><span style="color: #339933;">=</span><span style="color: #000088;">$precmd</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$oldevent</span><span style="color: #339933;">=</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'EVENT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$time</span><span style="color: #339933;">=</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'END_INTERVAL_TIME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//print &quot;time: &quot;.$time.&quot;  last: &quot;.$last.&quot;\n&quot;;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$time</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$last</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TOTAL_WAITS'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'MS'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// when I reach 40 values per commandline I force</span>
                <span style="color: #666666; font-style: italic;">// the update: next loop will reinitialize a new commandline.</span>
                <span style="color: #990000;">passthru</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$cmd</span><span style="color: #339933;">=</span><span style="color: #000088;">$precmd</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/* one more update pending in my buffer */</span>
        <span style="color: #990000;">passthru</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
oci_free_statement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
oci_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Depending on how many different wait events you have, you&#8217;ll have a certain number of rrd files:</p>
<pre># ls -l
total 3864
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 Streams_AQ__enqueue_blocked_on_low_memory.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 20 08:18 buffer_busy_waits.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 control_file_parallel_write.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 control_file_sequential_read.rrd
-rw-r--r-- 1 ludovico ludovico 165304 Apr 30 10:12 cursor__pin_S_wait_on_X.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 db_file_scattered_read.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 db_file_sequential_read.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 events_in_waitclass_Other.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 latch__cache_buffers_chains.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 latch__library_cache.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 11 13:22 latch__library_cache_lock.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 20 08:18 latch__redo_writing.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 latch__row_cache_objects.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 latch__shared_pool.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 library_cache_load_lock.rrd
-rw-r--r-- 1 ludovico ludovico 165304 Apr 15 13:17 library_cache_lock.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 log_buffer_space.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 log_file_parallel_write.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 log_file_sequential_read.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 log_file_single_write.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 log_file_switch_completion.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 11 13:22 log_file_sync.rrd
-rw-r--r-- 1 ludovico ludovico 165304 May 25 15:00 os_thread_startup.rrd</pre>
<p>As you can see, they are not so big&#8230;</p>
<p>Once you have your data in rrd files, it&#8217;s quite simple to script even complex plots with several datasources. Everything depends on the results you want.<br />
This script stack all my wait events for a certain instance: it takes the directory containing all the rrds as first argument and the number of hours we want to be plotted as second argument:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">cs</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">hours</span>=<span style="color: #800000;">${2:-148}</span>
&nbsp;
<span style="color: #007800;">eventlist</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$cs</span><span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/*</span>rrd<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#000000&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#000055&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#0000aa&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#0000ff&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#550055&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#aa00aa&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#ff00ff&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#550000&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#aa0000&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">10</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#ff0000&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#555500&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#aaaa00&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">13</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#ffff00&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">14</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#005500&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">15</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#00aa00&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">16</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#00ff00&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">17</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#005555&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">18</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#00aaaa&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#00ffff&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#555555&quot;</span>
colors<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">21</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;#aaaaaa&quot;</span>
&nbsp;
<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> event <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$eventlist</span> ; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">end</span>=<span style="color: #000000; font-weight: bold;">`</span>rrdtool info <span style="color: #007800;">$event</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> last_update <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $NF}'</span><span style="color: #000000; font-weight: bold;">`</span>
                <span style="color: #007800;">end</span>=<span style="color: #000000; font-weight: bold;">`</span>rrdtool info <span style="color: #007800;">$cs</span><span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>control_file_parallel_write.rrd <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> last_update <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $NF}'</span><span style="color: #000000; font-weight: bold;">`</span>
                <span style="color: #007800;">cmd</span>=<span style="color: #ff0000;">&quot;rrdtool graph - -s end-<span style="color: #007800;">${hours}</span>hours -e <span style="color: #007800;">$end</span>  -v <span style="color: #000099; font-weight: bold;">\&quot;</span>milliseconds waited<span style="color: #000099; font-weight: bold;">\&quot;</span> -l 0 -w 640 -h 240 -t <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$cs</span> WAIT PROFILE<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>
                <span style="color: #007800;">i</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$i</span>+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #007800;">color</span>=<span style="color: #800000;">${colors[$i]}</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$color</span>
        <span style="color: #007800;">evname</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$event</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> s<span style="color: #000000; font-weight: bold;">/</span>\.rrd\$<span style="color: #000000; font-weight: bold;">//`</span>
        <span style="color: #007800;">cmd</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$cmd</span>  DEF:<span style="color: #007800;">$evname</span>=<span style="color: #007800;">$event</span>:mswaited:AVERAGE&quot;</span>
        <span style="color: #007800;">cmd</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$cmd</span>  AREA:<span style="color: #007800;">${evname}</span><span style="color: #007800;">${color}</span>:&quot;</span><span style="color: #007800;">$evname</span><span style="color: #ff0000;">&quot;:STACK&quot;</span>
        <span style="color: #007800;">i</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$i</span>+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">20</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">i</span>=<span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
        <span style="color: #007800;">cmd</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$cmd</span>  |display /dev/input&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$cmd</span>
        <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #007800;">$cmd</span>
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>The resulting command is very long:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rrdtool graph - <span style="color: #660033;">-s</span> end-148hours <span style="color: #660033;">-e</span> <span style="color: #000000;">1243252800</span> \
 <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;milliseconds waited&quot;</span> <span style="color: #660033;">-l</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-w</span> <span style="color: #000000;">640</span> <span style="color: #660033;">-h</span> <span style="color: #000000;">240</span> <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;mydb WAIT PROFILE&quot;</span>\
 DEF:<span style="color: #007800;">Streams_AQ__enqueue_blocked_on_low_memory</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>Streams_AQ__enqueue_blocked_on_low_memory.rrd:mswaited:AVERAGE \
 AREA:Streams_AQ__enqueue_blocked_on_low_memory<span style="color: #666666; font-style: italic;">#000000:Streams_AQ__enqueue_blocked_on_low_memory:STACK\</span>
 DEF:<span style="color: #007800;">buffer_busy_waits</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>buffer_busy_waits.rrd:mswaited:AVERAGE \
 AREA:buffer_busy_waits<span style="color: #666666; font-style: italic;">#000055:buffer_busy_waits:STACK\</span>
 DEF:<span style="color: #007800;">control_file_parallel_write</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>control_file_parallel_write.rrd:mswaited:AVERAGE \
 AREA:control_file_parallel_write<span style="color: #666666; font-style: italic;">#0000aa:control_file_parallel_write:STACK\</span>
 DEF:<span style="color: #007800;">control_file_sequential_read</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>control_file_sequential_read.rrd:mswaited:AVERAGE \
 AREA:control_file_sequential_read<span style="color: #666666; font-style: italic;">#0000ff:control_file_sequential_read:STACK\</span>
 DEF:<span style="color: #007800;">cursor__pin_S_wait_on_X</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>cursor__pin_S_wait_on_X.rrd:mswaited:AVERAGE \
 AREA:cursor__pin_S_wait_on_X<span style="color: #666666; font-style: italic;">#550055:cursor__pin_S_wait_on_X:STACK\</span>
 DEF:<span style="color: #007800;">db_file_scattered_read</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>db_file_scattered_read.rrd:mswaited:AVERAGE \
 AREA:db_file_scattered_read<span style="color: #666666; font-style: italic;">#aa00aa:db_file_scattered_read:STACK\</span>
 DEF:<span style="color: #007800;">db_file_sequential_read</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>db_file_sequential_read.rrd:mswaited:AVERAGE \
 AREA:db_file_sequential_read<span style="color: #666666; font-style: italic;">#ff00ff:db_file_sequential_read:STACK\</span>
 DEF:<span style="color: #007800;">events_in_waitclass_Other</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>events_in_waitclass_Other.rrd:mswaited:AVERAGE \
 AREA:events_in_waitclass_Other<span style="color: #666666; font-style: italic;">#550000:events_in_waitclass_Other:STACK\</span>
 DEF:<span style="color: #007800;">latch__cache_buffers_chains</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>latch__cache_buffers_chains.rrd:mswaited:AVERAGE \
 AREA:latch__cache_buffers_chains<span style="color: #666666; font-style: italic;">#aa0000:latch__cache_buffers_chains:STACK\</span>
 DEF:<span style="color: #007800;">latch__library_cache</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>latch__library_cache.rrd:mswaited:AVERAGE \
 AREA:latch__library_cache<span style="color: #666666; font-style: italic;">#ff0000:latch__library_cache:STACK\</span>
 DEF:<span style="color: #007800;">latch__library_cache_lock</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>latch__library_cache_lock.rrd:mswaited:AVERAGE \
 AREA:latch__library_cache_lock<span style="color: #666666; font-style: italic;">#555500:latch__library_cache_lock:STACK\</span>
 DEF:<span style="color: #007800;">latch__redo_writing</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>latch__redo_writing.rrd:mswaited:AVERAGE \
 AREA:latch__redo_writing<span style="color: #666666; font-style: italic;">#aaaa00:latch__redo_writing:STACK\</span>
 DEF:<span style="color: #007800;">latch__row_cache_objects</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>latch__row_cache_objects.rrd:mswaited:AVERAGE \
 AREA:latch__row_cache_objects<span style="color: #666666; font-style: italic;">#ffff00:latch__row_cache_objects:STACK\</span>
 DEF:<span style="color: #007800;">latch__shared_pool</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>latch__shared_pool.rrd:mswaited:AVERAGE \
 AREA:latch__shared_pool<span style="color: #666666; font-style: italic;">#005500:latch__shared_pool:STACK\</span>
 DEF:<span style="color: #007800;">library_cache_load_lock</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>library_cache_load_lock.rrd:mswaited:AVERAGE \
 AREA:library_cache_load_lock<span style="color: #666666; font-style: italic;">#00aa00:library_cache_load_lock:STACK\</span>
 DEF:<span style="color: #007800;">library_cache_lock</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>library_cache_lock.rrd:mswaited:AVERAGE \
 AREA:library_cache_lock<span style="color: #666666; font-style: italic;">#00ff00:library_cache_lock:STACK\</span>
 DEF:<span style="color: #007800;">log_buffer_space</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>log_buffer_space.rrd:mswaited:AVERAGE \
 AREA:log_buffer_space<span style="color: #666666; font-style: italic;">#005555:log_buffer_space:STACK\</span>
 DEF:<span style="color: #007800;">log_file_parallel_write</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>log_file_parallel_write.rrd:mswaited:AVERAGE \
 AREA:log_file_parallel_write<span style="color: #666666; font-style: italic;">#00aaaa:log_file_parallel_write:STACK\</span>
 DEF:<span style="color: #007800;">log_file_sequential_read</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>log_file_sequential_read.rrd:mswaited:AVERAGE \
 AREA:log_file_sequential_read<span style="color: #666666; font-style: italic;">#00ffff:log_file_sequential_read:STACK\</span>
 DEF:<span style="color: #007800;">log_file_single_write</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>log_file_single_write.rrd:mswaited:AVERAGE \
 AREA:log_file_single_write<span style="color: #666666; font-style: italic;">#000000:log_file_single_write:STACK\</span>
 DEF:<span style="color: #007800;">log_file_switch_completion</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>log_file_switch_completion.rrd:mswaited:AVERAGE \
 AREA:log_file_switch_completion<span style="color: #666666; font-style: italic;">#000055:log_file_switch_completion:STACK\</span>
 DEF:<span style="color: #007800;">log_file_sync</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>log_file_sync.rrd:mswaited:AVERAGE \
 AREA:log_file_sync<span style="color: #666666; font-style: italic;">#0000aa:log_file_sync:STACK\</span>
 DEF:<span style="color: #007800;">os_thread_startup</span>=mydb<span style="color: #000000; font-weight: bold;">/</span>wait<span style="color: #000000; font-weight: bold;">/</span>os_thread_startup.rrd:mswaited:AVERAGE \
 AREA:os_thread_startup<span style="color: #666666; font-style: italic;">#0000ff:os_thread_startup:STACK |display /dev/input</span></pre></div></div>

<p>This is the resulting graph:<br />
<a href="http://www.ludovicocaldara.net/images/mydb_events.png"><img alt="Graph plotted with rrdtool displaying Oracle instance Wait Events" src="http://www.ludovicocaldara.net/images/mydb_events.png" title="Oracle Instance Wait Events" width="737" height="398" /></a></p>
<p><strong>OHHHHHHHHHHHH COOOOL!!!</strong><br />
 <img src='http://www.ludovicocaldara.net/dba/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Any comment is appreciated! thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/oracle-capacity-planning-with-rrdtool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More about Dataguard and how to check it</title>
		<link>http://www.ludovicocaldara.net/dba/more-about-dataguard-and-how-to-check-it/</link>
		<comments>http://www.ludovicocaldara.net/dba/more-about-dataguard-and-how-to-check-it/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 11:27:51 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[MRP0]]></category>
		<category><![CDATA[Oracle Dataguard]]></category>
		<category><![CDATA[real-time apply]]></category>
		<category><![CDATA[Standby]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=54</guid>
		<description><![CDATA[After my post Quick Oracle Dataguard check script I have some considerations to add: to check the gap of applied log stream by MRP0 process it&#8217;s sufficient to replace this query in the perl script I posted: SELECT SEQUENCE#, BLOCK# FROM v\$managed_standby WHERE process='RFS' AND client_process='LGWR' with this new one: SELECT SEQUENCE#, BLOCK# FROM v\$managed_standby [...]]]></description>
			<content:encoded><![CDATA[<p>After my post <a href="http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/">Quick Oracle Dataguard check script</a> I have some considerations to add:<br />
to check the gap of applied log stream by <strong>MRP0</strong> process it&#8217;s sufficient to replace this query in the perl script I posted:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">SEQUENCE</span>#<span style="color: #66cc66;">,</span> BLOCK# <span style="color: #993333; font-weight: bold;">FROM</span> v\$managed_standby
        <span style="color: #993333; font-weight: bold;">WHERE</span> process<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'RFS'</span> <span style="color: #993333; font-weight: bold;">AND</span> client_process<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'LGWR'</span></pre></div></div>

<p>with this new one:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">SEQUENCE</span>#<span style="color: #66cc66;">,</span> BLOCK# <span style="color: #993333; font-weight: bold;">FROM</span> v\$managed_standby
        <span style="color: #993333; font-weight: bold;">WHERE</span> process<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'MRP0'</span></pre></div></div>

<p>To check this you have to meet the following condition: You should have real-time apply enabled (and possibly NODELAY clause specified in your recover statement). Check it with this query:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> RECOVERY_MODE <span style="color: #993333; font-weight: bold;">FROM</span> V$ARCHIVE_DEST_STATUS;</pre></div></div>

<p>It should be &#8220;MANAGED REAL TIME APPLY&#8221;.<br />
If not using realtime apply your MRP0 process will wait until you have a new archive, so even if you have redo transport mode set to LGWR you&#8217;ll wait for standby log completion. Your gap of applied redo stream will be at least one sequence#.</p>
<p>With transport mode set to LGWR and real-time apply the output of the perl script is similar to this one:</p>
<pre>
# ./checkDataGuard.sh
PROD   :       1230      20631
STANDBY:       1230      20613
18         blocks gap
</pre>
<p>The whole gap between your primary and standby database should be LOW.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/more-about-dataguard-and-how-to-check-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Oracle Dataguard check script</title>
		<link>http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/</link>
		<comments>http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 15:49:10 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle Dataguard]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=38</guid>
		<description><![CDATA[Oracle Dataguard has his own command-line dgmgrl to check the whole dataguard configuration status. At least you should check that the show configuration command returns SUCCESS. This is an hypothetic script: #!/bin/bash export ORACLE_HOME=/u1/app/oracle/product/10.2.0 export ORACLE_SID=orcldg result=`echo &#34;show configuration;&#34; &#124; \ $ORACLE_HOME/bin/dgmgrl sys/strongpasswd &#124; \ grep -A 1 &#34;Current status for&#34; &#124; grep -v &#34;Current [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle Dataguard has his own command-line <i>dgmgrl</i> to check the whole dataguard configuration status.<br />
At least you should check that the <i>show configuration</i> command returns <b>SUCCESS</b>.</p>
<p>This is an hypothetic script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>u1<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>product<span style="color: #000000; font-weight: bold;">/</span>10.2.0
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_SID</span>=orcldg
<span style="color: #007800;">result</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;show configuration;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> \
  <span style="color: #007800;">$ORACLE_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dgmgrl sys<span style="color: #000000; font-weight: bold;">/</span>strongpasswd <span style="color: #000000; font-weight: bold;">|</span> \
  <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-A</span> <span style="color: #000000;">1</span> <span style="color: #ff0000;">&quot;Current status for&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;Current status for&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$result</span>&quot;</span> = <span style="color: #ff0000;">&quot;SUCCESS&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Another script should check for the gap between production online log and the log stream received by the standby database. This can be accomplished with v$managed_standby view.<br />
The Total Block Gap between production and standby can be calculated this way:<br />
Sum all blocks from v$archived_logs where seq# between  Current Standby Seq# and Current Production Seq#.  Then add current block# of the production LGWR process and subtract current block# from RFS standby process. This gives you total blocks even if there is a log sequence gap between sites.<br />
This is NOT the gap of online log APPLIED to the standby database. THIS IS THE GAP OF ONLINE LOG TRANSMITTED TO THE STANDBY RFS PROCESS and can be used to monitor your dataguard transmission from production to disaster recovery environment.</p>
<p>This is an excerpt of such script (please take care that it does not check against RFS failures, so it can fails when RFS is not alive):</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/u1/app/oracle/product/10.2.0/perl/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> DBI<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> DBD<span style="color: #339933;">::</span><span style="color: #006600;">Oracle</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">:</span>ora_session_modes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># DB connection #</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$prod</span>  <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;orclprod&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stby</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;orcldr&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$prodh</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$prodh</span> <span style="color: #339933;">=</span> DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'dbi:Oracle:'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$prod</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'sys'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'strongpassword'</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span>PrintError<span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> AutoCommit <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
  ora_session_mode <span style="color: #339933;">=&gt;</span> ORA_SYSDBA<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Error connecting to DB: $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>RaiseError<span style="color: #009900;">&#125;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">unless</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$stbyh</span> <span style="color: #339933;">=</span> DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'dbi:Oracle:'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$stby</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'sys'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'strongpassword'</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span>PrintError<span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> AutoCommit <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
  ora_session_mode <span style="color: #339933;">=&gt;</span> ORA_SYSDBA<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Error connecting to DB: $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>RaiseError<span style="color: #009900;">&#125;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">### query prod</span>
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">select</span> SEQUENCE<span style="color: #666666; font-style: italic;">#, BLOCK# from v\$managed_standby</span>
        where process<span style="color: #339933;">=</span><span style="color: #ff0000;">'LGWR'</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$psequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetchrow_array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">### query stdby</span>
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">select</span> SEQUENCE<span style="color: #666666; font-style: italic;">#, BLOCK# from v\$managed_standby</span>
        where process<span style="color: #339933;">=</span><span style="color: #ff0000;">'RFS'</span> <span style="color: #b1b100;">and</span> client_process<span style="color: #339933;">=</span><span style="color: #ff0000;">'LGWR'</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ssequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$sblock</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetchrow_array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;PROD   : %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$psequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;STANDBY: %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ssequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$sblock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">select</span> nvl<span style="color: #009900;">&#40;</span>sum<span style="color: #009900;">&#40;</span>blocks<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">+</span> <span style="color: #0000ff;">$pblock</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$sblock</span> as BLOCK_GAP
    from v<span style="color: #0000ff;">\$archived_log</span>
        where sequence<span style="color: #666666; font-style: italic;"># between $ssequence and $psequence</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$blockgap</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetchrow_array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%-10d blocks gap<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$blockgap</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #339933;">;</span></pre></div></div>

<p>Any comment is appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tips: Bash Prompt and Oracle</title>
		<link>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/</link>
		<comments>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 23:19:18 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[prompt]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=36</guid>
		<description><![CDATA[export PS1=\u@\h:\w\$ I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths: ludovico@host:/u01/app/oracle/product/10.2.0/network/admin$ \ /nooo/this/command/line/is/really/long/and/offcourse -I \ -will -wrap -my -command -line and, when working on multi-database environments I need to check my environment: env &#124; grep -i oracle #or echo $ORACLE_SID echo $ORACLE_HOME I currently use this prompt, [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=\u<span style="color: #000000; font-weight: bold;">@</span>\h:\<span style="color: #c20cb9; font-weight: bold;">w</span>\$</pre></div></div>

<p>I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ludovico<span style="color: #000000; font-weight: bold;">@</span>host:<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>product<span style="color: #000000; font-weight: bold;">/</span>10.2.0<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>admin$ \
<span style="color: #000000; font-weight: bold;">/</span>nooo<span style="color: #000000; font-weight: bold;">/</span>this<span style="color: #000000; font-weight: bold;">/</span>command<span style="color: #000000; font-weight: bold;">/</span>line<span style="color: #000000; font-weight: bold;">/</span>is<span style="color: #000000; font-weight: bold;">/</span>really<span style="color: #000000; font-weight: bold;">/</span>long<span style="color: #000000; font-weight: bold;">/</span>and<span style="color: #000000; font-weight: bold;">/</span>offcourse <span style="color: #660033;">-I</span> \
<span style="color: #660033;">-will</span> <span style="color: #660033;">-wrap</span> <span style="color: #660033;">-my</span> <span style="color: #660033;">-command</span> <span style="color: #660033;">-line</span></pre></div></div>

<p>and, when working on multi-database environments I need to check my environment:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> oracle
<span style="color: #666666; font-style: italic;">#or</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$ORACLE_SID</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$ORACLE_HOME</span></pre></div></div>

<p>I currently use this prompt, instead:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=$<span style="color: #ff0000;">'\\n# [ $LOGNAME@\h:$PWD [\\t] [`ohvers` SID:${ORACLE_SID:-&quot;no sid&quot;}] ]\\n# '</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># [ ludovico@caldara_2k:/u01/app/oracle/product/10.2.0/db_1/network/admin [23:15:58] [10.2.0 SID:orcl] ]</span>
<span style="color: #666666; font-style: italic;">#</span></pre></div></div>

<p>What is `<em>ohvers</em>`?? I defined this function to get the version of oracle from my ORACLE_HOME variable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ohvers <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$ORACLE_HOME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'s/.*\/\([[:digit:].]\+\)\/.*/\1/p'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Pros:</p>
<ul>
<li>I have a blank line that separate my prompt from previous output</li>
<li>I get the system clock (useful when saving my konsole history. Did I say konsole?)</li>
<li>I can see my Oracle Environment before launching dangerous commands</li>
<li>I have an empty line to start my endless commands</li>
<li>I have a lot of sharps &#8220;#&#8221; : they are fine against wrong copy&amp;paste operations&#8230;</li>
</ul>
<p>Suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle RAC Standard Edition to achieve low cost and high performance</title>
		<link>http://www.ludovicocaldara.net/dba/oracle-rac-standard-edition-to-achieve-low-cost-and-high-performance/</link>
		<comments>http://www.ludovicocaldara.net/dba/oracle-rac-standard-edition-to-achieve-low-cost-and-high-performance/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 23:43:04 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[RAC]]></category>
		<category><![CDATA[Standard Edition]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=29</guid>
		<description><![CDATA[I finished today to create a new production environment based on 2 Linux serverX86_64 and running Oracle RAC 10gR2. (I know, there is 11g right now, but I&#8217;m a conservative!) Wheeew, I just spent a couple of hours applying all the recommended patches! We choosed 2 nodes with a maximum of 2 multi-core processors each [...]]]></description>
			<content:encoded><![CDATA[<p>I finished today to create a new production environment based on 2 Linux serverX86_64 and running Oracle RAC 10gR2. (I know, there is 11g right now, but I&#8217;m a conservative!)<br />
Wheeew, I just spent a couple of hours applying all the recommended patches!<br />
We choosed 2 nodes with a maximum of 2 multi-core processors each one so we can license Standard Edition instead of Enterprise Edition. 64bits addressing allow us to allocate many gigabytes of SGA. I&#8217;m starting with 5Gb but I think we&#8217;ll need more. And a set of 6x300Gb 15krpms disks (it can be expanded with more disks and more shelves).<br />
This configuration keeps low the total cost of ownership but achieves best performance.<br />
Due to disks layout, costs and needed usable storage, we had to configure one huge RAID5 on the SAN with multi-path. I decided anyway to create 2 ASM disk groups (ASM is mandatory for Standard Edition RAC), one for the DB, the second one for the recovery area. With spare disks we should have enough availability and even if it&#8217;s a RAID5 I saw good write performances (&gt;150M/s).</p>
<p>Welcome new RAC, I hope we&#8217;ll feel good together!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/oracle-rac-standard-edition-to-achieve-low-cost-and-high-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s time to trouble&#8230;</title>
		<link>http://www.ludovicocaldara.net/dba/its-time-to-trouble/</link>
		<comments>http://www.ludovicocaldara.net/dba/its-time-to-trouble/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 10:42:58 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=24</guid>
		<description><![CDATA[Sometimes it&#8217;s hard to find enough time to write something or even to only THINK about writing something&#8230; The following are the projects I have to complete before the deadline of December 17th (at least if I still want to go on vacation&#8230;) A totally new Oracle 10gR2 RAC SE on Linux (OCFS2, ASM) including [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes <strong>it&#8217;s hard to find enough time to</strong> write something or even to only <strong>THINK about writing something</strong>&#8230;</p>
<p>The following are the projects I have to complete before the deadline of December 17th (at least if I still want to go on vacation&#8230;)</p>
<ul>
<li>A totally new <strong>Oracle 10gR2 RAC SE</strong> on Linux (<strong>OCFS2</strong>, <strong>ASM</strong>) including <strong>jboss</strong> frontends, backups, monitoring, documentation. (Servers are ready today).</li>
</ul>
<ul>
<li>A <strong>Disaster recovery</strong> architecture based on <strong>Dataguard</strong> with scripts based on rsync to do filesystem replication, with failover and failback, including backups, monitoring, documentation. (The server in DR site is reachable via network today).</li>
</ul>
<ul>
<li>A <strong>17 server</strong> infrastructure (among others a <strong>RAC 10gR2</strong> on linux) <strong>transfer</strong> from Milan datacenter to here. It&#8217;s planned for december 11th but I have to crosscheck backup and contingency requirements.</li>
</ul>
<ul>
<li>A <strong>14 serve</strong>r infrastructure (based on Windows and <strong>SqlServer</strong>) transfer from Milan datacenter to here. To be planned in december.</li>
</ul>
<ul>
<li>A totally new cold failover cluster based on linux with <strong>Oracle DBMS and E-business suite</strong> (Servers will be provided soon, I hope!).</li>
</ul>
<ul>
<li>A new standalone <strong>Windows Server 64bit</strong> to outstand the 32bit allocation bottleneck for a <strong>500Gb</strong> oracle database (Server will be provided not before december 10th).</li>
</ul>
<ul>
<li>Normally manage the day-by-day work, including replying to e-mails and answering the phone.</li>
</ul>
<p><strong>AARGH!!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/its-time-to-trouble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System triggers, stats$user_log and side effects</title>
		<link>http://www.ludovicocaldara.net/dba/system-triggers-statsuser_log-and-side-effects/</link>
		<comments>http://www.ludovicocaldara.net/dba/system-triggers-statsuser_log-and-side-effects/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 15:44:21 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=22</guid>
		<description><![CDATA[Sometimes people get advice from internet: both Metalink or well-known consulting sites. If people need a fix or a feature, they use to trust advices. Last week I heard a collegue about a 10g RAC database with performance problems and, since I never lay on my chair, I probed both AWR and ADDM . I [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes people get advice from internet: both Metalink or well-known consulting sites.<br />
If people need a fix or a feature, they use to trust advices.</p>
<p>Last week I heard a collegue about a 10g RAC database with performance problems and, since I never lay on my chair, I probed both AWR and ADDM . I suddenly recognized heavy enqueues and physical reads<br />
over a segment named STATS$USER_LOG. &#8220;Strange&#8221;, I said, &#8220;I cannot remember this name in neither perfstat or catalog segments&#8221;.<br />
Then I searched the Internet and the Metalink and found the same thing in BOTH metalink.oracle.com and www.dba-oracle.com: a trick to trace logon and logoffs into a table using system triggers.</p>
<p>Look at this code:</p>
<p><code>create or replace trigger<br />
logon_audit_trigger<br />
AFTER LOGON ON DATABASE<br />
BEGIN<br />
insert into stats$user_log values(<br />
user,<br />
sys_context('USERENV','SESSIONID'),<br />
sys_context('USERENV','HOST'),<br />
sysdate,<br />
to_char(sysdate, 'hh24:mi:ss'),<br />
[...]<br />
);<br />
COMMIT;<br />
END;<br />
/</code></p>
<p>Cool, every single access is kept into stats$user_log.</p>
<p>Let&#8217;s see the logoff trigger:</p>
<p><code>create or replace trigger<br />
logoff_audit_trigger<br />
BEFORE LOGOFF ON DATABASE<br />
BEGIN<br />
-- ***************************************************<br />
-- Update the last action accessed<br />
-- ***************************************************<br />
update stats$user_log [...]<br />
--***************************************************<br />
-- Update the last program accessed<br />
-- ***************************************************<br />
update stats$user_log [...]<br />
-- ***************************************************<br />
[ ... many, many updates ...]<br />
-- ***************************************************<br />
update stats$user_log [...]<br />
-- ***************************************************<br />
-- Compute the elapsed minutes<br />
-- ***************************************************<br />
update stats$user_log set elapsed_minutes =<br />
round((logoff_day - logon_day)*1440)<br />
where<br />
sys_context('USERENV','SESSIONID') = session_id;<br />
COMMIT;<br />
END;<br />
/<br />
</code><br />
That&#8217;s all. It inserts a row when someone logons. It updates MANY rows when someone logoffs.<br />
There is no match between the record inserted and the records updated (but the session_id).<br />
Neither indexes or constraints.</p>
<p>What&#8217;s the matter?</p>
<p>What happens if we have many logons?</p>
<p><code>SQL&gt; select num_rows from dba_tables where table_name='STATS$USER_LOG';</code></p>
<p>NUM_ROWS<br />
&#8212;&#8212;&#8212;-<br />
3053931</p>
<p>What happens if the execution plan does a full scan?</p>
<p>SQL&gt; explain plan for update stats$user_log [...]</p>
<p>Explained.</p>
<p><code>SQL&gt; @?/rdbms/admin/utlxpls<br />
---------------------------------------------<br />
| Id  | Operation          | Name           |<br />
---------------------------------------------<br />
|   0 | UPDATE STATEMENT   |                |<br />
|   1 |  UPDATE            | STATS$USER_LOG |<br />
|   2 |   TABLE ACCESS FULL| STATS$USER_LOG |<br />
---------------------------------------------</code></p>
<p>How many reads should it take?</p>
<p><code>SQL&gt; select bytes/1024/1024 Mb from dba_Segments where segment_name='STATS$USER_LOG';</code></p>
<p>MB<br />
&#8212;&#8212;&#8212;-<br />
237</p>
<p>The database performace will decrease constantly and very slowly&#8230;..<br />
Remember: never trust a solution if it involves a change on the system.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/system-triggers-statsuser_log-and-side-effects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sometimes they come back</title>
		<link>http://www.ludovicocaldara.net/dba/sometimes-they-come-back/</link>
		<comments>http://www.ludovicocaldara.net/dba/sometimes-they-come-back/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 09:08:31 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[nt]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[use_shared_socket]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=20</guid>
		<description><![CDATA[A collegue called me yesterday. Collegue: &#8220;Hi, I cannot acces a customer database, it&#8217;s urgent. Can you help me?&#8221; Me: &#8220;Did you ever connect to the database?&#8221; Collegue: &#8220;Off course, but last monday netadmins reconfigured a router: that&#8217;s when the problem started.&#8221; Me: &#8220;Reconfigured what? Collegue: &#8220;A router: the router lost the config.&#8221; I tried [...]]]></description>
			<content:encoded><![CDATA[<p>A collegue called me yesterday.<br />
Collegue: &#8220;Hi, I cannot acces a customer database, it&#8217;s urgent. Can you help me?&#8221;<br />
Me: &#8220;Did you ever connect to the database?&#8221;<br />
Collegue: &#8220;Off course, but last monday netadmins reconfigured a router: that&#8217;s when the problem started.&#8221;<br />
Me: &#8220;Reconfigured what?<br />
Collegue: &#8220;A router: the router lost the config.&#8221;</p>
<p>I tried the connection to the database: network timeout received.</p>
<p>Me: &#8220;Can the customer connect from his network?&#8221;<br />
Collegue: &#8220;Yes, it doesn&#8217;t work only from our network.&#8221;<br />
Me: &#8220;Is there a NAT?&#8221;<br />
Collegue: &#8220;Yes, the real address is different.&#8221;<br />
Me: &#8220;Is the db server running Windows&#8221;?<br />
Collegue: &#8220;I forgot! It&#8217;s a Windows NT.&#8221;<br />
Me: &#8220;Mmh, I should ask netadmins. Perhaps you can workaround putting &#8220;USE_SHARED_SOCKET&#8221; in the registry&#8230; Is the release at least 9i?&#8221;<br />
Collegue: &#8220;It&#8217;s a 7.3&#8243;<br />
Me: &#8220;@#&#8221;&#038;%!?&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/sometimes-they-come-back/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

