<?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>Andrew Fraser DBA &#187; RAC</title>
	<atom:link href="http://andrewfraserdba.com/category/rac/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewfraserdba.com</link>
	<description>Oracle DBA (plus SQL Server)</description>
	<lastBuildDate>Wed, 18 Jan 2012 15:25:23 +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>Intermittent ORA-12545 with oracle RAC database</title>
		<link>http://andrewfraserdba.com/2011/05/09/intermittent-ora-12545-with-oracle-rac-database/</link>
		<comments>http://andrewfraserdba.com/2011/05/09/intermittent-ora-12545-with-oracle-rac-database/#comments</comments>
		<pubDate>Mon, 09 May 2011 14:21:38 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[RAC]]></category>
		<category><![CDATA[SQL*Net]]></category>

		<guid isPermaLink="false">http://andrewfraserdba.com/?p=696</guid>
		<description><![CDATA[Problem: Client suffers intermittent ORA-12545 &#8220;Connect failed because target host or object does not exist&#8221; trying to connect to oracle RAC database. Solution: Edit server side (not client side) listener.ora and tnsnames.ora files to have fully qualified hostnames. Thanks to &#8230; <a href="http://andrewfraserdba.com/2011/05/09/intermittent-ora-12545-with-oracle-rac-database/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: </strong>Client suffers intermittent ORA-12545 &#8220;<em>Connect failed because target host or object does not exist</em>&#8221; trying to connect to oracle RAC database.<br />
<strong>Solution:</strong> Edit server side (not client side) listener.ora and tnsnames.ora files to have fully qualified hostnames.</p>
<p>Thanks to <a href="http://www.davidyahalom.com/index.php/intermittent-ora-12545-when-trying-to-connect-to-rac-database/">David Yahalom</a> for flagging this &#8211; it doesn&#8217;t appear to be covered in metalink/my oracle support.</p>
<p>RAC servers were configured to resolve each others host names with &#8211; so &#8216;racserver1&#8242; resolved to the same IP address as did the fully qualified name &#8216;racserver1.admin.mycompany.com&#8217;.</p>
<p>Client machine (web servers in my case) were not configured in that way. So they could resolve  &#8216;racserver1.admin.mycompany.com&#8217; ok, but could not resolve &#8216;racserver1&#8242;.</p>
<p>You might think that simply specifying the fully qualified hostnames in the <em>client</em> connect string (only) would be enough to resolve this.  But no.  Server side load balancing will every so often redirect the client to a new hostname.  The client has to be able to resolve that new hostname, or it will report an ORA-12545.  And that new hostname is supplied by the server, based on what is in the server listener and tnsnames settings.  This behaviour is the default (at least in Oracle 11gR1).</p>
<p>This is especially likely with web servers, where security considerations might mean they don&#8217;t see exactly the same DNS as other servers do, so is often seen with jdbc, java, php oci8.  But really it is a general oracle client issue &#8211; sql*plus would do the same from a client which could not resolve all of the server specified host names.</p>
<p>Bottom line &#8211; use fully qualified hostnames in RAC installation/DBCA, even when you think you don&#8217;t have to.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2011/05/09/intermittent-ora-12545-with-oracle-rac-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database Resident Connection Pooling</title>
		<link>http://andrewfraserdba.com/2011/04/23/database-resident-connection-pooling/</link>
		<comments>http://andrewfraserdba.com/2011/04/23/database-resident-connection-pooling/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 16:10:49 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[RAC]]></category>
		<category><![CDATA[SQL*Net]]></category>

		<guid isPermaLink="false">http://andrewfraserdba.com/?p=672</guid>
		<description><![CDATA[Database Resident Connection Pooling is new with 11g, and should be used for PHP applications. It will allow them to use the same type of connection pooling that java applications have had for a long time &#8211; largely equalising performance &#8230; <a href="http://andrewfraserdba.com/2011/04/23/database-resident-connection-pooling/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Database Resident Connection Pooling is new with 11g, and should be used for PHP applications.  It will allow them to use the same type of connection pooling that java applications have had for a long time &#8211; largely equalising performance differences with those two programming languages.</p>
<p>It just needs two things done to use it:</p>
<p><strong>1)</strong> In target database:</p>
<pre class="brush:sql">SQL> exec dbms_connection_pool.start_pool</pre>
<p><strong>2) </strong>In client easy connect, add &#8220;:pooled&#8221; at the end of the easy connect string, so it will look like:
<pre class="brush:sql">scott/tiger@myserver/mydb:pooled</pre>
<p>Or if you use client tnsnames.ora , then add &#8220;(server=pooled)&#8221; in the &#8220;connect_data&#8221; part of the &#8220;description&#8221;, so it will look like:
<pre class="brush:bash, shell">MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myserver.my.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = POOLED)
      (SERVICE_NAME = mydb.my.com)
    )
  )</pre>
<p><strong>3)</strong> For PHP to use this, you must be using oci8 v1.3 or above.  That comes bundled with PHP v5.3 and above, or can be downloaded separately from <a href="http://pecl.php.net/package/oci8">http://pecl.php.net/package/oci8</a>.  Use phpinfo(); to see what version you are currently using.</p>
<p>This SQL will let you see if the connection pool is working correctly:</p>
<pre class="brush:sql">col cclass_name form a30
select cclass_name, num_hits, num_misses from gv$cpool_cc_stats ;</pre>
<p>Other useful SQL for this:</p>
<pre class="brush:sql">select * from gv$cpool_stats ;
select * from gv$cpool_cc_stats ;
select program from gv$process where program like 'oracle%(N%)' ;
select * from dba_cpool_info ;</pre>
<p>Oracle Documentation on this is excellent, better than the blog or forum posts I saw:<br />
<a href="http://download.oracle.com/docs/cd/E11882_01/network.112/e10835/tnsnames.htm#i454847">Reference</a><br />
<a href="http://download.oracle.com/docs/cd/E11882_01/network.112/e10836/concepts.htm#NETAG454">Net Services Administrator&#8217;s Guide</a><br />
<a href="http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10646/oci09adv.htm#CHDBIBB">Programmer&#8217;s Guide</a><br />
<a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e17120/manproc004.htm#ADMIN12349">Database Administrator&#8217;s Guide</a><br />
<a href="http://www.oracle.com/technetwork/topics/php/026973.pdf">The Underground PHP and Oracle Manual</a> &#8211; Chapter 14.  But note that this incorrectly states that PHP 5.3 has not yet been released.</p>
<p><strong>For RAC</strong>, load balancing and transparent application failover should also be used. Load balancing is on by default according to the documentation (although I haven&#8217;t tested that), but transparent application failover need to be explicitly specified in tnsnames.ora to be used.</p>
<p>Load balancing would have &#8220;load_balance = on&#8221; in description part of client tnsnames.ora &#8211; supposedly that is on by default.</p>
<p>But Transparent Application Failover is not on by default. To use it, again in client tnsnames.ora, add<br />
&#8220;(failover=on)&#8221; to the description, and &#8220;(failover_mode=(type=select)(method=basic))&#8221; to the connect_data.  Alternatively use &#8220;(type=session)&#8221; for the more minimal type TAF, which will save some overhead on select operations.</p>
<p>The tnsnames.ora entry will end up looking like:</p>
<pre class="brush:bash, shell">MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myserver1.my.com)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = myserver2.my.com)(PORT = 1521))
    (LOAD_BALANCE = on)
    (FAILOVER = on)
    (CONNECT_DATA =
      (SERVER = POOLED)
      (SERVICE_NAME = mydb.my.com)
      (FAILOVER_MODE =
        (TYPE = SELECT)
        (METHOD = BASIC)
        (RETRIES = 5)
        (DELAY = 1)
      )
    )
  )</pre>
<p>Transparent Application Failover is documented in <a href="http://download.oracle.com/docs/cd/E11882_01/network.112/e10836/advcfg.htm#NETAG455">this part of the Net Services Administrator&#8217;s Guide</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2011/04/23/database-resident-connection-pooling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RAC OCFS on 11gR2</title>
		<link>http://andrewfraserdba.com/2010/11/11/rac-ocfs-on-11gr2/</link>
		<comments>http://andrewfraserdba.com/2010/11/11/rac-ocfs-on-11gr2/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 11:53:36 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[RAC]]></category>

		<guid isPermaLink="false">http://andrewfraserdba.com/?p=465</guid>
		<description><![CDATA[http://learnwithme11g.wordpress.com/2010/03/19/11gr2-rac-shared-storage-preparationocfs-part2/ Also very good is http://www.oracledba.org/index.html /etc/init.d/o2cb enable (on both nodes) mkfs.ocfs2 -L "RAC8LUN" /dev/mapper/RAC8LUN1p1 mkfs.ocfs2 -L "RAC8Q" /dev/mapper/RAC8Qp1 vi /etc/fstab mkdir /CRS_DATA mkdir /ORA_DATA mount /dev/mapper/RAC8LUN1p1 mount /dev/mapper/RAC8Qp1 &#160; &#160; &#160; &#160;]]></description>
			<content:encoded><![CDATA[<p><a href="http://learnwithme11g.wordpress.com/2010/03/19/11gr2-rac-shared-storage-preparationocfs-part2/">http://learnwithme11g.wordpress.com/2010/03/19/11gr2-rac-shared-storage-preparationocfs-part2/</a></p>
<p>Also very good is <a href="http://www.oracledba.org/index.html">http://www.oracledba.org/index.html</a></p>
<pre>/etc/init.d/o2cb enable (on both nodes)
mkfs.ocfs2 -L "RAC8LUN" /dev/mapper/RAC8LUN1p1
mkfs.ocfs2 -L "RAC8Q" /dev/mapper/RAC8Qp1
vi /etc/fstab
mkdir /CRS_DATA
mkdir /ORA_DATA
mount /dev/mapper/RAC8LUN1p1
mount /dev/mapper/RAC8Qp1</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2010/11/11/rac-ocfs-on-11gr2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recover RAC database</title>
		<link>http://andrewfraserdba.com/2010/10/29/recover-rac-database/</link>
		<comments>http://andrewfraserdba.com/2010/10/29/recover-rac-database/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 11:21:32 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[RAC]]></category>

		<guid isPermaLink="false">http://andrewfraserdba.com/?p=457</guid>
		<description><![CDATA[RAC has to be switched to non-cluster temporarily for the recovery. startup nomount alter system set cluster_database=false scope=spfile sid='*' ; shutdown immediate startup mount recover database alter database open ; alter system set cluster_database=true scope=spfile sid='*' ; shutdown immediate srvctl &#8230; <a href="http://andrewfraserdba.com/2010/10/29/recover-rac-database/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>RAC has to be switched to non-cluster temporarily for the recovery.</p>
<pre  class="brush:sql">startup nomount
alter system set cluster_database=false scope=spfile sid='*' ;
shutdown immediate
startup mount
recover database
alter database open ;
alter system set cluster_database=true scope=spfile sid='*' ;
shutdown immediate
srvctl start database -d mydb</pre>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2010/10/29/recover-rac-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RAC alter database archivelog</title>
		<link>http://andrewfraserdba.com/2010/10/28/rac-alter-database-archivelog/</link>
		<comments>http://andrewfraserdba.com/2010/10/28/rac-alter-database-archivelog/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 16:22:21 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[RAC]]></category>
		<category><![CDATA[Rman]]></category>

		<guid isPermaLink="false">http://andrewfraserdba.com/?p=447</guid>
		<description><![CDATA[Switch a RAC database into archivelog mode: alter system set log_archive_dest_1='location=/ORA_DISK/redoarch/arch_' scope=both sid='*' ; alter system set cluster_database=false scope=spfile sid='mydb1'; srvctl stop database -d mydb startup mount alter database archivelog ; alter system set cluster_database=true scope=spfile sid='mydb1'; shutdown immediate srvctl &#8230; <a href="http://andrewfraserdba.com/2010/10/28/rac-alter-database-archivelog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Switch a RAC database into archivelog mode:</p>
<pre  class="brush:sql">alter system set log_archive_dest_1='location=/ORA_DISK/redoarch/arch_' scope=both sid='*' ;
alter system set cluster_database=false scope=spfile sid='mydb1';
srvctl stop database -d mydb
startup mount
alter database archivelog ;
alter system set cluster_database=true scope=spfile sid='mydb1';
shutdown immediate
srvctl start database -d mydb</pre>
<p><span id="more-447"></span>And switch it into noarchivelog mode:</p>
<pre  class="brush:sql">alter system reset log_archive_dest_1 scope=spfile sid='*' ;
alter system set cluster_database=false scope=spfile sid='mydb1';
srvctl stop database -d mydb
startup mount
alter database noarchivelog ;
alter system set cluster_database=true scope=spfile sid='mydb1';
shutdown immediate
srvctl start database -d mydb</pre>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2010/10/28/rac-alter-database-archivelog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using 10g datapump and scheduler to copy schemas</title>
		<link>http://andrewfraserdba.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/</link>
		<comments>http://andrewfraserdba.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/#comments</comments>
		<pubDate>Thu, 01 Feb 2007 16:10:25 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[RAC]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/</guid>
		<description><![CDATA[Update 13-Feb-07: Setting the datapump table_exists_action to replace does not overwrite views, sequences, plsql objects. They have to be dropped separately before datapump is called, see gotchas and code below. Update 02-Mar-07: dba_ views rather than all_ views have to &#8230; <a href="http://andrewfraserdba.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong> 13-Feb-07: Setting the datapump table_exists_action to <em>replace</em> does not overwrite views, sequences, plsql objects. They have to be dropped separately before datapump is called, see gotchas and code below.</p>
<p><strong>Update</strong> 02-Mar-07: dba_ views rather than all_ views have to be used to identify what objects to drop prior to datapump, for reasons explained in <a href="http://andrewfraser.wordpress.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/">this post</a>.</p>
<p>For a nightly process to copy small schemas from one database to another, the normal, or old style, way to do that is with export/import in a cron controlled shell script, which would include a sql-from-sql script to drop all the target schema objects before doing the import.</p>
<p>But that presents problems in RAC, which is what I was working on &#8211; which node does the cron script reside on? What happens if that node is down?</p>
<p>An option would be to have the script run on another machine, one unrelated to the RAC cluster, but that introduces more points of failure, and means sending data back and forward over sql*net.</p>
<p>So instead I used the oracle&#8217;s 10g scheduler and datapump, as below. This data pumps straight over a database link, without having to write to a dump file in between, which is nice. And because it is all in the database, it ought to be unaffected by particular RAC nodes being down.</p>
<p><span id="more-19"></span><br />
Some gotchas:</p>
<ul>
<li>The documentation for dbms_datapump isn&#8217;t at all clear on what the syntax for SCHEMA_LISTS&#8217;s should be. It should be this type of format:
<pre class="brush:sql">name => 'SCHEMA_LIST' , value => '''SCHEMA1'',''SCHEMA2'''</pre>
<p>which is a lot of quotes. Thanks to Sunit Joshi for that tip in <a href="http://www.webservertalk.com/message1791234.html">http://www.webservertalk.com/message1791234.html</a></li>
<li>The dbms_datapump documentation has a bug: dbms_datapump.open does not have a parameter called &#8220;<em>mode</em>&#8220;, it has one called &#8220;<em>job_mode</em>&#8221; instead.</li>
<li>When calling dbms_datapump from within a stored procedure, as opposed to an anonymous pl/sql block, the owner of the stored procedure has to have had &#8220;<em>create table</em>&#8221; privilege granted to them explicitly, rather than through a role. That&#8217;s detailed in metalink note 315488.1, but I wasted a lot of time trying to debug that before I went on to metalink. The error reported doesn&#8217;t help much:
<pre class="brush:sql">ERROR at line 1:
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 911
ORA-06512: at "SYS.DBMS_DATAPUMP", line 4330
ORA-06512: at "NIGHTLY_IMPORT", line 4
ORA-06512: at line 1</pre>
</li>
<li>Jobs are created disabled by default with dbms_scheduler, you have to specify &#8220;<code>enabled => TRUE</code>&#8221; to get them to run.</li>
<li><em>new 13-Feb-07</em> Setting table_exists_action to &#8216;replace&#8217; overwrites any existing tables ok, but does <em>not</em> replace view definitions, plsql objects, sequences, and so on. They all have to be explicitly dropped before datapump is called. That is quite a tricky counterintuitive limitation of the table_exists_action replace functionality &#8211; why would you want new tables copied over but old sequences left in place? It is suprises like this that make old fashioned (but well understood) exp/imp still worth using.</li>
<li><em>new 13-Feb-07</em> Be aware that the dropped tables will stay on in the recyclebin. There is a good recyclebin article at <a href="http://orafaq.com/node/968">http://orafaq.com/node/968</a>.</li>
</ul>
<p>Good information on this is at <a href="http://orafaq.com/wiki/Datapump">http://orafaq.com/wiki/Datapump</a> and <a href="http://orafaq.com/node/862">http://orafaq.com/node/862</a>.</p>
<p>Here&#8217;s my code. I included a check against a flag table which allows developers to switch the job on and off:</p>
<pre class="brush:sql">create table run_copy ( run_copy varchar2(3) ) tablespace users ;
grant select, insert, update, delete, references on run_copy to public ;
create public synonym run_copy for run_copy ;
insert into run_copy ( run_copy ) values ( 'Yes' ) ;
create database link nightly_import_sourcedb connect to username identified by password using 'sourcedb' ;
-- procedure owner needs explicit create table
grant create table to username ;

CREATE OR REPLACE PROCEDURE nightly_import AS
  -- Andrew Fraser 30 January 2007
  run_import NUMBER ;
  hand NUMBER ;
BEGIN
  run_import := 0 ;
  SELECT COUNT(*) INTO run_import FROM run_copy WHERE UPPER(run_copy) IN ('N','NO') ;
  IF run_import > 0
  THEN
    -- dont run import if someone has set NO flag in run_copy table
    NULL ;
  ELSE
    -- first have to drop plsql and other objects that table_exists_action does not deal with
    FOR d1 IN ( select object_type, owner, object_name from all_objects
      where object_type in ('FUNCTION','PACKAGE','PROCEDURE','SEQUENCE','SYNONYM','VIEW')
      and owner in ('BACKUP','GATEKEEPER','REFDATA','TRANSDATA','WHSUSR','WHS_VIEWER') )
    LOOP
      execute immediate 'drop '||d1.object_type||' '||d1.owner||'.'||d1.object_name ;
    END LOOP ;
    -- then run datapump import itself
    hand := dbms_datapump.open (
      operation    => 'IMPORT' ,
      job_mode     => 'SCHEMA' ,
      remote_link  => 'nightly_import_sourcedb' ) ;
    dbms_datapump.metadata_filter (
      handle       => hand ,
      name         => 'SCHEMA_LIST' ,
      value        => '''BACKUP'',''GATEKEEPER'',''REFDATA'',''TRANSDATA'',''WHSUSR'',''WHS_VIEWER''' ) ;
    dbms_datapump.set_parameter (
      handle       => hand ,
      name         => 'TABLE_EXISTS_ACTION' ,
      value        => 'REPLACE' ) ;
    dbms_datapump.start_job(hand) ;
  END IF ;
END ;
/

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name           =>  'run_nightly_import' ,
   job_type           =>  'STORED_PROCEDURE' ,
   job_action         =>  'nightly_import' ,
   start_date         =>  TRUNC(sysdate+1)+4/24 , /* start 4am tomorrow */
   repeat_interval    =>  'FREQ=DAILY; INTERVAL=1', /* run every night */
   enabled            =>  TRUE ,
   comments           =>  'Andrew Fraser 30 January 2007');
END;
/</pre>
<p>Even with the code for this method so short, I&#8217;m not sure I would always want to use it over cron and old fashioned export/import. But for RAC, and also for Windows servers (because they lack a decent shell  scripting language), this is the way to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

