<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>die Seilerwerks</title>
	<atom:link href="http://seilerwerks.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://seilerwerks.wordpress.com</link>
	<description>Chronicling Life, Love, Linux and Oracle database administration.</description>
	<lastBuildDate>Thu, 08 Dec 2011 07:37:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='seilerwerks.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>die Seilerwerks</title>
		<link>http://seilerwerks.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://seilerwerks.wordpress.com/osd.xml" title="die Seilerwerks" />
	<atom:link rel='hub' href='http://seilerwerks.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Moving [Back] to Blogger</title>
		<link>http://seilerwerks.wordpress.com/2010/11/20/moving-back-to-blogger/</link>
		<comments>http://seilerwerks.wordpress.com/2010/11/20/moving-back-to-blogger/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 06:22:12 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=498</guid>
		<description><![CDATA[Hello folks. Just a note to let you know that, on the heels of Google&#8217;s recent Google Apps integrations, I&#8217;ve decided to go back to blogger and make my life a bit simpler. die Seilerwerks will now be found at http://www.seiler.us.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=498&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello folks. Just a note to let you know that, on the heels of Google&#8217;s recent Google Apps integrations, I&#8217;ve decided to go back to blogger and make my life a bit simpler.</p>
<p><a href="http://www.seiler.us">die Seilerwerks</a> will now be found at <a href="http://www.seiler.us">http://www.seiler.us</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/498/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/498/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/498/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/498/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/498/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/498/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/498/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/498/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=498&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2010/11/20/moving-back-to-blogger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Beware the /var/tmp/.oracle Hidden Directory!</title>
		<link>http://seilerwerks.wordpress.com/2010/11/12/beware-the-vartmp-oracle-hidden-directory/</link>
		<comments>http://seilerwerks.wordpress.com/2010/11/12/beware-the-vartmp-oracle-hidden-directory/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 20:29:38 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=488</guid>
		<description><![CDATA[NOTE: This post originally appeared on the Pythian blog. A few months ago, we had a test instance complaining that it couldn&#8217;t write to ASM. This was an 11.1.0.7 single (non-RAC) instance on Oracle Enterprise Linux 5, using ASM for the storage. We first saw these errors in the alert log: ORA-15032: not all alterations [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=488&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>NOTE: This post originally appeared on <a href="http://www.pythian.com/news/13939/beware-the-vartmp-oracle-hidden-directory/">the Pythian blog</a>.</em></p>
<p>A few months ago, we had a test instance complaining that it couldn&#8217;t write to ASM. This was an 11.1.0.7 single (non-RAC) instance on Oracle Enterprise Linux 5, using ASM for the storage. We first saw these errors in the alert log:</p>
<pre>ORA-15032: not all alterations performed
ORA-29702: error occurred in Cluster Group Service operation
ORA-29702: error occurred in Cluster Group Service operation
ERROR: error ORA-15032 caught in ASM I/O path
</pre>
<p>Uh-oh, that doesn&#8217;t look good. So I log into the ASM instance and try to see if the disks are OK:</p>
<pre>SQL&gt; select path, mount_status from v$asm_disk;
select path, mount_status from v$asm_disk
                               *
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-29702: error occurred in Cluster Group Service operation
ORA-29702: error occurred in Cluster Group Service operation
</pre>
<p><span id="more-488"></span><br />
I can&#8217;t even query that. As <a href="http://www.youtube.com/watch?v=1DsFMJQHbMs">Ted would say</a>, &#8220;strange things are afoot at the Circle K.&#8221; To be safe, I thought I&#8217;d try to shutdown the DBMS instance, which also failed without having to abort:</p>
<pre>SQL&gt; shutdown immediate
ORA-00204: error in reading (block 1, # blocks 1) of control file
ORA-00202: control file: '+FOOTEST_DATA/footest1_footest_db/control01.ctl'
ORA-15081: failed to submit an I/O operation to a disk
SQL&gt; shutdown abort
ORACLE instance shut down.
</pre>
<p>We decided to restart the whole DBMS/ASM/CSS stack, but CSS wouldn&#8217;t stop either:</p>
<pre>-bash-3.2# /etc/init.d/init.cssd stop
Stopping Cluster Synchronization Services.
Unable to communicate with the Cluster Synchronization Services daemon.
Shutdown has begun. The daemons should exit soon.
</pre>
<p>We ended up booting the server altogether, after which everything came up nicely. We filed an SR with Oracle Support, who directed us to Note 391790.1 (Unable To Connect To Cluster Manager Ora-29701). This note lists the cause, quite simply, as:</p>
<blockquote><p>The hidden directory &#8216;/var/tmp/.oracle&#8217; was removed while instances &amp; the CRS stack were up and running. Typically this directory contains a number of &#8220;special&#8221; socket files that are used by local clients to connect via the IPC protocol (sqlnet) to various Oracle processes including the TNS listener, the CSS, CRS &amp; EVM daemons or even database or ASM instances. These files are created when the &#8220;listening&#8221; process starts.</p></blockquote>
<p>The solution is to restart CRS or reboot the machine. Our /var/tmp/.oracle directory looked like this:</p>
<pre>[oracle@footest ~]$ ls -la /var/tmp/.oracle
total 12
drwxrwxrwt 2 root   root 4096 May  8 15:03 .
drwxrwxrwt 3 root   root 4096 May 10 07:02 ..
srwxrwxrwx 1 oracle dba     0 May  8 15:03 s#18854.1
srwxrwxrwx 1 oracle dba     0 May  8 15:03 s#18854.2
srwxrwxrwx 1 oracle dba     0 May  8 15:03 sEXTPROC
srwxrwxrwx 1 oracle dba     0 May  8 14:44 sfootestDBG_CSSD
srwxrwxrwx 1 oracle dba     0 May  8 14:44 sOCSSD_LL_footest_
srwxrwxrwx 1 oracle dba     0 May  8 14:44 sOCSSD_LL_footest_localhost
srwxrwxrwx 1 oracle dba     0 May  8 14:44 sOracle_CSS_LclLstnr_localhost_0
srwxrwxrwx 1 oracle dba     0 May  8 15:03 sPNPKEY
</pre>
<p>I did some sandbox testing, and found that only the Oracle and root OS users could delete that directory, and was able to duplicate the error every time when doing so.</p>
<p>However, I really was dumbstruck that Oracle would have so critical a directory in /var/tmp! I politely note this to Oracle Support, who justified this location with a few <strong>solid</strong> reasons:</p>
<ol>
<li>It has always been in this location (and still is in 11gR2).</li>
<li>/var/tmp/.oracle is a hidden directory, so it probably won&#8217;t be noticed by any miscreants looking to cause trouble.</li>
</ol>
<p>OK, I was being sarcastic, these reasons are awful. The only safeguard they gave was &#8220;make sure no one deletes it.&#8221; We scoured the server for cron jobs that would automatically clean out /var/tmp but didn&#8217;t find any, nor any bash history suggesting malice. The only thing that we could think of was that this test server was in a VM (Citrix Xen), although one would hope that it doesn&#8217;t happen at all, regardless. We certainly could not find an explanation, but now we&#8217;re aware to not delete /var/tmp/.oracle while the instances are running (even though we never did before).</p>
<p>Surachart Opun has also <a href="http://surachartopun.com/2009/01/vartmporacle-hidden-directory.html">blogged on this topic</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/488/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=488&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2010/11/12/beware-the-vartmp-oracle-hidden-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing Oracle 11gR2 Enterprise Edition on Ubuntu 10.04 (Lucid Lynx)</title>
		<link>http://seilerwerks.wordpress.com/2010/06/30/installing-oracle-11gr2-enterprise-edition-on-ubuntu-10-04-lucid-lynx/</link>
		<comments>http://seilerwerks.wordpress.com/2010/06/30/installing-oracle-11gr2-enterprise-edition-on-ubuntu-10-04-lucid-lynx/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 20:37:29 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=474</guid>
		<description><![CDATA[Note: This post originally appeared on The Pythian Group blog. I recently reformatted my laptop with the latest Ubuntu LTS release, 10.04, aka Lucid Lynx. Since I like to have a native client installation as well as a portable sandbox server, I decided to install the latest version of Oracle EE, 11.2.0.1. Rather than re-invent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=474&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Note: This post originally appeared on <a href="http://www.pythian.com/news/13291/installing-oracle-11gr2-enterprise-edition-on-ubuntu-10-04-lucid-lynx/">The Pythian Group blog</a>.</em></p>
<p>I recently reformatted my laptop with the latest <a href="http://www.ubuntu.com/">Ubuntu</a> LTS release, 10.04, aka <a href="https://wiki.ubuntu.com/LucidLynx">Lucid Lynx</a>. Since I like to have a native client installation as well as a portable sandbox server, I decided to install the latest version of Oracle EE, 11.2.0.1.</p>
<p>Rather than re-invent the wheel, I&#8217;m going to direct you to<a href="http://www.pythian.com/news/2329/installing-oracle-11gr1-on-ubuntu-904-jaunty-jackalope/"> the previous Oracle-on-Ubuntu post</a> by my colleague Augusto Bott.  Many of the directions there hold true here (even with 32-bit vs 64-bit), with a few exceptions.<br />
<span id="more-474"></span><br />
<strong>Download the Software</strong><br />
First and foremost, download the 32-or-64-bit installer files (there are 2 of them) <a href="http://www.oracle.com/technology/software/products/database/index.html">from OTN</a>.</p>
<p><strong>Installing Pre-requisite Packages</strong><br />
Install these software packages on your Ubuntu 10.04 system:<br />
<pre class="brush: plain;">
$ sudo apt-get install unzip build-essential x11-utils rpm ksh lsb-rpm libaio1
</pre></p>
<p>Ubuntu 10.04 comes with libstdc++6 installed. However, Oracle 11gR2 requires libstdc++5. If you do not install libstdc++5, you will see <a href="http://forums.oracle.com/forums/thread.jspa?threadID=1077139&amp;tstart=0">errors as described in this OTN thread</a>. The fix, as described in that thread, is to download and manually shoehorn the libstdc++5 library files onto Ubuntu 10.04:<br />
<pre class="brush: plain;">
$ wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3.6-17ubuntu1_amd64.deb
$ dpkg-deb -x libstdc++5_3.3.6-17ubuntu1_amd64.deb ia64-libs
$ sudo cp ia64-libs/usr/lib/libstdc++.so.5.0.7 /usr/lib64/
$ cd /usr/lib64/
$ sudo ln -s libstdc++.so.5.0.7 libstdc++.so.5

$ wget http://security.ubuntu.com/ubuntu/pool/universe/i/ia32-libs/ia32-libs_2.7ubuntu6.1_amd64.deb
$ dpkg-deb -x ia32-libs_2.7ubuntu6.1_amd64.deb ia32-libs
$ sudo cp ia32-libs/usr/lib32/libstdc++.so.5.0.7 /usr/lib32/
$ cd /usr/lib32
$ sudo ln -s libstdc++.so.5.0.7 libstdc++.so.5
</pre></p>
<p>Now we&#8217;re ready to move on.</p>
<p><strong>Create User and Groups</strong><br />
First create the oinstall and dba groups:<br />
<pre class="brush: plain;">
$ sudo su -
# addgroup oinstall
# addgroup dba
</pre></p>
<p>Then create the oracle user and assign it to those groups:<br />
<pre class="brush: plain;">
# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
# mkdir /home/oracle
# chown -R oracle:dba /home/oracle
</pre></p>
<p>Now we create some symbolic links to give the Ubuntu system a more &#8220;Red Hat-ish layout,&#8221; as Augusto put it:<br />
<pre class="brush: plain;">
# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /usr/bin/basename /bin/basename
# mkdir /etc/rc.d
# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
# mkdir -p /u01/app/oracle
# chown -R oracle:dba /u01
</pre></p>
<p>Then we update some sysctl parameters by editing /etc/sysctl.conf. It is wisest to backup this file first and then add these lines to the end of /etc/sysctl.conf:<br />
<pre class="brush: plain;">
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 1048576
net.core.wmem_max = 1048576
net.ipv4.ip_local_port_range = 9000 65535
</pre><br />
Note that these values are different from what was needed in 11gR1.</p>
<p>Now we update some limits for the oracle software owner by adding these lines to the end of /etc/security/limits.conf:<br />
<pre class="brush: plain;">
oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
</pre><br />
Again, it is best to backup the file first.</p>
<p>Now we activate the new settings from /etc/sysctl.conf with this command:<br />
<pre class="brush: plain;">
# sysctl -p
</pre><br />
You should see the new settings in the output of that command.</p>
<p><strong>Unpack and Install the Software</strong><br />
From here we go into the directory containing our two 11gR2 database zip files. I&#8217;m using the 64-bit edition, so my files are named linux.x64_11gR2_databaseXof2.zip, where X is 1 or 2. I unzip both of these files, which creates a &#8220;database&#8221; subdirectory:<br />
<pre class="brush: plain;">
$ unzip linux.x64_11gR2_database_1of2.zip
$ unzip linux.x64_11gR2_database_2of2.zip
</pre><br />
Each of these commands will produce a large volume of output to the terminal as it lists each file being unpacked.  Once this is done, your directory should look something like this:<br />
<pre class="brush: plain;">
$ ls -lh
total 2.2G
drwxr-xr-x 8 seiler seiler 4.0K 2009-08-20 14:34 database
-rw-r--r-- 1 seiler seiler 1.2G 2010-03-09 11:33 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 seiler seiler 1.1G 2010-03-09 12:38 linux.x64_11gR2_database_2of2.zip
</pre></p>
<p>Now you simply cd into the database directory and run the runInstaller program:<br />
<pre class="brush: plain;">
$ cd database
$ ./runInstaller
</pre></p>
<p>This will launch the Oracle Universal Installer, or OUI, program. The rest is pretty straight forward. Since this is just a sandbox, I chose not to provide any email info and declined to receive updates. I chose to first install the software only, which went perfectly well. OUI will complain about missing packages, since it is checking for RPMs. We can safely ignore these and proceed with installation.</p>
<p>Once installation is done I set these variables in my bash environment:<br />
<pre class="brush: plain;">
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export EDITOR=/usr/bin/vi
</pre></p>
<p>Then some quick tests to verify installation:<br />
<pre class="brush: plain;">
$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 10 23:46:42 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL&gt; quit
$ /u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch lsinventory
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.1.0.6.6
OUI version       : 11.2.0.1.0
OUI location      : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2010-06-10_23-46-53PM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2010-06-10_23-46-53PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1): 

Oracle Database 11g                                                  11.2.0.1.0
There are 1 products installed in this Oracle Home.


There are no Interim patches installed in this Oracle Home.


--------------------------------------------------------------------------------

OPatch succeeded.
</pre><br />
Everything looks <a href="http://www.last.fm/music/David+Bowie/Hunky+Dory">hunky-dory</a>. Let&#8217;s create an instance.</p>
<p>I launched dbca to create an Oracle 11gR2 instance. The one problem I encountered here was that, at the end of dbca prompts, the &#8220;Confirmation&#8221; dialog window was blank. Other blog posts on the internet suggested blindly clicking around until you magically hit the &#8220;OK&#8221; button, but more often than not I would hit the &#8220;Cancel&#8221; button. Turns out this is a not-so-uncommon <a href="http://www.google.ca/search?sourceid=chrome&amp;ie=UTF-8&amp;q=gnome+visual+effects+java+swing">problem with Java Swing and Gnome&#8217;s visual effects</a>. The solution for Gnome users is to disable Visual Effects in the Appearance preferences before launching dbca. If you are using a lightweight desktop environment such as <a href="http://lxde.org/">LXDE</a>, you shouldn&#8217;t have this problem.</p>
<p>And that&#8217;s that. The rest is nothing new to those who have done installations before. You can optionally configure TNS names or Listener with the netca tool, or log into your new instance and enjoy.</p>
<p>Special thanks to Augusto Bott for not only authoring the previous Oracle-on-Ubuntu articles but also for suggesting the Gnome Visual Effects conflict!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/474/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=474&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2010/06/30/installing-oracle-11gr2-enterprise-edition-on-ubuntu-10-04-lucid-lynx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Applying Oracle 11.2 April 2010 PSU for Single-Instance ASM and DBMS</title>
		<link>http://seilerwerks.wordpress.com/2010/06/30/applying-oracle-11-2-april-2010-psu-for-single-instance-asm-and-dbms/</link>
		<comments>http://seilerwerks.wordpress.com/2010/06/30/applying-oracle-11-2-april-2010-psu-for-single-instance-asm-and-dbms/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 20:36:38 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=479</guid>
		<description><![CDATA[Note: This post originally appeared at The Pythian Group blog. When news of the April 2010 PSU for Oracle 11.2 came out, I was excited to see it, since it marked the first non-one-off patch release for the 11.2 database software. I happened to have an 11gR2 test system running on 11gR2 ASM via standalone [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=479&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Note: This post originally appeared at <a href="http://www.pythian.com/news/11881/applying-oracle-11-2-april-2010-psu-for-single-instance-asm-and-dbms/">The Pythian Group blog</a>.</em></p>
<p>When news of the April 2010 PSU for Oracle 11.2 came out, I was excited to see it, since it marked the first non-one-off patch release for the 11.2 database software.  I happened to have an 11gR2 test system running on 11gR2 ASM via standalone Grid Infrastructure.  I applied PSU 9352237 to the DBMS home and fired it up, only to see the folly of my ways when any ASM file operations like disk resizing (or auto-extending) failed with ORA-1653.  This was due to the DBMS component now having a higher version number than the ASM component, which ASM does not allow.  The Grid Infrastucture PSU would need to be applied to bring the ASM component up to snuff, but that patch (9343627) was, at that time, only &#8220;announced&#8221; with no ETA.  Alas, the patch was rolled back and we continued testing without it.</p>
<p>Then this week I check again and saw that PSU 9343627 was released and gave it a whirl.  I was a little confused when the README seemed to contain a lot of instructions that always assumed it to be on a clustered, RAC install.  My setup was a single-instance Grid Infrastructure installation just to provide ASM.  I soon met problem upon problem when going through first this setup step:<span id="more-479"></span><br />
<pre class="brush: plain;">
# GRID_HOME/crs/install/rootcrs.pl -unlock
2010-05-03 11:40:42: Parsing the host name
2010-05-03 11:40:42: Checking for super user privileges
2010-05-03 11:40:42: User has super user privileges
Using configuration parameter file: GRID_HOME/crs/install/crsconfig_params
CRS-4013: This command is not supported in a single-node configuration.
CRS-4000: Command Stop failed, or completed with errors.
You must kill crs processes or reboot the system to properly 
cleanup the processes started by Oracle clusterware
The Oracle Clusterware stack failed to stop.
You should stop the stack with 'crsctl stop crs' and rerun the command
</pre><br />
<!--more--><br />
I decided to try the PSU anyway, thinking Oracle would certainly have noted in the README if this was a problem for single-node installations.  Turns out I was wrong:<br />
<pre class="brush: plain;">
$ GRID_HOME/OPatch/opatch napply -local -oh GRID_HOME -id 9343627,9352237
Invoking OPatch 11.2.0.1.2

... snip ...

Running prerequisite checks...
Prerequisite check &quot;CheckApplicable&quot; failed.
The details are:

Patch 9343627:
Copy Action: Desctination File &quot;GRID_HOME/bin/oradnssd&quot; is not writeable.
'oracle.crs, 11.2.0.1.0': Cannot copy file from 'oradnssd' to 'GRID_HOME/bin/oradnssd'

UtilSession failed: Prerequisite check &quot;CheckApplicable&quot; failed.

OPatch failed with error code 73
</pre></p>
<p>I created an SR with Oracle support, and after reviewing my case agreed that the instructions were not right for single-instance Grid Infrastructure installations.  They will be updating the README, but in the meantime I&#8217;d like to share the revised instructions that got me through two successful GI/DBMS PSU applications today.</p>
<p><strong>Naming Conventions</strong><br />
First a few naming conventions to avoid confusion:</p>
<ul>
<li>DBMS_HOME &#8211; The Oracle DBMS installation directory.</li>
<li>GRID_HOME &#8211; The Oracle Grid Infrastructure installation directory.</li>
</ul>
<p>I&#8217;ve replaced all references to the directories in my examples with DBMS_HOME and GRID_HOME.  Whenever you see those strings, substitute the actual path to your DBMS install or GRID install, whichever the case may be.</p>
<p><strong>Download the PSU and OPatch 11.2</strong><br />
First, you&#8217;ll obviously need to download patch 9343627 that contains the PSU for your platform.  In my case that&#8217;s Linux x86_64.  As of this writing, I believe it&#8217;s only available for Linux x86 and x86_64.  Note that patch 9343627 also includes patch 9352237.  You do not have to, and should not, download that PSU separately.  Everything you need is in the 9343627 download.</p>
<p>Second, choose a working directory to unzip that file.  In my case, this is <code>/home/oracle/software/11gR2/psu/gi</code>, which looked like this after unzipping the PSU zip file:<br />
<pre class="brush: plain;">
$ ls
9343627  9352237  p9343627_112010_Linux-x86-64.zip
</pre></p>
<p>Unlike normal one-off patches, where you would descend into the individual patch-number-named directories, you&#8217;ll stay at this level.</p>
<p>Note also that you&#8217;ll need OPatch 11.2 or higher.  See MOS Doc ID 6880880 and get the latest version of OPatch for your platform.  Then just unzip the file in the DBMS_HOME and GRID_HOME directories, overwriting the old OPatch directory.</p>
<p><strong>Pre-Patch Steps</strong><br />
First I&#8217;m assuming that you have shut down all DBMS instances on this server.  We will shut down ASM later in this process, so <em>be sure to shutdown the DBMS instances now</em>.</p>
<p>Now we&#8217;ll start the pre-patch steps.  First we stop the database on this server, saving the state of the database configuration in /tmp/oracle_home.stat:<br />
<pre class="brush: plain;">
$ DBMS_HOME/bin/srvctl stop home -o DBMS_HOME -s /tmp/oracle_home.stat
</pre><br />
Repeat this for any additional Oracle database home installs on the server.</p>
<p>Next we save the database home configuration.  This only needs to be done if we&#8217;re also going to patch the DBMS home in addition to the GI home.  This is done from the directory where we unzipped the PSU:<br />
<pre class="brush: plain;">
$ ./9343627/custom/server/9343627/custom/scripts/prepatch.sh -dbhome DBMS_HOME
./9343627/custom/server/9343627/custom/scripts/prepatch.sh completed successfully.
</pre></p>
<p>After that, we shut down ASM as one would normally do it:<br />
<pre class="brush: plain;">
$ . oraenv
+ASM
$ sqlplus / as sysasm
SQL&gt; shutdown immediate;
SQL&gt; quit
</pre></p>
<p>Then, as root, we unlock and shutdown HAS (not CRS, as the original README would have you do):<br />
<pre class="brush: plain;">
# GRID_HOME/crs/install/roothas.pl -unlock
2010-05-04 17:14:08: Checking for super user privileges
2010-05-04 17:14:08: User has super user privileges
2010-05-04 17:14:08: Parsing the host name
Using configuration parameter file: GRID_HOME/crs/install/crsconfig_params
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'localhost'
CRS-2673: Attempting to stop 'ora.cssd' on 'localhost'
CRS-2677: Stop of 'ora.cssd' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'localhost'
CRS-2677: Stop of 'ora.diskmon' on 'localhost' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'localhost' has completed
CRS-4133: Oracle High Availability Services has been stopped.
Successfully unlock GRID_HOME
</pre></p>
<p>Now we&#8217;re ready to do some patching.</p>
<p><strong>Applying PSU 9343627 and 9352237 to Oracle 11.2 Grid Infrastructure</strong><br />
As I mentioned earlier, the PSU contains both 9343627 and 9352237, and it is advised that you apply both.  I did so successfully with these commands:<br />
<pre class="brush: plain;">
$ GRID_HOME/OPatch/opatch napply -oh GRID_HOME -id 9343627
$ GRID_HOME/OPatch/opatch napply -oh GRID_HOME -id 9352237
</pre><br />
For each one, you&#8217;ll go through the normal opatch [y|n] confirmation prompts, and also prompted for an email address.  I entered in my MOS login email, and left the password blank (it is optional).  The rest was automatic and finished without error for both cases.</p>
<p><strong>Applying PSU 9343627 and 9352237 to Oracle 11.2 DBMS</strong><br />
Here is something slightly different when applying the 9343627 patch to the DBMS_HOME, we specify a subdirectory after the &#8220;napply&#8221; parameter:<br />
<pre class="brush: plain;">
$ DBMS_HOME/OPatch/opatch napply 9343627/custom/server/ -oh DBMS_HOME -id 9343627
</pre><br />
For patch 9352237, we use the regular syntax:<br />
<pre class="brush: plain;">
$ DBMS_HOME/OPatch/opatch napply -oh DBMS_HOME -id 9352237
</pre></p>
<p>Note that I use OPatch from DBMS_HOME when patching DBMS_HOME, and from GRID_HOME when patching GRID_HOME.  I can&#8217;t say if it is actually necessary, but I like to keep things tidy.  This is why I advised installing the new OPatch into both homes earlier.</p>
<p>As of this moment, both homes are patched, but we aren&#8217;t done yet!</p>
<p><strong>Post-Patch Steps</strong><br />
First we run the postpatch.sh script included in patch 9343627 to reset some file permissions on the DBMS_HOME:<br />
<pre class="brush: plain;">
$ ./9343627/custom/server/9343627/custom/scripts/postpatch.sh -dbhome DBMS_HOME
</pre></p>
<p>Now we re-lock the GRID_HOME and restart the GI stack.  As root:<br />
<pre class="brush: plain;">
# GRID_HOME/crs/install/roothas.pl -patch
2010-05-04 17:33:41: Checking for super user privileges
2010-05-04 17:33:41: User has super user privileges
2010-05-04 17:33:41: Parsing the host name
Using configuration parameter file: GRID_HOME/crs/install/crsconfig_params
CRS-4123: Oracle High Availability Services has been started.
</pre></p>
<p>Verify that the services we need are started (again as root):<br />
<pre class="brush: plain;">
# crsctl check has
CRS-4638: Oracle High Availability Services is online
# crsctl check css
CRS-4529: Cluster Synchronization Services is online
</pre></p>
<p>If you don&#8217;t see CSS started, then you aren&#8217;t alone.  On both of my servers, CSS was not set to auto-start from OHASD.  This was fixed by running these commands as the GRID_HOME owner (oracle):<br />
<pre class="brush: plain;">
$ crsctl modify resource &quot;ora.cssd&quot; -attr &quot;AUTO_START=1&quot;
$ crsctl modify resource &quot;ora.diskmon&quot; -attr &quot;AUTO_START=1&quot;
</pre></p>
<p>Then, as root:<br />
<pre class="brush: plain;">
# crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'localhost'
CRS-2673: Attempting to stop 'ora.cssd' on 'localhost'
CRS-2677: Stop of 'ora.cssd' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'localhost'
CRS-2677: Stop of 'ora.diskmon' on 'localhost' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'localhost' has completed
CRS-4133: Oracle High Availability Services has been stopped.

# crsctl start has
CRS-4123: Oracle High Availability Services has been started.

# crsctl check has
CRS-4638: Oracle High Availability Services is online

# crsctl check css
CRS-4529: Cluster Synchronization Services is online
</pre></p>
<p>Moving on in the post-patch steps, we start the DBMS_HOME from the state file we created earlier:<br />
<pre class="brush: plain;">
$ DBMS_HOME/bin/srvctl start home -o DBMS_HOME -s /tmp/oracle_home.stat 
</pre></p>
<p>At this point, we are done.  You can start ASM and the DBMS instances.  For some affirmation, run this for both GRID_HOME and DBMS_HOME (just using GRID_HOME in this example)</p>
<p><pre class="brush: plain;">

$ GRID_HOME/OPatch/opatch lsinventory
Invoking OPatch 11.2.0.1.2

Oracle Interim Patch Installer version 11.2.0.1.2
Copyright (c) 2010, Oracle Corporation.  All rights reserved.


Oracle Home       : GRID_HOME
Central Inventory : /opt/oracle/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.2.0.1.2
OUI version       : 11.2.0.1.0
OUI location      : GRID_HOME/oui
Log file location : GRID_HOME/cfgtoollogs/opatch/opatch2010-05-04_18-36-23PM.log

Patch history file: GRID_HOME/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : GRID_HOME/cfgtoollogs/opatch/lsinv/lsinventory2010-05-04_18-36-23PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1): 

Oracle Grid Infrastructure                                           11.2.0.1.0
There are 1 products installed in this Oracle Home.


Interim patches (2) :

Patch  9352237      : applied on Tue May 04 18:22:41 EDT 2010
Unique Patch ID:  12381846
   Created on 25 Mar 2010, 00:05:17 hrs PST8PDT
   Bugs fixed:
     8661168, 8769239, 8898852, 8801119, 9054253, 8706590, 8725286, 8974548
     8778277, 8780372, 8769569, 9027691, 9454036, 9454037, 9454038, 8761974
     7705591, 8496830, 8702892, 8639114, 8723477, 8729793, 8919682, 8818983
     9001453, 8475069, 9328668, 8891929, 8798317, 8820324, 8733749, 8702535
     8565708, 9036013, 8735201, 8684517, 8870559, 8773383, 8933870, 8812705
     8405205, 8822365, 8813366, 8761260, 8790767, 8795418, 8913269, 8897784
     8760714, 8717461, 8671349, 8775569, 8898589, 8861700, 8607693, 8642202
     8780281, 9369797, 8780711, 8784929, 8834636, 9015983, 8891037, 8828328
     8570322, 8832205, 8665189, 8717031, 8685253, 8718952, 8799099, 8633358
     9032717, 9321701, 8588519, 8783738, 8796511, 8782971, 8756598, 9454385
     8856497, 8703064, 9066116, 9007102, 8721315, 8818175, 8674263, 9352237
     8753903, 8720447, 9057443, 8790561, 8733225, 9197917, 8928276, 8991997, 8837736

Patch  9343627      : applied on Tue May 04 18:18:31 EDT 2010
Unique Patch ID:  12381846
   Created on 15 Apr 2010, 11:28:38 hrs PST8PDT
   Bugs fixed:
     9343627, 9262748, 9262722



--------------------------------------------------------------------------------

OPatch succeeded.
</pre></p>
<p>As I said, Oracle support will be updating the README for PSU 9343627, but in the meantime I hope this guide helps you as much as it helped me.  I&#8217;d like to thank my Pythian colleague Alex Gorbachev for his help in diagnosing some of the GI problems after the first broken patching, and also Esteban B. at Oracle Support for working closely with us to get a new single-node action plan.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/479/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=479&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2010/06/30/applying-oracle-11-2-april-2010-psu-for-single-instance-asm-and-dbms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>A Drupal Backup Script</title>
		<link>http://seilerwerks.wordpress.com/2009/11/22/a-drupal-backup-script/</link>
		<comments>http://seilerwerks.wordpress.com/2009/11/22/a-drupal-backup-script/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 16:28:55 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=454</guid>
		<description><![CDATA[I maintain a drupal codebase that hosts multiple sites. I&#8217;ve been shamefully lax in getting regular backups of those files and databases, until today. Here is a pretty basic bash script that will create a bzip2 archive of the drupal codebase (including site-specific dirs), and then create mysqldump exports of each site&#8217;s database and gzip [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=454&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I maintain a drupal codebase that hosts multiple sites.  I&#8217;ve been shamefully lax in getting regular backups of those files and databases, until today.  Here is a pretty basic bash script that will create a bzip2 archive of the drupal codebase (including site-specific dirs), and then create mysqldump exports of each site&#8217;s database and gzip those files.  This particular script requires that the drupal install directory be named &#8220;drupal&#8221;, but you can change this easily enough to suit your needs.</p>
<p>This does require a ~/.drupalsites file that contains the needed database login info (suggest chmod 600).  Like I said, nothing too clever.</p>
<p><pre class="brush: bash;">
#!/bin/bash
DATESTAMP=`date +%Y%m%d`
SITESFILE=${HOME}/.drupalsites
# SITESFILE contents are in the following format:
# SITENAME:DBNAME:DBUSER:DBPASSWD
DRUPALDIR=/path/to/drupal
BACKUPDIR=${HOME}/backups/${DATESTAMP}

mkdir -p ${BACKUPDIR}

# Backup the drupal codebase
echo -n &quot;Backing up ${DRUPALDIR} ... &quot;
cd ${DRUPALDIR}/../
tar -cjpf ${BACKUPDIR}/drupal_${DATESTAMP}.tar.bz2 drupal
echo &quot;Done.&quot;

cd ${BACKUPDIR}

# Backup MySQL Databases
cat $SITESFILE | while read line; do
        #echo $line
        line=(${line//:/ })
        echo -n &quot;Backing up MySQL db ${line[1]} ... &quot;
        DUMPFILE=${line[0]}_${DATESTAMP}.sql
        mysqldump -u ${line[2]} -p${line[3]} ${line[1]} &gt; ${DUMPFILE}
        gzip ${DUMPFILE}
        echo &quot;Done.&quot;
done

echo &quot;Backup completed, all files are in ${BACKUPDIR}.&quot;
</pre></p>
<p>This script runs fine from cron, I have it scheduled for a weekly run.  I then plan to rsync this to my home server for an offsite copy, even though the hosting service provides backups as well.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/454/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=454&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2009/11/22/a-drupal-backup-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>HOWTO: Oracle Cross-Platform Migration with Minimal Downtime</title>
		<link>http://seilerwerks.wordpress.com/2009/10/27/howto-oracle-cross-platform-migration-with-minimal-downtime/</link>
		<comments>http://seilerwerks.wordpress.com/2009/10/27/howto-oracle-cross-platform-migration-with-minimal-downtime/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 18:49:33 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=449</guid>
		<description><![CDATA[Originally posted at The Pythian Group blog. I recently performed a migration from Oracle 10gR2 on Solaris to the same version on Linux, immediately followed by an upgrade to 11g. Both platforms were x86-64. Migrating to Linux also included migrating to ASM, whereas we had been using ZFS to hold the datafiles on Solaris. Restoring [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=449&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted at <a href="http://www.pythian.com/news/3653/howto-oracle-cross-platform-migration-with-minimal-downtime">The Pythian Group blog</a>.</em></p>
<p>I recently performed a migration from Oracle 10gR2 on Solaris to the same version on Linux, immediately followed by an upgrade to 11g.  Both platforms were x86-64.  Migrating to Linux also included migrating to ASM, whereas we had been using ZFS to hold the datafiles on Solaris.  Restoring files into ASM meant we would have to use RMAN (which we would probably choose to use anyway).</p>
<p>As with many databases, the client wanted minimal downtime.  It was obvious to us that the most time-consuming operation would be the restore and recovery into the new instance.  We were basically doing a restore and recovery from production backups and archived redo logs.  It quickly dawned on me that we could start this operation well before the scheduled cutover time and downtime window, chopping at least six hours from the downtime window.  The client would only need to keep the new instance in mount mode after the initial restore/recovery finished, periodically re-catalog the source instance&#8217;s FRA (which was mounted via NFS), and then re-run the <code>recover database</code> command in RMAN.  Once the time comes to cutover, simply <code>archivelog current</code> the original instance and <code>shutdown immediate</code>.  Then open the new instance with the <code>RESETLOGS</code> option, and voila!  Migration complete!</p>
<p>I&#8217;ll try to recreate a simple example here.  <span id="more-449"></span></p>
<p>On the new instance, assume that you have ASM set up and configured with two disk groups, <code>DATA</code> and <code>REDO</code>.  Let&#8217;s also assume that you have the FRA directory (or the directory where you hold backups and archivelogs) mounted from the Solaris host to the Linux host under <code>/solfra/prod/</code>.  Here&#8217;s the command we used:<br />
<pre class="brush: bash;">
mount -o hard,bg,tcp,nfsvers=3,suid,rsize=32768,wsize=32768,nointr,noac,ro solhost:/fra /solfra/
</pre></p>
<p>We then need to get a pfile and edit it for <em>ASM-ification</em>.  You can either restore the spfile from backup or just export a pfile from the current running production instance.  To do the former, you&#8217;d need to go into RMAN and run an operation similar to this (best to ensure that the <code>ORACLE_HOME</code>, <code>ORACLE_SID</code>, and other Oracle-related environment variables are set properly):</p>
<p><pre class="brush: sql;">
RMAN&gt; startup force

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/oracle/app/oracle/product/10.2.0/db_1/dbs/initprod.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/29/2009 13:34:50
ORA-00205: error in identifying control file, check alert log for more info
RMAN&gt;
RMAN&gt; restore spfile to pfile 'initprod.ora' from autobackup recovery area = '/solfra/' db_unique_name = 'PROD';

Starting restore at 29-JUN-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK

recovery area destination: /solfra/
database name (or database unique name) used for search: PROD
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /solfra/PROD/autobackup/2009_06_29/o1_mf_s_690813149_54kypcxz_.bkp
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 29-JUN-09
</pre></p>
<p>From here you can go into sqlplus and <code>CREATE PFILE FROM SPFILE;</code>.</p>
<p>Now we have our text pfile in <code>$ORACLE_HOME/dbs/initprod.ora</code>, and we want to make these changes specific to the transition to ASM:</p>
<pre>
*.control_files='+DATA','+REDO'
*.db_create_file_dest='+DATA'
*.db_create_online_log_dest_1='+REDO'
*.db_recovery_file_dest='/path/to/fra'
*.db_recovery_file_dest_size='2000G'
</pre>
<p>Obviously, the last two parameters about location and size of the FRA should be tailored to your setup.</p>
<p>We then create a new SPFILE with <code>CREATE SPFILE FROM PFILE;</code>.</p>
<p>Now we&#8217;re ready to restore the controlfile(s) from backup:<br />
<pre class="brush: sql;">
RMAN&gt; startup force;

Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 08/13/2009 20:20:56
ORA-00205: error in identifying control file, check alert log for more info

RMAN&gt; restore controlfile from autobackup recovery area = '/solfra/' db_unique_name = 'PROD';

Starting restore at 13-AUG-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=650 devtype=DISK

recovery area destination: /solfra/
database name (or database unique name) used for search: PROD
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /solfra/PROD/autobackup/2009_08_13/o1_mf_s_694801261_5890xyoj_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=+DATA/prod/controlfile/current.256.694815695
output filename=+REDO/prod/controlfile/current.256.694815697
Finished restore at 13-AUG-00
</pre></p>
<p>Note that if you restored the spfile from backup, you don&#8217;t need to specify the recovery area in the <code>restore controlfile from autobackup</code> command.  In this case, because I chose to create a pfile from the source instance, I needed to supply the recovery area location.  Note that this is the recovery area that holds the source backups, not the recovery area that your new instance will use once it is opened.</p>
<p>With the control files restored, we can mount the new instance:<br />
<pre class="brush: sql;">
RMAN&gt; alter database mount;

database mounted
released channel: ORA_DISK_1
</pre></p>
<p>The next step is to catalog the backup files and archivelogs from the remote FRA.</p>
<p><pre class="brush: sql;">
RMAN&gt; CATALOG START WITH '/solfra/PROD' NOPROMPT;

Starting implicit crosscheck backup at 13-AUG-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=646 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=650 devtype=DISK
Crosschecked 565 objects
Finished implicit crosscheck backup at 13-AUG-09

Starting implicit crosscheck copy at 13-AUG-09
using channel ORA_DISK_1
using channel ORA_DISK_2
Finished implicit crosscheck copy at 13-AUG-09

searching for all files in the recovery area
cataloging files...
</pre></p>
<p>This will continue listing all the files in the catalog, and some files that were not cataloged (e.g. online redo logs, non-RMAN files, etc.).</p>
<p>Now we&#8217;re ready to begin our RESTORE phase.  You&#8217;ll need an rman command file that looks something like this:<br />
<pre class="brush: sql;">
run {
  set newname for datafile X to new;
  # ... (repeat for other datafiles)
  set newname for tempfile Y to new;
  # ... (repeat for other tempfiles)
  restore database;
  switch datafile all;
  switch tempfile all;
}
recover database;
</pre></p>
<p>Note that X and Y are the file# of the individual datafile and tempfile, respectively.  You will probably want to generate this file if you have a large number of datafiles.</p>
<p>It is important that you read MetaLink Doc 415884.1, if you are performing a migration to a different platform with the same endian.  Oracle suggests that you should perform a CONVERT DATABASE, but later admits that you only need to perform a CONVERT on tablespaces containing UNDO segments:</p>
<blockquote><p>
The convert database command is a no operation command for all files that do not contain undo but they are scanned regardless during the conversion. Using the convert tablespace/datafile for those containing undo will suffice and all other source files not containing undo can be moved to the target (same endian) platform without the Recovery Manager conversion. This will greatly reduce the time required to move and database with thousands of files from source to target platform also decreasing the amount of time the database is unavailable.</p></blockquote>
<p>We had an internal debate over whether or not it is truly necessary even to do this.  However, I would advise you to read this document and discuss it with Oracle Support Services.  They would most likely try to convince you to do it or threaten to not support your database.</p>
<p>Once the script finishes with the <code>recover database</code> portion, this query should indicate that datafile headers and controlfiles are in sync:<br />
<pre class="brush: sql;">
SQL&gt; alter session set nls_date_format='YYYY/MON/DD hh24:mi:ss';

Session altered.

SQL&gt; select checkpoint_time,fuzzy,count(*),status
from ( select checkpoint_time,fuzzy,status
       from v$datafile_header
       union all
       select controlfile_time,'CTL',null from v$database)
group by checkpoint_time,fuzzy,status;

CHECKPOINT_TIME      FUZ   COUNT(*) STATUS
-------------------- --- ---------- -------
2009/AUG/14 02:22:11 CTL	  1
2009/AUG/14 02:22:11 YES       1266 ONLINE
</pre></p>
<p>The database is still in mount mode.  If we were ready to cut over now, we could open the database with the <code>RESETLOGS</code> option.  However, we are still a few hours or a day away from the cutover.  What we want to do is apply more logs from the current production instance as they get archived. To minimize the babysitting, we decided to run this in a script once every few hours:<br />
<pre class="brush: sql;">
CATALOG START WITH '/solfra/PROD' NOPROMPT;
RECOVER DATABASE;
</pre></p>
<p>As you can guess, this re-catalogs the NFS-mounted FRA, ignoring files that were already cataloged.  So now the controlfile knows about the new archivelogs.  The <code>RECOVER DATABASE</code> command then beautifully applies logs from where it left off until it runs out of logs again.  We re-run this periodically to keep our new instance as close to current as possible until it&#8217;s time to cut over.</p>
<p>When the cutover time comes, we run this on the current production instance:<br />
<pre class="brush: sql;">
SQL&gt; alter system archive log current;

System altered.

SQL&gt; shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
</pre></p>
<p>Then, on the new instance, we do one last catalog and recover.  This should bring us completely up to date with the original prod instance.  Now we just need to open with resetlogs:<br />
<pre class="brush: sql;">
SQL&gt; alter database open resetlogs;

Database altered.
</pre></p>
<p>In my case, I manually renamed the online and standby redo logs to <code>+REDO</code> (they still had the old filesystem names in v$logfile), but I believe that <code>OPEN RESETLOGS</code> does this automatically anyway.</p>
<p>And so, here we are in Linux on on the same version (10.2.0.2) as Solaris with appropriate one-off patches, using ASM.  At this point, I was just under 30 minutes into my downtime window since the original prod instance was shutdown.  I don&#8217;t think that&#8217;s too bad for moving a 1.3T database!</p>
<p>After this, I immediately went into upgrading to 11gR1 (11.1.0.7) and then building a new standby instance, but that is outside the scope of the initial migration that I wanted to share with you today.  Cheers!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/449/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/449/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/449/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/449/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/449/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/449/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/449/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=449&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2009/10/27/howto-oracle-cross-platform-migration-with-minimal-downtime/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Moving Oracle Datafiles to a ZFS Filesystem with the Correct Recordsize</title>
		<link>http://seilerwerks.wordpress.com/2009/10/24/moving-oracle-datafiles-to-a-zfs-filesystem-with-the-correct-recordsize/</link>
		<comments>http://seilerwerks.wordpress.com/2009/10/24/moving-oracle-datafiles-to-a-zfs-filesystem-with-the-correct-recordsize/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 16:20:05 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=442</guid>
		<description><![CDATA[Originally posted on The Pythian Group blog. Full credit for this tale should go to my colleague Christo Kutrovsky for the inspiration and basic plan involved. We recently migrated a large database from Solaris SPARC to Solaris x86-64. All seemed to go well with the migration, but in the next few weeks, we noticed some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=442&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted on <a href="http://www.pythian.com/news/3627/moving-oracle-datafiles-to-a-zfs-filesystem-with-the-correct-recordsize">The Pythian Group blog</a>.</em></p>
<p><em>Full credit for this tale should go to my colleague <a href="http://www.pythian.com/news/author/kutrovsky">Christo Kutrovsky</a> for the inspiration and basic plan involved.<br />
</em></p>
<p>We recently migrated a large database from Solaris SPARC to Solaris x86-64. All seemed to go well with the migration, but in the next few weeks, we noticed some I/O issues cropping up. Some research led us to find that the ZFS filesystem used to hold the datafiles was killing us on I/O. The default “recordsize” setting for ZFS was 128k.<br />
<pre class="brush: bash;">
$ /usr/sbin/zfs get recordsize zfs-data
NAME      PROPERTY    VALUE     SOURCE
zfs-data  recordsize  128K      default
</pre><br />
An Oracle database typically uses 8k for the block size, but in this case it was 16k. We saw basically the same thing that Neelakanth Nadgir described in his blog post, <a href="http://blogs.sun.com/realneel/entry/zfs_and_databases">Databases and ZFS</a>:</p>
<blockquote><p>With ZFS, not only was the throughput much lower, but we used more [than] twice the amount of CPU per transaction, and we are doing 2x times the IO. The disks are also more heavily utilized. We noticed that we were not only reading in more data, but we were also doing more IO operations [than] what is needed.</p></blockquote>
<p>The fix is to set the ZFS recordsize for a datafile filesystem to match the Oracle instance’s <code>db_block_size</code>.  We also read in <a href="http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide#ZFS_and_Database_Recommendations">the ZFS Best Practices Guide</a> that redo logs should be in a separate filesystem with the default ZFS recordsize of 128k. We already had them separate, so we just needed to get our datafiles on a ZFS filesystem with a 16k recordsize.<br />
<span id="more-442"></span><br />
The first step is to change the ZFS recordsize for the current filesystem. Easy enough, but the change in recordsize will only apply to new files written there. It doesn’t do anything for our existing terabyte-plus of datafiles. This means we need to move the files to a new ZFS filesystem with the correct recordsize already set. That’s where the magic happens.</p>
<p><span id="more-3627"> </span></p>
<p>My first thought was that we’d need whole other slab of disk. Then I learned that we can simply create a new ZFS filesystem on the same pool of disks as the old filesystem. Obviously we won’t be able to hold two complete copies of the datafiles, but this would let us migrate groups of files at a time (for example, a tablespace). When the move is complete, disk space is released from the old filesystem, so the sum of used disk is essentially unchanged.</p>
<p>The rest is just a matter of moving datafiles. Now, we all know you can’t just move or copy Oracle datafiles from a running instance. We also know that clients want as little downtime as possible, so doing a complete shutdown/move/mount/rename/open is out of the question. We could offline a tablespace, move its datafiles, rename them in the database, then online the tablespace again. Here’s a sample scenario, starting with tablespace and datafile creation:<br />
<pre class="brush: sql;">
SQL&gt; create tablespace zfstest
  2          datafile '/u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf'
  3          size 128m;

Tablespace created.

SQL&gt; alter tablespace zfstest
  2          add datafile '/u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf'
  3          size 128m;

Tablespace altered.

SQL&gt; create table zfsobjects tablespace zfstest
  2          as select * from dba_objects;

Table created.
</pre><br />
Accept the following:</p>
<ul>
<li><code>/u01/app/oracle/oradata/orcl/zfs128k/</code> is a ZFS filesystem with default 128k recordsize</li>
<li><code>/u01/app/oracle/oradata/orcl/zfs16k/</code> is a ZFS filesystem with a 16k recordsize</li>
</ul>
<p>So here we have datafiles created on a ZFS filesystem with the default 128k recordsize, and a small table just to test data access. To move the entire tablespace in one go, we do this:<br />
<pre class="brush: sql;">
SQL&gt; alter tablespace zfstest offline;

Tablespace altered.

SQL&gt; !mv /u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf
     /u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf

SQL&gt; alter database rename file '/u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf' to
'/u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf';

Database altered.

SQL&gt; !mv /u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf
/u01/app/oracle/oradata/orcl/zfs16k/zfstest02.dbf

SQL&gt; alter database rename file '/u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf' to
'/u01/app/oracle/oradata/orcl/zfs16k/zfstest02.dbf';
Database altered.

SQL&gt; alter tablespace zfstest online;

Tablespace altered.

SQL&gt; select count(*) from zfsobjects;

  COUNT(*)
----------
     68844
</pre><br />
Pretty simple.  We do the one escape to the OS <code>mv</code> command to move the datafile.  If you want to be safe, you could use <code>cp</code> instead of <code>mv</code> to copy the file.  Just know that disk space from the old filesystem won’t be released until you delete the old files.</p>
<p>Note that this operation could take a very long time in the case of large tablespaces. We could try a somwhat similar approach of taking one datafile offline at a time and moving it. We’d just need to perform a quick recovery before bringing it online. That would look like this:<br />
<pre class="brush: sql;">
SQL&gt; alter database datafile '/u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf' offline;

Database altered.

SQL&gt; !mv /u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf
/u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf

SQL&gt; alter database rename file '/u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf' to
'/u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf';

Database altered.

SQL&gt; recover datafile '/u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf';
Media recovery complete.

SQL&gt; alter database datafile '/u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf' online;

Database altered.

SQL&gt; alter database datafile
'/u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf' offline;

Database altered.

SQL&gt; !mv /u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf
/u01/app/oracle/oradata/orcl/zfs16k/zfstest02.dbf

SQL&gt; alter database rename file '/u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf'
to '/u01/app/oracle/oradata/orcl/zfs16k/zfstest02.dbf';

Database altered.

SQL&gt; recover datafile '/u01/app/oracle/oradata/orcl/zfs16k/zfstest02.dbf';
Media recovery complete.

SQL&gt; alter database datafile '/u01/app/oracle/oradata/orcl/zfs16k
/zfstest02.dbf' online;

Database altered.

SQL&gt; select count(*) from zfsobjects;

  COUNT(*)
----------
     68844
</pre><br />
Seems fine. Note that your instance needs to be in ARCHIVELOG mode to be able to take datafiles offline. Obviously, if someone tried to access data on an offline datafile they’d get this error:<br />
<pre class="brush: sql;">
SQL&gt; select count(*) from zfsobjects;
select count(*) from zfsobjects
                     *
ERROR at line 1:
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/zfs16k/zfstest01.dbf'
</pre><br />
So if a datafile is particularly large, this can mean still a few minutes of some data being offline. We have one more tool at our disposal that provides for a quicker turnaround: RMAN’s <code>BACKUP AS COPY</code> command. As it says, this creates a copy of a datafile as a backup. The benefit is that it does this while the current datafile (and data) remains online. We then just need to offline, switch, recover, and online each datafile, which takes very little time compared to the time spent moving a large datafile. That process would be something like this.</p>
<p>First, we want to know the file numbers of our datafiles. This is because the RMAN procedure doesn’t provide for an easy way to preserve datafile names when we backup an entire tablespace (which we’re going to do):<br />
<pre class="brush: sql;">
SQL&gt; select file_id, file_name
  2  from dba_data_files
  3  where tablespace_name='ZFSTEST';

   FILE_ID FILE_NAME
---------- -------------------------------------------------------
	 6 /u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf
	 7 /u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf
</pre><br />
So we have file numbers 6 and 7.  Now we create our RMAN command file and execute it:<br />
<pre class="brush: sql;">
RMAN&gt; backup as copy
2&gt; 	tablespace zfstest format '/u01/app/oracle/oradata/orcl/zfs16k/%U';
3&gt;
4&gt; sql 'alter database datafile 6 offline';
5&gt; switch datafile 6 to copy;
6&gt; recover datafile 6;
7&gt; sql 'alter database datafile 6 online';
8&gt;
9&gt; sql 'alter database datafile 7 offline';
10&gt; switch datafile 7 to copy;
11&gt; recover datafile 7;
12&gt; sql 'alter database datafile 7 online';
13&gt;
Starting backup at 18-AUG-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf
output file name=/u01/app/oracle/oradata/orcl/zfs16k/data_D-ORCL_I-1203425866_TS-ZFSTEST_FNO-6_01kn0irh tag=TAG20090818T140640 RECID=2 STAMP=695225208
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf
output file name=/u01/app/oracle/oradata/orcl/zfs16k/data_D-ORCL_I-1203425866_TS-ZFSTEST_FNO-7_02kn0is0 tag=TAG20090818T140640 RECID=3 STAMP=695225222
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 18-AUG-09

sql statement: alter database datafile 6 offline

datafile 6 switched to datafile copy
&quot;/u01/app/oracle/oradata/orcl/zfs16k/data_D-ORCL_I-1203425866_TS-ZFSTEST_FNO-6_01kn0irh&quot;

Starting recover at 18-AUG-09
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 18-AUG-09

sql statement: alter database datafile 6 online

sql statement: alter database datafile 7 offline

datafile 7 switched to datafile copy
&quot;/u01/app/oracle/oradata/orcl/zfs16k/data_D-ORCL_I-1203425866_TS-ZFSTEST_FNO-7_02kn0is0&quot;

Starting recover at 18-AUG-09
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 18-AUG-09

sql statement: alter database datafile 7 online

Recovery Manager complete.
</pre><br />
Voila!  The tablespace is moved with minimal downtime:<br />
<pre class="brush: sql;">SQL&gt; select file_id, file_name
  2  from dba_data_files
  3  where tablespace_name='ZFSTEST';

   FILE_ID
----------
FILE_NAME
--------------------------------------------------------------------------------
	 6
/u01/app/oracle/oradata/orcl/zfs16k/data_D-ORCL_I-1203425866_TS-ZFSTEST_FNO-6_01kn0irh

	 7
/u01/app/oracle/oradata/orcl/zfs16k/data_D-ORCL_I-1203425866_TS-ZFSTEST_FNO-7_02kn0is0

SQL&gt; select count(*) from zfsobjects;

  COUNT(*)
----------
     68844
</pre><br />
Obviously, you can generate all your statements from SQL scripts, and you’ll definitely want to do this if your tablespace has a large amount of datafiles. If you are scripting, you could opt to backup one datafile at a time if you need to preserve file names. In this case, I wasn’t too concerned.</p>
<p>UPDATE: Teammate Marc Billette pointed out that the old datafiles were not removed when doing a datafile copy and switch. I clearly left them on disk, continuing to use space! So, once we are done with all the datafile switches, then our original datafiles become the copies, and we can list and delete those in RMAN like this:<br />
<pre class="brush: sql;">
RMAN&gt; list datafilecopy all;

List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time
------- ---- - --------------- ---------- ---------------
4       6    A 18-AUG-09       629982     18-AUG-09
        Name: /u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf

5       7    A 18-AUG-09       630001     18-AUG-09
        Name: /u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf

RMAN&gt; delete datafilecopy all;

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK
List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time
------- ---- - --------------- ---------- ---------------
4       6    A 18-AUG-09       629982     18-AUG-09
        Name: /u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf

5       7    A 18-AUG-09       630001     18-AUG-09
        Name: /u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf

Do you really want to delete the above objects (enter YES or NO)? YES
deleted datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/zfs128k/zfstest01.dbf RECID=4 STAMP=695225227
deleted datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/zfs128k/zfstest02.dbf RECID=5 STAMP=695225228
Deleted 2 objects
</pre><br />
Thanks to Marc for catching this early in the published life of the article!</p>
<p>I hope this post can help other people that run into this problem with Oracle on ZFS (I’ve heard from one on twitter already), or people just wanting to move datafiles. Again, thanks to Pythian DBA Christo Kutrovsky for laying this process out for us!</p>
<p><em>Note: this process was tested on Oracle 10gR2 (10.2.0.2) and 11gR1 (11.1.0.6).</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/442/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=442&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2009/10/24/moving-oracle-datafiles-to-a-zfs-filesystem-with-the-correct-recordsize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting up Network ACLs in Oracle 11g… For Dummies</title>
		<link>http://seilerwerks.wordpress.com/2009/08/19/setting-up-network-acls-in-oracle-11g%e2%80%a6-for-dummies/</link>
		<comments>http://seilerwerks.wordpress.com/2009/08/19/setting-up-network-acls-in-oracle-11g%e2%80%a6-for-dummies/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 18:37:46 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=434</guid>
		<description><![CDATA[Originally posted on The Pythian Group blog. Having recently performed a test upgrade for a client from Oracle RDBMS 10g to 11g, I can tell you that one of the big changes that will likely require action on your part as DBA is the new fine-grained access control for the packages UTL_SMTP, UTL_TCP, UTL_MAIL, UTL_HTTP [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=434&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted on <a href="http://www.pythian.com/news/3434/setting-up-network-acls-in-oracle-11g-for-dummies">The Pythian Group blog</a>.<br />
</em></p>
<p>Having recently performed a test upgrade for a client from Oracle RDBMS 10g to 11g, I can tell you that one of the big changes that will likely require action on your part as DBA is the new fine-grained access control for the packages <code>UTL_SMTP</code>, <code>UTL_TCP</code>, <code>UTL_MAIL</code>, <code>UTL_HTTP</code> and <code>UTL_INADDR</code>.  Part of the Oracle 11g pre-upgrade tool will <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28300/upgrade.htm#BABJHIHH">notify you of users that will require new privileges</a>.</p>
<p>Of course, Oracle’s <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28300/afterup.htm#BABFCBJI">post-upgrade network ACL setup documentation</a> is much more confusing than it needs to be, at least for simple minds like me. A colleague stepped forward with a simple set of commands for a basic setup that even the tired and stressed can understand.</p>
<p>I’ll share that here, with some basic explanation:</p>
<p><span id="more-3434"> </span><br />
<pre class="brush: sql;">
BEGIN
  -- Create the new ACL, naming it &quot;netacl.xml&quot;, with a description.
  -- Also, provide one starter privilege, granting user FOO
  -- the privilege to connect.
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('netacl.xml',
      'Allow usage to the UTL network packages', 'FOO', TRUE, 'connect');

  -- Now grant privilege to resolve DNS names for FOO,
  -- and then grant connect and resolve to user BAR
  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('netacl.xml' ,'FOO', TRUE, 'resolve');
  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('netacl.xml' ,'BAR', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('netacl.xml' ,'BAR', TRUE, 'resolve');

  -- Specify which hosts this ACL applies to,
  -- for simplicity, we're saying all (*)
  -- You might want to specify certain hosts to lock this down.
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('netacl.xml','*');
END;
/
</pre><br />
As you can see, this example will let the <code>FOO</code> and <code>BAR</code> database users connect and resolve to any host.  The <code>ASSIGN_ACL</code> section in the full package documentation (see link below) details how this can be used to lock down a user’s ability to make outside connections.</p>
<p>Of course, nothing beats reading the <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_networkacl_adm.htm#insertedID0">Oracle 11g DBMS_NETWORK_ACL_ADMIN documentation</a>, where you can see some examples of stricter ACL setups.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/434/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=434&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2009/08/19/setting-up-network-acls-in-oracle-11g%e2%80%a6-for-dummies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Turn Off db_cache_advice To Avoid Latch Contention Bugs</title>
		<link>http://seilerwerks.wordpress.com/2009/08/19/turn-off-db_cache_advice-to-avoid-latch-contention-bugs/</link>
		<comments>http://seilerwerks.wordpress.com/2009/08/19/turn-off-db_cache_advice-to-avoid-latch-contention-bugs/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 18:35:12 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=429</guid>
		<description><![CDATA[Originally posted on The Pythian Group blog. A couple of weeks ago, we noticed some timeouts in some of our standard Oracle RDBMS health check scripts on a new instance. I had just migrated this instance to bigger, better, badder hardware and so it had been given more SGA to use, namely a bigger buffer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=429&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted on <a href="http://www.pythian.com/news/2838/turn-off-db_cache_advice-to-avoid-latch-contention-bugs">The Pythian Group blog</a>.</em></p>
<p>A couple of weeks ago, we noticed some timeouts in some of our standard Oracle RDBMS health check scripts on a new instance. I had just migrated this instance to bigger, better, badder hardware and so it had been given more SGA to use, namely a bigger buffer cache. The software version was still Oracle 10.2.0.2, as we wanted to introduce as few variables as possible (we were already moving to a new platform with an <a href="http://en.wikipedia.org/wiki/Endianness">endian</a> change).</p>
<p>At first the timeouts were infrequent, but over the course of a week started to grow in frequencey until the point where none of the checks were finishing in the allowed timeframe. We ran an AWR report, and tucked far down in the “Latch Activity” section, a colleague noticed this:</p>
<pre>                                           Pct    Avg   Wait                 Pct
                                    Get    Get   Slps   Time       NoWait NoWait
Latch Name                     Requests   Miss  /Miss    (s)     Requests   Miss
------------------------ -------------- ------ ------ ------ ------------ ------
...
<strong>simulator lru latch          10,032,617    3.3    0.7  44950      336,837    0.3</strong>
...
Latch Activity                             DB/Inst: FOO/foo  Snaps: 156-157
-&gt; "Get Requests", "Pct Get Miss" and "Avg Slps/Miss" are statistics for
   willing-to-wait latch get requests
-&gt; "NoWait Requests", "Pct NoWait Miss" are for no-wait latch get requests
-&gt; "Pct Misses" for both should be very close to 0.0

                                           Pct    Avg   Wait                 Pct
                                    Get    Get   Slps   Time       NoWait NoWait
Latch Name                     Requests   Miss  /Miss    (s)     Requests   Miss
------------------------ -------------- ------ ------ ------ ------------ ------
transaction branch alloc        112,412    0.0    0.0      0            0    N/A
undo global data                466,321    0.0    0.0      0            0    N/A
user lock                         7,440    0.8    0.4      1            0    N/A
          -------------------------------------------------------------</pre>
<p>The “simulator lru latch” event brought us to MetaLink note 5918642.8 and bug 5918642. Affecting 10g and 11g prior to 10.2.0.4 and 11.1.0.7, respectively. The bug is with the database buffer cache advisor, controlled by the parameter <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams042.htm#sthref126">db_cache_advice</a>, which defaults to ON (depending on statistics_level).  The note simply states:</p>
<blockquote><p>High simulator lru latch contention can occur when db_cache_advice is set to ON if there is a large buffer cache.</p></blockquote>
<p>We simply set db_cache_advice to OFF (thankfully it is a dynamic parameter), and pretty quickly our checks were running just fine.</p>
<p>My suggestion is to simply turn this off unless you are actively using the cache advisor to tune an instance. Once you are done tuning, and are no longer using the advisor, turn it off.</p>
<p>NOTE:  As Mladen Gogola pointed out in the comments, turning this off will cause problems if you are using automatic memory management (i.e. sga_target &gt; 0).   Re-pasting his post here:</p>
<blockquote><p>The problem with that advice is that it will prevent automatic memory management from resizing the buffer cache and the instance will end up with a huge, mostly empty, shared pool and default buffer cache. Automatic memory management is biased toward shared pool even with the cache dvice turned on, without it, buffer cache will be reduced to the minimum size, usually only 64MB. If you disable cache advice, I would also recommend disabling the automatic memory management and configuring SGA manually.</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/429/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/429/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/429/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/429/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/429/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/429/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/429/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/429/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=429&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2009/08/19/turn-off-db_cache_advice-to-avoid-latch-contention-bugs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending Timezone-Aware Email with UTL_SMTP</title>
		<link>http://seilerwerks.wordpress.com/2009/08/19/sending-timezone-aware-email-with-utl_smtp/</link>
		<comments>http://seilerwerks.wordpress.com/2009/08/19/sending-timezone-aware-email-with-utl_smtp/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 18:32:43 +0000</pubDate>
		<dc:creator>Don Seiler</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://seilerwerks.wordpress.com/?p=420</guid>
		<description><![CDATA[Originally posted at The Pythian Group blog. I’m back again with another in what I hope will be a long line of “Quick Tips for Newbies” series. At The Pythian Group, we have employees all over the globe, from our headquarters in Ottawa to regional offices in Boston, Prague, India and Sydney, and a few [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=420&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted at <a href="http://www.pythian.com/news/1976/sending-timezone-aware-email-with-utl_smtp">The Pythian Group blog</a>.</em></p>
<p>I’m back again with another in what I hope will be a long line of “Quick Tips for Newbies” series.</p>
<p>At The Pythian Group, we have employees all over the globe, from our headquarters in Ottawa to regional offices in Boston, Prague, India and Sydney, and a few scattered remote workers in Seattle, Paris, Kiev, Brazil, South Africa and Wisconsin, among other places. In other words, we are spread across multiple timezones, and since it wasn’t too long ago that everyone was in Ottawa, this is something that still presents little quirks.</p>
<p>One such quirk involved email generated by one of our internal Oracle instances—via a stored procedure that used <code>UTL_SMTP</code> to send the messages—did not have timezone information in the “Date” email header. As a result, they would be stamped with the hour in Eastern timezone (Ottawa time), but the mail clients would think that hour was local. Depending on where you are relative to Ottawa, this could be many hours in the past or future. Of course, this wouldn’t be noticed if you were in Ottawa or even Boston, both in Eastern. For the rest, it was at the very least, an annoyance—but one that is easily fixed.</p>
<p><span id="more-1976"> </span></p>
<p>Looking at the PL/SQL stored procedure that we used to generate email messages, I saw that the “Date” header was being built with this code:</p>
<p><pre class="brush: sql;">date_hdr := 'Date: '||to_char(sysdate,'dd Mon yy hh24:mi:ss');</pre></p>
<p>The fix is almost trivial—just use <code>SYSTIMESTAMP</code> instead of <code>SYSDATE</code>, and include the timezone in the <code>TO_CHAR</code> function:</p>
<p><pre class="brush: sql;">date_hdr := 'Date: '||to_char(systimestamp,'dd Mon yy hh24:mi:ss tzhtzm');</pre></p>
<p>Voila!  Emails now had a full Date header. And there was much rejoicing from around the world.</p>
<p>Here’s a quick query to highlight the difference:<br />
<pre class="brush: sql;">
SQL&gt; select to_char(sysdate,'dd Mon yy hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'D
------------------
01 Dec 08 18:50:02

SQL&gt; select to_char(systimestamp,'dd Mon yy hh24:mi:ss tzhtzm') from dual;

TO_CHAR(SYSTIMESTAMP,'DD
------------------------
01 Dec 08 18:50:10 -0500
</pre><br />
Even if you aren’t sending email to all the ends of the Earth, it won’t hurt to make your messages timezone-aware. I’m sure it will save some confusion and frustration down the line.</p>
<p><em>Note: I discovered the fix via <a href="http://hidowb.blogspot.com/2008/04/time-zone-and-header-in-emails-using.html">this blog post</a>, which seems to be invite-only at the time of this writing.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seilerwerks.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seilerwerks.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seilerwerks.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seilerwerks.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seilerwerks.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seilerwerks.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seilerwerks.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seilerwerks.wordpress.com/420/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seilerwerks.wordpress.com&amp;blog=2020677&amp;post=420&amp;subd=seilerwerks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seilerwerks.wordpress.com/2009/08/19/sending-timezone-aware-email-with-utl_smtp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0a26f7f3e30943f45acff81cd87feba6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Don</media:title>
		</media:content>
	</item>
	</channel>
</rss>
