<?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>info.michael-simons.eu &#187; Oracle</title>
	<atom:link href="http://info.michael-simons.eu/category/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://info.michael-simons.eu</link>
	<description>Just another nerd blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 10:26:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimizing the Oracle Query Optimizer</title>
		<link>http://info.michael-simons.eu/2010/10/20/optimizing-the-oracle-query-optimizer/</link>
		<comments>http://info.michael-simons.eu/2010/10/20/optimizing-the-oracle-query-optimizer/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 10:38:10 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Hint]]></category>
		<category><![CDATA[Query Optimizer]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=454</guid>
		<description><![CDATA[The Oracle Query Optimizer does a great job in rewriting Queries. For example the nested subquery in SELECT C.cust_last_name, C.country_id FROM customers C WHERE EXISTS &#40;SELECT 1 FROM sales S WHERE S.quantity_sold &#62; 1000 AND S.cust_id = C.cust_id&#41;; will be rewritten into the following query, using a semi-join: SELECT C.cust_last_name, C.country_id FROM customers C, sales [...]]]></description>
			<content:encoded><![CDATA[<p>The Oracle Query Optimizer does a great job in rewriting Queries. For example the nested subquery in</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id 
<span style="color: #993333; font-weight: bold;">FROM</span>    customers C 
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #cc66cc;">1</span> 
                          <span style="color: #993333; font-weight: bold;">FROM</span> sales S 
                          <span style="color: #993333; font-weight: bold;">WHERE</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span> <span style="color: #993333; font-weight: bold;">AND</span> 
                                        S<span style="color: #66cc66;">.</span>cust_id <span style="color: #66cc66;">=</span> C<span style="color: #66cc66;">.</span>cust_id<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>will be rewritten into the following query, using a semi-join:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id 
<span style="color: #993333; font-weight: bold;">FROM</span> customers C<span style="color: #66cc66;">,</span> sales S 
<span style="color: #993333; font-weight: bold;">WHERE</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span> <span style="color: #993333; font-weight: bold;">AND</span> 
C<span style="color: #66cc66;">.</span>cust_id S<span style="color: #66cc66;">=</span> S<span style="color: #66cc66;">.</span>cust_id;</pre></div></div>

<p>(Example from <a href="http://blogs.oracle.com/optimizer/2010/09/optimizer_transformations_subquery_unesting_part_1.html">Optimizer Transformations: Subquery Unnesting part 1</a>)</p>
<p>In the first form, the subquery will be invoked for each entry in customers, replacing the value of the correlated column C.cust_id. Thus the query cannot be parallelized among other implications. Most of the time, if the columns are correctly indexed, the semijoin will be much faster.</p>
<p>This form of rewriting is called &#8220;unnesting&#8221;.</p>
<p>Consider the following 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> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id 
<span style="color: #993333; font-weight: bold;">FROM</span>    customers C<span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> f_compute_some_complicated_value<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>quantity_sold<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> S<span style="color: #66cc66;">.</span>cust_id
                          <span style="color: #993333; font-weight: bold;">FROM</span> sales S                          
                          <span style="color: #993333; font-weight: bold;">WHERE</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span><span style="color: #66cc66;">&#41;</span> S
<span style="color: #993333; font-weight: bold;">WHERE</span>  S<span style="color: #66cc66;">.</span>cust_id <span style="color: #66cc66;">=</span> C<span style="color: #66cc66;">.</span>cust_id</pre></div></div>

<p>The subquery in the from clause its called a derived table. It will be rewritten as:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id<span style="color: #66cc66;">,</span> f_compute_some_complicated_value<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>quantity_sold<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> S<span style="color: #66cc66;">.</span>cust_id
<span style="color: #993333; font-weight: bold;">FROM</span>    customers C<span style="color: #66cc66;">,</span> Sales S
<span style="color: #993333; font-weight: bold;">WHERE</span>  S<span style="color: #66cc66;">.</span>cust_id <span style="color: #66cc66;">=</span> C<span style="color: #66cc66;">.</span>cust_id 
<span style="color: #993333; font-weight: bold;">AND</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This technique is called query merging. Here the join should also be faster in most cases.</p>
<p>Both techniques are good and will improve many queries.</p>
<p>But consider a scenario where the subqueries query remote tables (via database link for example) or call PL/SQL or even Java stored procedures and the main table (customes in the examples) contains many more rows than the joined table or the where clause is less selective then the where clause of the subquery: The subquery will be executed as many times as there are rows in the main table. This can lead to very poor performance.</p>
<p>Luckily, the optimizer can be given hints:</p>
<p>To stop unnesting, use the NO_UNNEST hint:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id 
<span style="color: #993333; font-weight: bold;">FROM</span>    customers C 
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #808080; font-style: italic;">/*+ NO_UNNEST */</span> <span style="color: #cc66cc;">1</span> 
                          <span style="color: #993333; font-weight: bold;">FROM</span> sales S 
                          <span style="color: #993333; font-weight: bold;">WHERE</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span> <span style="color: #993333; font-weight: bold;">AND</span> 
                                        S<span style="color: #66cc66;">.</span>cust_id <span style="color: #66cc66;">=</span> C<span style="color: #66cc66;">.</span>cust_id<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Furthermore, i&#8217;d rewrite the query like so:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id 
<span style="color: #993333; font-weight: bold;">FROM</span>    customers C 
<span style="color: #993333; font-weight: bold;">WHERE</span> C<span style="color: #66cc66;">.</span>cust_id <span style="color: #66cc66;">=</span>ANY <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #808080; font-style: italic;">/*+ NO_UNNEST */</span> S<span style="color: #66cc66;">.</span>cust_id 
                                       <span style="color: #993333; font-weight: bold;">FROM</span> sales S 
                                       <span style="color: #993333; font-weight: bold;">WHERE</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Where the EXISTS clause triggers the subquery for each item in customes, the =ANY clause will trigger the subquery only once. Both queries are semantically identical.</p>
<p>To stop the merging of derived tables, use the NO_MERGE hint in the surrounding select clause:</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: #808080; font-style: italic;">/*+ NO_MERGE(S) */</span> C<span style="color: #66cc66;">.</span>cust_last_name<span style="color: #66cc66;">,</span> C<span style="color: #66cc66;">.</span>country_id 
<span style="color: #993333; font-weight: bold;">FROM</span>    customers C<span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> f_compute_some_complicated_value<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>quantity_sold<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> S<span style="color: #66cc66;">.</span>cust_id
                          <span style="color: #993333; font-weight: bold;">FROM</span> sales S                          
                          <span style="color: #993333; font-weight: bold;">WHERE</span> S<span style="color: #66cc66;">.</span>quantity_sold <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1000</span><span style="color: #66cc66;">&#41;</span> S
<span style="color: #993333; font-weight: bold;">WHERE</span>  S<span style="color: #66cc66;">.</span>cust_id <span style="color: #66cc66;">=</span> C<span style="color: #66cc66;">.</span>cust_id</pre></div></div>

<p>The NO_MERGE hint takes the alias of the derived table as a parameter.</p>
<p>Combining both techniques brought a complex query down from 40s to just about 1s. We are using an Oracle 10g Database, but the hints also apply to 11g.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=454&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_454" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2010/10/20/optimizing-the-oracle-query-optimizer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle &#8220;sleep&#8221; procedure: DBMS_LOCK.SLEEP</title>
		<link>http://info.michael-simons.eu/2010/09/07/oracle-sleep-procedure-dbms_lock-sleep/</link>
		<comments>http://info.michael-simons.eu/2010/09/07/oracle-sleep-procedure-dbms_lock-sleep/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 09:00:01 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[DBMS_LOCK]]></category>
		<category><![CDATA[PL/SQL]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=440</guid>
		<description><![CDATA[There&#8217;s a nice little &#8220;sleep&#8221; procedure in Oracle: A procedure that stops the execution of the current thread for n seconds. Strangely, this method can be called in SQL*Plus like so: EXEC dbms_lock.sleep&#40;10&#41;; but not in another stored procedure or function like so CREATE OR REPLACE PROCEDURE FOOBAR AS BEGIN DBMS_LOCK.SLEEP&#40;1&#41;; END; / To use [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a nice little &#8220;sleep&#8221; procedure in Oracle: A procedure that stops the execution of the current thread for n seconds.</p>
<p>Strangely, this method can be called in SQL*Plus like so:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">EXEC</span> dbms_lock<span style="color: #66cc66;">.</span>sleep<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>but not in another stored procedure or function like so</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> FOOBAR <span style="color: #993333; font-weight: bold;">AS</span>
<span style="color: #993333; font-weight: bold;">BEGIN</span>
  DBMS_LOCK<span style="color: #66cc66;">.</span>SLEEP<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">END</span>;
<span style="color: #66cc66;">/</span></pre></div></div>

<p>To use &#8220;sleep&#8221; in your procedures or functions, login as administrator to your database (or ask you admin to to so) and create the following objects:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> sleep<span style="color: #66cc66;">&#40;</span>seconds <span style="color: #993333; font-weight: bold;">NUMBER</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span>
<span style="color: #993333; font-weight: bold;">BEGIN</span>
  DBMS_LOCK<span style="color: #66cc66;">.</span>SLEEP<span style="color: #66cc66;">&#40;</span>seconds<span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">END</span>;
<span style="color: #66cc66;">/</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> public synonym sleep <span style="color: #993333; font-weight: bold;">FOR</span> sleep;
&nbsp;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">EXECUTE</span> <span style="color: #993333; font-weight: bold;">ON</span> sleep <span style="color: #993333; font-weight: bold;">TO</span> public;</pre></div></div>

<p>and in your procedure just use &#8220;sleep&#8221;.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=440&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_440" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2010/09/07/oracle-sleep-procedure-dbms_lock-sleep/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Oracle NLS-Lang Settings</title>
		<link>http://info.michael-simons.eu/2010/08/13/oracle-nls-lang-settings/</link>
		<comments>http://info.michael-simons.eu/2010/08/13/oracle-nls-lang-settings/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 14:23:38 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Shortcuts]]></category>
		<category><![CDATA[NLS_LANG]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=419</guid>
		<description><![CDATA[To use SQL*Plus Windows correctly, export NLS_LANG like so: set NLS_LANG=GERMAN_GERMANY.WE8MSWIN1252 If you prefer the command line client SQL*Plus, export NLS_LANG like so: set NLS_LANG=GERMAN_GERMANY.WE8PC850 Share This]]></description>
			<content:encoded><![CDATA[<p>To use SQL*Plus Windows correctly, export NLS_LANG like so:</p>
<pre>set NLS_LANG=GERMAN_GERMANY.WE8MSWIN1252</pre>
<p>If you prefer the command line client SQL*Plus, export NLS_LANG like so:</p>
<pre>set NLS_LANG=GERMAN_GERMANY.WE8PC850</pre>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=419&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_419" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2010/08/13/oracle-nls-lang-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle: Drop table if exists replacement</title>
		<link>http://info.michael-simons.eu/2010/02/16/oracle-drop-table-if-exists-replacement/</link>
		<comments>http://info.michael-simons.eu/2010/02/16/oracle-drop-table-if-exists-replacement/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 11:18:32 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=395</guid>
		<description><![CDATA[Mysql has a nice &#8220;if exists&#8221; addition to the drop table statement. If the table to be dropped does not exists, it doesn&#8217;t raise an exception but only creates a warning. In Oracle RDMBS you can emulate this behavior like so: BEGIN EXECUTE immediate 'drop table INSERT_TABLE_NAME_HERE'; EXCEPTION WHEN others THEN IF SQLCODE != -942 [...]]]></description>
			<content:encoded><![CDATA[<p>Mysql has a nice &#8220;if exists&#8221; addition to the drop table statement. If the table to be dropped does not exists, it doesn&#8217;t raise an exception but only creates a warning.</p>
<p>In Oracle RDMBS you can emulate this behavior like so:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">BEGIN</span> <span style="color: #993333; font-weight: bold;">EXECUTE</span> immediate <span style="color: #ff0000;">'drop table INSERT_TABLE_NAME_HERE'</span>; EXCEPTION <span style="color: #993333; font-weight: bold;">WHEN</span> others <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #993333; font-weight: bold;">IF</span> SQLCODE !<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">942</span> <span style="color: #993333; font-weight: bold;">THEN</span> RAISE; <span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">IF</span>; <span style="color: #993333; font-weight: bold;">END</span>;
<span style="color: #66cc66;">/</span></pre></div></div>

<p>Ugly, but it works very well.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=395&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_395" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2010/02/16/oracle-drop-table-if-exists-replacement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Different day, same shit, today: Java 5 on Oracle Enterprise Linux 5</title>
		<link>http://info.michael-simons.eu/2009/01/19/different-day-same-shit-today-java-5-on-oracle-enterprise-linux-5/</link>
		<comments>http://info.michael-simons.eu/2009/01/19/different-day-same-shit-today-java-5-on-oracle-enterprise-linux-5/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 12:00:17 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[OEL5]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=255</guid>
		<description><![CDATA[Worlds collide: Oracle and Sun JDK. Perfect start to ruin a not so bad Monday morning. Background: Need to have a Tomcat Server deployed on a Oracle Enterprise Linux 5 system. I was happy, when i saw a tomcat5 package in the repositories. Great, i thought. All i need. Well. Not. Under Windows you&#8217;ll get [...]]]></description>
			<content:encoded><![CDATA[<p>Worlds collide: Oracle and Sun JDK. Perfect start to ruin a not so bad Monday morning.</p>
<p>Background: Need to have a <a href="http://tomcat.apache.org/">Tomcat Server</a> deployed on a <a href="http://www.oracle.com/technologies/linux/index.html">Oracle Enterprise Linux 5</a> system.</p>
<p>I was happy, when i saw a tomcat5 package in the repositories. Great, i thought. All i need. Well. Not.</p>
<p>Under Windows you&#8217;ll get between one and ten JVM versions installed with on Oracle product (slight exaggerated), within the OEL5 there was only one ancient 1.4.2 JDK. *sigh* Did i mention that  the application that is supposed to run on that thing uses a buttload of Java 5 features?</p>
<p>&#8220;yum search java-&#8221;&#8230; No Java 5. WtF? </p>
<p>There is no Java 5.</p>
<p>Again, do it yourself:</p>
<p><a href="http://wiki.centos.org/HowTos/JavaOnCentOS">This is a nice entry</a> that describes howto build rpms for the &#8220;official&#8221; Sun Java 5 jdk.</p>
<p>I used the following steps to build my rpms:</p>
<ul>
<li>Downloaded this <a href="http://mirrors.dotsrc.org/jpackage/1.7/generic/SRPMS.non-free/java-1.5.0-sun-1.5.0.15-1jpp.nosrc.rpm">rpm</a></li>
<li>Downloaded <em>jdk-1_5_0_15-linux-i586.bin</em> from the <a href="http://java.sun.com/products/archive/">Sun JDK archive page</a></li>
<li>Put the later one into <em>/usr/src/redhat/SOURCES/</em></li>
<li>Built the rpms with <em>rpmbuild &#8211;rebuild java-1.5.0-sun-1.5.0.15-1jpp.nosrc.rpm</em>. If rpmbuild is not installed, it&#8217;s hidden in the package <em>rpm-build</em>, not rpmbuild.</li>
<li>Installed missing libXp</li>
<li>Installed the rpms:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-devel-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-src-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-demo-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-plugin-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-fonts-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-alsa-1.5.0.15-1jpp.i586.rpm
rpm <span style="color: #660033;">-Uvh</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>RPMS<span style="color: #000000; font-weight: bold;">/</span>i586<span style="color: #000000; font-weight: bold;">/</span>java-1.5.0-sun-jdbc-1.5.0.15-1jpp.i586.rpm</pre></div></div>

</li>
<li>Last step: Choose the right java version with <em>alternatives &#8211;config java</em></li>
</ul>
<p>After that, everything could be fine. Well, it wasn&#8217;t:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">sun.misc.InvalidJarIndexException: Invalid index</pre></div></div>

<p>Jehova! Finally not a NPE but something new, at least to me. Sometimes i wonder why i always run into bugs like <a href="http://forums.fedoraforum.org/showthread.php?p=802366">these</a>.</p>
<p>Some script changes and repackages all jar files in some weird ways so that a standard JDK has funny problems. </p>
<p>My solution to it: Reindex everything in <em>/usr/share/java</em> after you&#8217;ve chosen your newly installed java with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;jakarta*commons*.jar&quot;</span> <span style="color: #660033;">-exec</span> jar <span style="color: #660033;">-i</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

<p>I opted to reindex only the jakarta commons files, that got Tomcat up and running with Java 5.</p>
<p>One last note: The <em>/usr/bin/dtomcat5</em> is broken imho, at least when run from /etc/init.d/tomcat5. In ignores <em>/etc/tomcat5/tomcat5.conf</em> and therefore cannot stop Tomcat.</p>
<p>My solution: Replace</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CATALINA_HOME</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">TOMCAT_CFG</span>=<span style="color: #ff0000;">&quot;/etc/tomcat5/tomcat5.conf&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>(in line 55 on my setup) with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CATALINA_HOME</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">TOMCAT_CFG</span>=<span style="color: #ff0000;">&quot;/etc/tomcat5/tomcat5.conf&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TOMCAT_CFG</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> . <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TOMCAT_CFG}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>and remove</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CATALINA_HOME</span>&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;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TOMCAT_CFG</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> . <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TOMCAT_CFG}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>(in line 105 on my setup).</p>
<p>I wonder why simple things like these always are a pain in the ass. Stupid nuisances that keeps people from getting their work done. *sigh* Not a good start for the week.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=255&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_255" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2009/01/19/different-day-same-shit-today-java-5-on-oracle-enterprise-linux-5/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>RFC3339 revisited</title>
		<link>http://info.michael-simons.eu/2008/11/13/rfc3339-revisited/</link>
		<comments>http://info.michael-simons.eu/2008/11/13/rfc3339-revisited/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 10:24:53 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=230</guid>
		<description><![CDATA[Not just for ruby but also the corresponding formats for Java public static final SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat&#40;&#34;yyyy-MM-dd'T'HH:mm:ssZ&#34;&#41;; and for Oracle SELECT to_timestamp_tz&#40;'1979-21-09T06:54:00+01:00','YYYY-MM-DD&#34;T&#34;HH24:MI:SSTZH:TZM'&#41; FROM dual / Oracle Share This]]></description>
			<content:encoded><![CDATA[<p>Not just for <a href="http://info.michael-simons.eu/2008/11/01/ruby-formatting-time-values-as-rfc3339/">ruby</a> but also the corresponding formats for </p>
<p><strong>Java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">SimpleDateFormat</span> RFC3339_FORMAT <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SimpleDateFormat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yyyy-MM-dd'T'HH:mm:ssZ&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and for <strong>Oracle</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> to_timestamp_tz<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'1979-21-09T06:54:00+01:00'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'YYYY-MM-DD&quot;T&quot;HH24:MI:SSTZH:TZM'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span> dual
<span style="color: #66cc66;">/</span></pre></div></div>

<p><strong>Oracle</strong></p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=230&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_230" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/11/13/rfc3339-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with sql</title>
		<link>http://info.michael-simons.eu/2008/10/27/fun-with-sql/</link>
		<comments>http://info.michael-simons.eu/2008/10/27/fun-with-sql/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 08:47:30 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=221</guid>
		<description><![CDATA[What&#8217;s all the fuss about this SQL Injection thing? It boils down getting some malicious crafted SQL code into the SQL code of an application, destroying data or authenticate yourself without knowing any real password. xkdc has a nice explanation. The simple cases base on wrong escaped strings and the like. But as this SQL [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s all the fuss about this <a href="http://en.wikipedia.org/wiki/SQL_injection">SQL Injection thing</a>?</p>
<p>It boils down getting some malicious crafted SQL code into the SQL code of an application, destroying data or authenticate yourself without knowing any real password. xkdc has a nice <a href="http://xkcd.com/327/">explanation</a>.</p>
<p>The simple cases base on wrong escaped strings and the like. But as this <a href="http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/">SQL injection cheatsheet</a> shows there are an infinity number of possibilities. </p>
<p>At day most of the time my database connection is an Oracle connection and so i found this Oracle whitepaper titled <a href="http://www.oracle.com/technology/tech/pl_sql/pdf/how_to_write_injection_proof_plsql.pdf"><em>How to write injection-proof PL/SQL</em></a> very interesting (via <a href="http://www.schneier.com/blog/archives/2008/10/how_to_write_in.html">Bruce Schneier</a> found at the <a href="http://the-gay-bar.com/index.php?/archives/203-Dumb-security-tips-Think-before-you-follow-online-guides/">gay bar</a>).</p>
<p>I do not have a magic recipe for avoiding attack vectors all the time but as well as the whitepaper is written, it&#8217;s not a solution to expose all queries only via pl/sql to clients. In fact, it&#8217;s a nightmare to get this to work with JPA and other ORM mappers.</p>
<p>I try not to use dynamic sql in the sense of &#8220;concatenate some strings with one another and mysql_real_escape_string or DBMS_Assert. them&#8221; but use prepared statements with placeholders and explicit datatypes. Also if there&#8217;s a need for computing sql queries at runtime, do not ever let user supplied input come near them. I know that i&#8217;m relying to my api in this case but there is always a point on which i must rely on i guess. </p>
<p>As alway, the most important thing is: Be conscious about what you are doing and try to understand that, but at this point, i leave the discussion about software development and enter the depths of common sense…</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=221&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_221" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/10/27/fun-with-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle XE environment variables on Linux</title>
		<link>http://info.michael-simons.eu/2008/06/04/oracle-xe-environment-variables-on-linux/</link>
		<comments>http://info.michael-simons.eu/2008/06/04/oracle-xe-environment-variables-on-linux/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 08:43:20 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Shortcuts]]></category>
		<category><![CDATA[Oracle DB]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=172</guid>
		<description><![CDATA[Just a quick reminder for myself: With the default installation of an Oracle Express (Oracle XE) comes two shell script with all the necessary environment variables to use sql*plus, exp, imp and the like on the command line: source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh respectively source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.csh Share This]]></description>
			<content:encoded><![CDATA[<p>Just a quick reminder for myself:</p>
<p>With the default installation of an Oracle Express (<a href="http://www.oracle.com/technology/products/database/xe/index.html">Oracle XE</a>) comes two shell script with all the necessary environment variables to use sql*plus, exp, imp and the like on the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>xe<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>server<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>oracle_env.sh</pre></div></div>

<p>respectively</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>xe<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>server<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>oracle_env.csh</pre></div></div>

<p class="akst_link"><a href="http://info.michael-simons.eu/?p=172&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_172" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/06/04/oracle-xe-environment-variables-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feeling dizzy&#8230;</title>
		<link>http://info.michael-simons.eu/2008/03/26/feeling-dizzy/</link>
		<comments>http://info.michael-simons.eu/2008/03/26/feeling-dizzy/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 10:45:38 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DB]]></category>
		<category><![CDATA[Oracle Spatial]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/2008/03/26/feeling-dizzy/</guid>
		<description><![CDATA[After staring at this for about a day in various rotations and flips just to get Oracle GeoRaster work together with a homebrew GIS like application made me feel somewhat dizzy. To be cartesian or not cartesian, that is the question Otherwise, Oracle GeoRaster works quite well, at least for that bunch of german TK25 [...]]]></description>
			<content:encoded><![CDATA[<p>After staring at this</p>
<div style="text-align:center;">
<img src="/wp-content/uploads/2008/03/dummy.jpg" alt="dummy" />
</div>
<p>for about a day in various rotations and flips just to get <a href="http://www.oracle.com/technology/sample_code/products/spatial/htdocs/georaster.html">Oracle GeoRaster</a> work together with a homebrew GIS like application made me feel somewhat dizzy. To be cartesian or not cartesian, that is the question <img src='http://info.michael-simons.eu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Otherwise, Oracle GeoRaster works quite well, at least for that bunch of german TK25 maps in GK3 coordinates that used to float around in the filesystem and are now being stored in the database.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=154&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_154" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/03/26/feeling-dizzy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtualization with load-balancing and hot-failover: Done.</title>
		<link>http://info.michael-simons.eu/2008/02/19/virtualization-with-load-balancing-and-hot-failover-done/</link>
		<comments>http://info.michael-simons.eu/2008/02/19/virtualization-with-load-balancing-and-hot-failover-done/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 19:28:08 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Oracle VM]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/2008/02/19/virtualization-with-load-balancing-and-hot-failover-done/</guid>
		<description><![CDATA[This is really going the last post of my series on Oracle VM Server / VM Manager on inexpensive hardware. Last week a second Dell Power Edge arrived, followed by a little NAS/iSCSI System, the ES-2100 from Eurostor, which is rebranded Thecus N5200 Pro. I do link Eurostor because i made some very nice contact [...]]]></description>
			<content:encoded><![CDATA[<p>This is really going the last post of my series on Oracle VM Server / VM Manager on inexpensive hardware.</p>
<p>Last week a second Dell Power Edge arrived, followed by a little NAS/iSCSI System, the <a href="http://www.eurostor.com/german/ES2100T.D.php">ES-2100</a> from <a href="http://www.eurostor.com">Eurostor</a>, which is rebranded <a href="http://www.thecus.com/products_over.php?cid=11&#038;pid=8">Thecus N5200 Pro</a>. I do link  Eurostor because i made some very nice contact with their tech support.</p>
<p>After running the Oracle VM Server on a 2.4 GHz Core 2 Duo Xeon with 4 Gb Ram for about 70 days non-stop, we decided to do the next step: Incarnating a second server with a shared storage.</p>
<p>The one server runs an paravirtualized OEL5 with 2 GB Ram which itself runs an Oracle 11g test instance with medium load, a hardware virtualized Windows XP with 512 MB Ram that runs a Jetty with a few services and since 2 weeks a hvm Debian that serves as a mailrelay for that Exchange of ours&#8230; Which has a now really less load as SpamAssasin takes care of all.</p>
<p>Setting up the second Dell was flawless, nothing new.</p>
<p>The iSCSI was another thing&#8230; First i deleted the RAID6 as we decided to go for RAID5. Stupid me set disk usage to 100%, went for the weekend, came back on monday and saw: Wow, no space for the iSCSI target. Damn it, all timeplans went bazoo&#8230; So deleting the RAID once again and back to start, this time with 20% for Disk Usage (you never know) and 80% for one iSCSI target (if this was my machine, i really had a purpose for 1.5TB storage&#8230; but here.. *sigh*).</p>
<p>So, another 8 hours later, i bought a cheap 8 port Gigabit switch, set up the ES-2100 for link aggregation and connected it to both Oracle VM Servers.</p>
<p>I roughly followed the steps described <a href="http://download.oracle.com/docs/cd/E11081_01/doc/doc.21/e10898/migration.htm#CHDJGGFF">here</a>, but as i changed some steps, let me describe them:</p>
<ul>
<li>Installed the iscsi tools with:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-Uvh</span> iscsi-initiator-utils-6.2.0.742-<span style="color: #000000;">0.5</span>.el5.i386.rpm</pre></div></div>

</li>
<li>Discovering and removing unused services like that:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iscsiadm <span style="color: #660033;">-m</span> discovery <span style="color: #660033;">-t</span> sendtargets <span style="color: #660033;">-p</span> 139.185.48.249</pre></div></div>

<p>Example of removing a node:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iscsiadm <span style="color: #660033;">-m</span> node <span style="color: #660033;">-p</span> 10.2.0.250:<span style="color: #000000;">3260</span>,<span style="color: #000000;">3</span> <span style="color: #660033;">-T</span> iqn.1992-04.com.emc:cx.apm00070202838.b0 <span style="color: #660033;">-o</span> delete</pre></div></div>

<p>Listing the remaining:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iscsiadm <span style="color: #660033;">-m</span> node</pre></div></div>

<p>and having a new partition under /proc/partitions after</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">service iscsi restart</pre></div></div>

</li>
</ul>
<p>The ocfs2 cluster configuration is as simple as described in the linked Oracle document. I recommend adding names and ipaddresses corresponding to the one in /etc /ocfs2/cluster.conf to /etc /hosts, as the o2cb services won&#8217;t start otherwise. One thing Oracle forgot to mention is to open port 7777 on both machines in the iptables configuration.</p>
<p>At first i made the mistake to mkfs.ocfs2 the device and forgot to create a partition. This worked for whatever reason, but i destroyed the filesystem and created a partition with fdisk (new partition, primary, the whole thing).</p>
<p>Next, i didn&#8217;t follow Oracle but decided the following:</p>
<ul>
<li>Unmount the /OVS on the first server (the one with all the vms)</li>
<li>Adding the following stanza to /etc /fstab:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1               <span style="color: #000000; font-weight: bold;">/</span>OVS ocfs2   defaults        <span style="color: #000000;">1</span> <span style="color: #000000;">0</span></pre></div></div>

</li>
<li>mount -a</li>
<li>Mount the old /OVS to somewhere else and rsychned it to the new location. I reached transferrates around 20MB/s with concurrent writes from the other server. Not but for a inexpensive device like that little iscsi thingy.</li>
<li>Added the the new server to the pool.</li>
<li>Rebooted both servers, just to be sure that they come back healty.</li>
<li>Restarted all vms, which worked greated over the iscsi.</li>
<li>Tested load-balancing and live migration and what can i say: Wow, it works. Fast and flawless. Great thing.</li>
</ul>
<p>So in the end we have a safe setup with hardware costs under 5k € and a setup time from about 6 or 7 days which brought some good knowledge and know-how. I think we wouldn&#8217;t have achivied this based on a VMWare solution brought by external consultants. Maybe that would have ended like the last Dilbert in that <a href="http://info.michael-simons.eu/2008/02/14/dilbert-does-virtualization-too/">series</a> <img src='http://info.michael-simons.eu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>To bring some variety to this blog, here&#8217;s a picture of the current setup:</p>
<div style="text-align:center;">
<img src="/wp-content/uploads/2008/02/DSC00195.JPG" alt="our virtualization setup" />
</div>
<p>I one of the google visitors or the 2 readers have any questions, feel free to ask <img src='http://info.michael-simons.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>See the other posts here: <a href="http://info.michael-simons.eu/2007/11/28/positive-erlebnisse/">1</a>, <a href="http://info.michael-simons.eu/2007/12/11/negative-erlebnisse/">2</a>, <a href="http://info.michael-simons.eu/2007/12/12/installing-oracle-vm-server/">3</a>, <a href="http://info.michael-simons.eu/2007/12/12/installing-oracle-enterprise-linux-5-as-a-vm-in-oracle-vm-server/">4</a>, <a href="http://info.michael-simons.eu/2007/12/12/installing-oracle-11g-database-on-oel5/">5</a>. </p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=150&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_150" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/02/19/virtualization-with-load-balancing-and-hot-failover-done/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.767 seconds -->

