<?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 Dataguard</title>
	<atom:link href="http://www.ludovicocaldara.net/dba/tag/oracle-dataguard/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>Dataguard check script for Real Application Clusters (MAA)</title>
		<link>http://www.ludovicocaldara.net/dba/dataguard-check-script-for-real-application-clusters-maa/</link>
		<comments>http://www.ludovicocaldara.net/dba/dataguard-check-script-for-real-application-clusters-maa/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 13:46:30 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[maximum availability architecture]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle Dataguard]]></category>
		<category><![CDATA[Oracle MAA]]></category>
		<category><![CDATA[Perl script]]></category>
		<category><![CDATA[RAC]]></category>
		<category><![CDATA[real-time apply]]></category>
		<category><![CDATA[Standby]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=86</guid>
		<description><![CDATA[Two years after my posts: Quick Oracle Dataguard check script and More about Dataguard and how to check it I faced a whole new Dataguard between two Oracle Real Application Clusters, aka Oracle Maximum Availability Architecture (MAA). This enviromnent is relying on Windows OS. Don&#8217;t know how this could be called &#8220;availability&#8221; but here we [...]]]></description>
			<content:encoded><![CDATA[<p>Two years after my posts:<br />
<a href="http://www.ludovicocaldara.net/dba/quick-oracle-dataguard-check-script/">Quick Oracle Dataguard check script</a> and <a href="http://www.ludovicocaldara.net/dba/more-about-dataguard-and-how-to-check-it">More about Dataguard and how to check it</a> I faced a whole new <strong>Dataguard </strong> between two <strong>Oracle Real Application Clusters</strong>, aka <em>Oracle Maximum Availability Architecture (MAA)</em>.</p>
<p>This enviromnent is relying on Windows OS. Don&#8217;t know how this could be called &#8220;<em>availability</em>&#8221; but here we are. I revisited my scripts in a quick and very dirty way. Please consider that I did copy and paste to check the alignment once per thread, but it should be improved with some kind of iteration to check each thread in a more structured fashion.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!D:\oracle\product\10.2.0\db_1\perl\5.8.3\bin\MSWin32-x86-multi-thread\perl.exe -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;prod&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;stby&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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>connect<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;">'strongpwd'</span><span style="color: #339933;">,</span> 
    <span style="color: #009900;">&#123;</span>PrintError<span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> AutoCommit <span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
    ora_session_mode <span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>connect<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;">'strongpwd'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span>PrintError<span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> AutoCommit <span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
    ora_session_mode <span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>disconnect<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</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 stdby MRP0</span>
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>prepare<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">select</span> thread<span style="color: #666666; font-style: italic;">#, SEQUENCE#, BLOCK#</span>
    from gv<span style="color: #0000ff;">\$managed_standby</span> 
    where process<span style="color: #339933;">=</span><span style="color: #ff0000;">'MRP0'</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>execute<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;">$mrpthread</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mrpsequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mrpblock</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>finish<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### query stdby RFS</span>
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>prepare<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">select</span> thread<span style="color: #666666; font-style: italic;">#, SEQUENCE#, BLOCK#</span>
    from gv<span style="color: #0000ff;">\$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> order by thread<span style="color: #666666; font-style: italic;">#</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>execute<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;">$rfsthread1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfssequence1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfsblock1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">$rfsthread2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfssequence2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfsblock2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>finish<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>prepare<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span>EOSQL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">select</span> thread<span style="color: #666666; font-style: italic;">#, SEQUENCE#, BLOCK#</span>
    from gv<span style="color: #0000ff;">\$managed_standby</span>
    where process<span style="color: #339933;">=</span><span style="color: #ff0000;">'LNS'</span> order by thread<span style="color: #666666; font-style: italic;">#</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>execute<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;">$pthread1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$psequence1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">$pthread2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$psequence2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>finish<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ENVIRONM  Thread Sequence   Block<span style="color: #000099; font-weight: bold;">\n</span>&quot;</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;--------- ------ ---------- ----------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</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;PROD     LNS1  1 %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$psequence1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock1</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  RFS1  1 %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfssequence1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfsblock1</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;PROD     LSN2  2 %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$psequence2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$pblock2</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  RFS2  2 %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfssequence2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfsblock2</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  MRP0  %d %10d %10d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mrpthread</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mrpsequence</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mrpblock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$psequence</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pblock</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$mrpthread</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #0000ff;">$psequence</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$psequence1</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$pblock</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$pblock1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #0000ff;">$psequence</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$psequence2</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$pblock</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$pblock2</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>prepare<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</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;">$mrpblock</span> as BLOCK_GAP
from gv<span style="color: #0000ff;">\$archived_log</span>
where thread<span style="color: #666666; font-style: italic;">#=$mrpthread and sequence#</span>
between <span style="color: #0000ff;">$mrpsequence</span> <span style="color: #b1b100;">and</span> <span style="color: #0000ff;">$psequence</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>execute<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;">$mrpblockgap</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>finish<span style="color: #009900;">&#40;</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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>prepare<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</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;">$pblock1</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$rfsblock1</span> as BLOCK_GAP
from gv<span style="color: #0000ff;">\$archived_log</span>
where thread<span style="color: #666666; font-style: italic;">#=1 and sequence#</span>
between <span style="color: #0000ff;">$rfssequence1</span> <span style="color: #b1b100;">and</span> <span style="color: #0000ff;">$psequence1</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>execute<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;">$rfsblockgap1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>finish<span style="color: #009900;">&#40;</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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>prepare<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</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;">$pblock2</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$rfsblock2</span> as BLOCK_GAP
from gv<span style="color: #0000ff;">\$archived_log</span>
where thread<span style="color: #666666; font-style: italic;">#=2 and sequence#</span>
between <span style="color: #0000ff;">$rfssequence2</span> <span style="color: #b1b100;">and</span> <span style="color: #0000ff;">$psequence2</span>
EOSQL
<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>execute<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;">$rfsblockgap2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetchrow_array<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;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>finish<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;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>%-10d blocks gap in TRANSMISSION<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rfsblockgap1</span><span style="color: #339933;">+</span><span style="color: #0000ff;">$rfsblockgap2</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 in APPLY (MRP0)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mrpblockgap</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$stbyh</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>disconnect<span style="color: #339933;">;</span>
<span style="color: #0000ff;">$prodh</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>disconnect<span style="color: #339933;">;</span></pre></div></div>

<p>Please foreward me every improvement you implement over my code: it would be nice to post it here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/dataguard-check-script-for-real-application-clusters-maa/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>

