<?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>ray_apps_blog &#187; mac</title>
	<atom:link href="http://blog.rayapps.com/category/mac/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rayapps.com</link>
	<description>About Ruby, Oracle, Mac and others</description>
	<lastBuildDate>Mon, 21 Jun 2010 14:02:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.rayapps.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0dbc428d172e04af3f6bb51ac225001b?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>ray_apps_blog &#187; mac</title>
		<link>http://blog.rayapps.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.rayapps.com/osd.xml" title="ray_apps_blog" />
	<atom:link rel='hub' href='http://blog.rayapps.com/?pushpress=hub'/>
		<item>
		<title>How to install Oracle Database 10g on Mac OS X Snow Leopard</title>
		<link>http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard/</link>
		<comments>http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 22:25:38 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://rayapps.wordpress.com/?p=106</guid>
		<description><![CDATA[Oracle Database 10g is not yet officially supported on new Mac OS X 10.6 Snow Leopard but thanks to comments at my previous tutorial I managed to do Oracle 10g installation on fresh Mac OS X Snow Leopard. If you have upgraded from Leopard with Oracle 10g installation to Snow Leopard then most probably Oracle [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=106&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://rayapps.files.wordpress.com/2009/09/sl_oracle.jpg?w=250&#038;h=133" alt="sl_oracle.jpg" border="0" width="250" height="133" align="right">Oracle Database 10g is not yet officially supported on new Mac OS X 10.6 Snow Leopard but thanks to comments at my <a href="http://blog.rayapps.com/2009/04/12/how-to-install-oracle-database-10g-on-mac-os-x-intel/">previous tutorial</a> I managed to do Oracle 10g installation on fresh Mac OS X Snow Leopard.</p>
<p>If you have upgraded from Leopard with Oracle 10g installation to Snow Leopard then most probably Oracle 10g should work fine and you should not do anything. These instructions are just for fresh installation of Snow Leopard.</p>
<p>And also please take in mind that Oracle 10g on Snow Leopard is not supported yet by Oracle and therefore please do not run critical production applications on it :)</p>
<p>So here are my updated Oracle 10g installation instructions for Snow Leopard.</p>
<h3>Initial preparation</h3>
<p>At first you need Xcode tools installed on your Mac OS X.</p>
<p>Then you need to create oracle user as well as increase default kernel parameters. Open Terminal and switch to root user:</p>
<pre>sudo -i</pre>
<p>Create oinstall group and oracle user (I used group and user number 600 to ensure that they do not collide with existing groups and users):</p>
<pre>dscl . -create /groups/oinstall
dscl . -append /groups/oinstall gid 600
dscl . -append /groups/oinstall passwd "*"</pre>
<pre>dscl . -create /users/oracle
dscl . -append /users/oracle uid 600
dscl . -append /users/oracle gid 600
dscl . -append /users/oracle shell /bin/bash
dscl . -append /users/oracle home /Users/oracle
dscl . -append /users/oracle realname "Oracle software owner"
mkdir /Users/oracle
chown oracle:oinstall /Users/oracle</pre>
<p>Change password for oracle user:</p>
<pre>passwd oracle</pre>
<p>Change default kernel parameters:</p>
<pre>vi /etc/sysctl.conf</pre>
<p>and enter values recommended by Oracle:</p>
<pre>kern.sysv.semmsl=87381
kern.sysv.semmns=87381
kern.sysv.semmni=87381
kern.sysv.semmnu=87381
kern.sysv.semume=10
kern.sysv.shmall=2097152
kern.sysv.shmmax=2197815296
kern.sysv.shmmni=4096
kern.maxfiles=65536
kern.maxfilesperproc=65536
net.inet.ip.portrange.first=1024
net.inet.ip.portrange.last=65000
kern.corefile=core
kern.maxproc=2068
kern.maxprocperuid=2068</pre>
<p>Oracle DB installation scripts have reference to Java version 1.4.2 which is not present on Snow Leopard. The easiest way to fix it is to create symbolic link to newer version of Java:</p>
<pre>sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2</pre>
<p>After this reboot your computer so that these new kernel parameters would be taken into effect.</p>
<p>After reboot you need to log in as new &#8220;Oracle software owner&#8221; user (as now Snow Leopard has stricter control for access to X11 display and therefore I couldn&#8217;t manage to start Oracle installation just from terminal).</p>
<p>Open Terminal application and set shell settings in .bash_profile</p>
<pre>vi .bash_profile</pre>
<p>and enter</p>
<pre>export DISPLAY=:0.0
export ORACLE_BASE=$HOME
umask 022
ulimit -Hn 65536
ulimit -Sn 65536</pre>
<p>As you see I prefer to install all Oracle related files under home directory of oracle user therefore I am setting ORACLE_BASE to home directory. And also include ulimit settings &#8211; I forgot to do this initially and got strange TNS service errors because of that.</p>
<p>Now execute this script so that these settings are applied to current shell:</p>
<pre>. ./.bash_profile</pre>
<p>Now download <a href="http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10204macsoft_x86-64.html">db.zip installation archive</a> and place it somewhere and unzip it:</p>
<pre>mkdir Install
cd Install
# download db.zip to this directory
unzip db.zip
cd db/Disk1</pre>
<p>Now you are ready to start installation. In Snow Leopard you need to pass -J-d32 option to installation script to force to run Java in 32-bit mode as some native libraries are 32-bit:</p>
<pre>./runInstaller -J-d32</pre>
<h3>Installation</h3>
<p>In installation wizard I selected the following options:</p>
<ul>
<li>Standard Edition &#8211; as I don&#8217;t need additional features of Enterprise Edition</li>
<li>Install Software Only &#8211; we will need to do some fixes before database creation</li>
</ul>
<p>In the middle of installation you will get error message &#8220;Error in invoking target &#8216;all_no_orcl ipc_g ihsodbc32&#8242; &#8230;&#8221; (message truncated). Please do not press anything and switch to Terminal application.</p>
<pre>cd ~/oracle/product/10.2.0/db_1/rdbms/lib
vi ins_rdbms.mk</pre>
<p>and in this file you need to search for line containing HSODBC_LINKLINE (in vi enter /HSODBC_LINKLINE) and comment out this line with putting # in front of it:</p>
<pre>#	$(HSODBC_LINKLINE)</pre>
<p>and save changed file.</p>
<p>In this way we disable failing compilation of library which is anyway not needed for our Oracle DB installation.</p>
<p>After that you can switch back to Oracle installation application and press Retry.</p>
<p>At the end of installation you will be instructed to run one shell script from root. To do that open new tab in Terminal and execute (substitute &#8220;username&#8221; with your login name):</p>
<pre>su - username
sudo /Users/oracle/oracle/product/10.2.0/db_1/root.sh</pre>
<p>Hopefully installation will complete successfully.</p>
<h3>Creation of database</h3>
<p>Switch back to Terminal tab with oracle user and add the following lines to .bash_profile of oracle user:</p>
<pre>export ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin</pre>
<p>and execute it</p>
<pre>. ~/.bash_profile</pre>
<p>Now you need to modify $ORACLE_HOME/jdk/bin/java script and change &#8220;&#8230;java -Xbootclasspath&#8230;&#8221; to &#8220;&#8230;java -d32 -Xbootclasspath&#8230;&#8221;. This is necessary to force netca and dbca utilities to run in 32-bit mode.</p>
<p>Now you need to do the major installation hack :) Unfortunately the main oracle executable binary when compiled under Snow Leopard is giving core dumps when starting Oracle database and currently the only way how I managed to fix it is to replace this executable file with the one which was compiled previously under Leopard. So you need to download it in trust me that it is correct :)</p>
<pre>cd $ORACLE_HOME/bin
curl -O http://rayapps.com/downloads/oracle_se.zip
unzip oracle_se.zip
chmod ug+s oracle
rm oracle_se.zip</pre>
<p>(If you installed Oracle Enterprise Edition then please substitute oracle_se.zip with oracle_ee.zip)</p>
<p>Now you can run Network Configuration Assistant</p>
<pre>netca</pre>
<p>and select all default options to create listener and wait until you get confirmation message that listener is configured and started.</p>
<p>After that you can run Database Configuration Assistant</p>
<pre>dbca</pre>
<p>and select</p>
<ul>
<li>Create a Database</li>
<li>General Purpose</li>
<li>Specify orcl as Global Database Name and SID (or set it to something different if you need)</li>
<li>Specify password for SYS and SYSTEM users</li>
<li>I selected also Sample Schemas</li>
<li>and in Character Sets I selected Use Unicode (AL32UTF8)</li>
</ul>
<p>At the end of installation I tried to use Password Management to unlock additional schemas but it didn&#8217;t work &#8211; so you need to unlock other sample schemas if needed using sqlplus.</p>
<p>At the end of installation verify if you can connect to newly created database</p>
<pre>sqlplus system@orcl</pre>
<p>I hope that my fixes will help you as well and you will be able to connect to database.</p>
<p>If you want to unlock other sample users then do it from sqlplus, e.g.:</p>
<pre>alter user hr account unlock identified by hr;</pre>
<p>Further instructions are the same as for Leopard and there are no more changes.</p>
<h3>Change listener to listen on localhost</h3>
<p>As I need this Oracle database just as local development database on my computer then I want to change the listener so that it would listen just on localhost port 1521:</p>
<pre>vi $ORACLE_HOME/network/admin/listener.ora</pre>
<p>and change it to:</p>
<pre>SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
    )
  )</pre>
<pre>LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )</pre>
<p>Then also change ORCL alias definition in $ORACLE_HOME/network/admin/tnsnames.ora to:</p>
<pre>ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )</pre>
<p>After this change restart listener and try to connect with sqlplus to verify that these changes are successful.</p>
<h3>Automatic startup of Oracle database</h3>
<p>If you want that Oracle database is started automatically when your computer is booted then you need to create the following startup script. Start terminal and switch to root.</p>
<p>At first edit /etc/oratab and change N to Y at the end of line for ORCL database &#8211; this will be used by dbstart utility to find which databases should be started automatically.</p>
<p>Then create startup script for Oracle database:</p>
<pre>mkdir /Library/StartupItems/Oracle
cd /Library/StartupItems/Oracle
vi Oracle</pre>
<p>and enter the following:</p>
<pre>#!/bin/sh</pre>
<pre># Suppress the annoying "$1: unbound variable" error when no option
# was given
if [ -z $1 ] ; then
  echo "Usage: $0 [start|stop|restart] "
  exit 1
fi</pre>
<pre># source the common startup script
. /etc/rc.common</pre>
<pre># Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for the installation
ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_HOME DYLD_LIBRARY_PATH</pre>
<pre># change the value of ORACLE to the login name of the
# oracle owner at your site
ORACLE=oracle</pre>
<pre>PATH=$PATH:$ORACLE_HOME/bin</pre>
<pre># Set shell limits for the Oracle Database
ulimit -Hu 2068
ulimit -Su 2068
ulimit -Hn 65536
ulimit -Sn 65536</pre>
<pre>StartService()
{
  ConsoleMessage "Starting Oracle Databases"
  su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
}</pre>
<pre>StopService()
{
  ConsoleMessage "Stopping Oracle Databases"
  su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
}</pre>
<pre>RestartService()
{
  StopService
  StartService
}</pre>
<pre>RunService "$1"</pre>
<p>and then make this script executable</p>
<pre>chmod a+x Oracle</pre>
<p>and in addition create properties file:</p>
<pre>vi StartupParameters.plist</pre>
<p>with the following contents:</p>
<pre>{
  Description     = "Oracle Database Startup";
  Provides        = ("Oracle Database");
  Requires        = ("Disks");
  OrderPreference = "None";
}</pre>
<p>Now you can verify that these scripts are working. Open new terminal and try</p>
<pre>sudo /Library/StartupItems/Oracle/Oracle stop</pre>
<p>to stop the database and</p>
<pre>sudo /Library/StartupItems/Oracle/Oracle start</pre>
<p>to start again the database. And later you can reboot your computer also to verify that Oracle database will be started automatically.</p>
<h3>Hide oracle user from login window</h3>
<p>After computer reboot you probably noticed that now you got oracle user in initial login window. To get rid of it execute this from terminal:</p>
<pre>sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add oracle</pre>
<h3>What next?</h3>
<p>Now when you have Oracle database installed you would need some development tools that you could use to access the database. Here are some links:</p>
<ul>
<li><a href="http://www.oracle.com/technology/products/database/sql_developer/index.html">Oracle SQL Developer</a> &#8211; free Oracle GUI tool that supports Mac OS X as well</li>
<li>If you would like to use Ruby and Ruby on Rails then check out my tutorial <a href="http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/">how to setup Ruby and Oracle client on Snow Leopard</a></li>
</ul>
<p>Please comment if you find any issues with Oracle Database 10g installation on Snow Leopard using this tutorial.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=106&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>141</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>

		<media:content url="http://rayapps.files.wordpress.com/2009/09/sl_oracle.jpg" medium="image">
			<media:title type="html">sl_oracle.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>How to setup Ruby and Oracle Instant Client on Snow Leopard</title>
		<link>http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/</link>
		<comments>http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 08:57:33 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rayapps.wordpress.com/?p=96</guid>
		<description><![CDATA[Introduction Mac OS X Snow Leopard is out and many Rubyists are rushing to upgrade to it. The main difference for Ruby after upgrading to Snow Leopard is that Ruby installation has been changed from 32-bit to 64-bit program and version has changed from 1.8.6 to 1.8.7. And it means that all Ruby gems with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=96&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Mac OS X Snow Leopard is out and many Rubyists are rushing to upgrade to it. The main difference for Ruby after upgrading to Snow Leopard is that Ruby installation has been changed from 32-bit to 64-bit program and version has changed from 1.8.6 to 1.8.7. And it means that all Ruby gems with C extensions should be reinstalled and recompiled using 64-bit external libraries.</p>
<p>After upgrading to Snow Leopard the first thing to do is to follow <a href="http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard">instructions on official Ruby on Rails blog</a>. After that follow instructions below.</p>
<h3>Installing 64-bit Oracle Instant Client for Intel Mac</h3>
<p>Download <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">Oracle Instant Client 64-bit version</a>. Download &#8220;Instant Client Package &#8211; Basic&#8221;, &#8220;Instant Client Package &#8211; SDK&#8221; and &#8220;Instant Client Package &#8211; SQL*Plus&#8221;.</p>
<p>Unzip downloaded archives and move it where you would like to have it &#8211; I am keeping it in /usr/local/oracle/instantclient_10_2 (if you have previous 32-bit Oracle Instant Client in this directory then delete it beforehand). Then go to this directory and make symbolic links for dynamic libraries</p>
<pre>
sudo ln -s libclntsh.dylib.10.1 libclntsh.dylib
sudo ln -s libocci.dylib.10.1 libocci.dylib
</pre>
<p>Then I recommend to create and place somewhere your tnsnames.ora file where you will keep your database connections definitions &#8211; I place this file in directory /usr/local/oracle/network/admin.</p>
<p>Then finally you need to set up necessary environment variables &#8211; I place the following definitions in my .bash_profile script:</p>
<pre>
export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
export SQLPATH="/usr/local/oracle/instantclient_10_2"
export TNS_ADMIN="/usr/local/oracle/network/admin"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH=$PATH:$DYLD_LIBRARY_PATH
</pre>
<p>Use your path to Oracle Instant Client if it differs from /usr/local/oracle/instantclient_10_2. And as you see I also define NLS_LANG environment variable &#8211; this is necessary if your database is not in UTF8 encoding but in Ruby you want to get UTF-8 encoded strings from the database. Specifying this NLS_LANG environment variable you will force that Oracle Instant Client will do character set translation.</p>
<p>After these steps relaunch Terminal application (so that new environment variables are set), specify database connection in tnsnames.ora file and try if you can access your database with sqlplus from command line.</p>
<h3>Install ruby-oci8 gem</h3>
<p>The latest versions of ruby-oci8 are available as Ruby gems and therefore I recommend to install it as a gem and not to compile and install as library (as I have recommended previously in my blog).</p>
<p>If you previously installed ruby-oci8 as a library then I recommend to delete it from Ruby installation. Go to /usr/lib/ruby/site_ruby/1.8 directory and remove oci8.rb file as well as remove oci8lib.bundle compiled library from either universal-darwin9.0 or universal-darwin10.0 subdirectory.</p>
<p>Now install ruby-oci8 with the following command:</p>
<pre>
sudo env DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH ARCHFLAGS="-arch x86_64" gem install ruby-oci8
</pre>
<p>It is important to pass DYLD_LIBRARY_PATH environment variable to sudo (as otherwise ruby-oci8 gem installation will not find Oracle Instant Client) as well as specify ARCHFLAGS to compile C extension just for 64-bit platform as otherwise it will try to compile both for 32-bit and 64-bit platform.</p>
<p>Now try</p>
<pre>
ruby -rubygems -e "require 'oci8'; OCI8.new('scott','tiger','orcl').exec('select * from dual') do |r| puts r.join(','); end"
</pre>
<p>or similar (replacing username, password or database alias) to verify that you can access Oracle database from ruby.</p>
<p>That&#8217;s it! Please write in comments if something is not working according to these instructions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=96&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>
	</item>
		<item>
		<title>How to install Oracle Database 10g on Mac OS X Intel</title>
		<link>http://blog.rayapps.com/2009/04/12/how-to-install-oracle-database-10g-on-mac-os-x-intel/</link>
		<comments>http://blog.rayapps.com/2009/04/12/how-to-install-oracle-database-10g-on-mac-os-x-intel/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 13:48:19 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://rayapps.wordpress.com/?p=74</guid>
		<description><![CDATA[UPDATE: Created instructions how to install Oracle 10g on Mac OS X Snow Leopard Couple days ago Oracle developers on Mac OS X received Easter present &#8211; finally Oracle Database 10g was released for Mac OS X 10.5 Intel platform. This download includes installation guide for Mac OS X but as any Oracle installation guide [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=74&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<h4>UPDATE: <a href="http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard/">Created instructions how to install Oracle 10g on Mac OS X Snow Leopard</a><br />
</h4>
<p>Couple days ago Oracle developers on Mac OS X received Easter present &#8211; finally <a href="http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10204macsoft_x86-64.html">Oracle Database 10g was released for Mac OS X 10.5 Intel platform</a>. This download includes installation guide for Mac OS X but as any Oracle installation guide it is quite long and contains a lot of unnecessary information for first time install as well as does not contain some necessary information.</p>
<p>Therefore I am posting here my shorter tutorial how to install it. And this tutorial is targeted to developers who want to install local Oracle database for development needs on their MacBook, iMac or Mac Pro.</p>
<h3>Initial preparation</h3>
<p>If you are a developer then I suppose you already have Xcode tools installed which are required also for Oracle installation. And I tried these steps on Mac OS X latest version 10.5.6.</p>
<p>Then you need to create oracle user as well as increase default kernel parameters. Open Terminal and switch to root user:</p>
<pre>sudo -i</pre>
<p>Create oinstall group and oracle user (I used group and user number 600 to ensure that they do not collide with existing groups and users):</p>
<pre>dscl . -create /groups/oinstall
dscl . -append /groups/oinstall gid 600
dscl . -append /groups/oinstall passwd "*"</pre>
<pre>dscl . -create /users/oracle
dscl . -append /users/oracle uid 600
dscl . -append /users/oracle gid 600
dscl . -append /users/oracle shell /bin/bash
dscl . -append /users/oracle home /Users/oracle
dscl . -append /users/oracle realname "Oracle software owner"
mkdir /Users/oracle
chown oracle:oinstall /Users/oracle</pre>
<p>Change password for oracle user:</p>
<pre>passwd oracle</pre>
<p>Change default kernel parameters:</p>
<pre>vi /etc/sysctl.conf</pre>
<p>and enter values recommended by Oracle:</p>
<pre>kern.sysv.semmsl=87381
kern.sysv.semmns=87381
kern.sysv.semmni=87381
kern.sysv.semmnu=87381
kern.sysv.semume=10
kern.sysv.shmall=2097152
kern.sysv.shmmax=2197815296
kern.sysv.shmmni=4096
kern.maxfiles=65536
kern.maxfilesperproc=65536
net.inet.ip.portrange.first=1024
net.inet.ip.portrange.last=65000
kern.corefile=core
kern.maxproc=2068
kern.maxprocperuid=2068</pre>
<p>After this reboot your computer so that these new kernel parameters would be taken into effect. After reboot open again Terminal and now login as oracle user:</p>
<pre>su - oracle</pre>
<p>Set shell settings in .bash_profile</p>
<pre>vi .bash_profile</pre>
<p>and enter</p>
<pre>export DISPLAY=:0.0
export ORACLE_BASE=$HOME
umask 022
ulimit -Hn 65536
ulimit -Sn 65536</pre>
<p>As you see I prefer to install all Oracle related files under home directory of oracle user therefore I am setting ORACLE_BASE to home directory. And also include ulimit settings &#8211; I forgot to do this initially and got strange TNS service errors because of that.</p>
<p>Now execute this script so that these settings are applied to current shell:</p>
<pre>. ./.bash_profile</pre>
<p>Now download <a href="http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10204macsoft_x86-64.html">db.zip installation archive</a> and place it somewhere and unzip it:</p>
<pre>mkdir Install
cd Install
# download db.zip to this directory
unzip db.zip
cd db/Disk1</pre>
<p>Now you are ready to start installation:</p>
<pre>./runInstaller</pre>
<h3>Installation</h3>
<p>In installation wizard I selected the following options:</p>
<ul>
<li>Advanced Installation &#8211; so that I can change some default options</li>
<li>Standard Edition &#8211; as I don&#8217;t need additional features of Enterprise Edition</li>
<li>Create Database / General Purpose</li>
<li>Global database name: orcl, SID: orcl</li>
<li>Character set: UTF-8 AL32UTF8</li>
<li>Create database with sample schemas</li>
<li>Selected &#8220;Use the same password for all the accounts&#8221; &#8211; do not specify default &#8220;manager&#8221; password as it will not be allowed :)</li>
<li>Password Management &#8211; selected this to unlock necessary sample accounts (e.g. HR schema account that I use as default test schema)</li>
</ul>
<p>At the end of installation you will be instructed to run one shell script from root.<br />
Hopefully installation will complete successfully.</p>
<h3>Additional oracle user settings</h3>
<p>If you will use oracle user later then add the following lines to .bash_profile of oracle user:</p>
<pre>export ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_SID=ORCL
PATH=$PATH:$ORACLE_HOME/bin</pre>
<p>After this relogin as oracle user and verify listener status:</p>
<pre>lsnrctl status</pre>
<p>and if it is down then start it with</p>
<pre>lsnrctl start</pre>
<p>and verify if you can connect to Oracle database with sample user (that I unlocked during installation)</p>
<pre>sqlplus hr/hr@orcl</pre>
<p>If it fails then do some investigation :)</p>
<h3>Change listener to listen on localhost</h3>
<p>As I need this Oracle database just as local development database on my computer then I want to change the listener so that it would listen just on localhost port 1521:</p>
<pre>vi $ORACLE_HOME/network/admin/listener.ora</pre>
<p>and change the contents of the file to:</p>
<pre>SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
    )
  )</pre>
<pre>LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )</pre>
<p>Then also change ORCL alias definition in $ORACLE_HOME/network/admin/tnsnames.ora to:</p>
<pre>ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )</pre>
<p>After this change restart listener and try to connect with sqlplus to verify that these changes are successful.</p>
<h3>Automatic startup of Oracle database</h3>
<p>If you want that Oracle database is started automatically when your computer is booted then you need to create the following startup script. Start terminal and switch to root.</p>
<p>At first edit /etc/oratab and change N to Y at the end of line for ORCL database &#8211; this will be used by dbstart utility to find which databases should be started automatically.</p>
<p>Then create startup script for Oracle database:</p>
<pre>mkdir /Library/StartupItems/Oracle
cd /Library/StartupItems/Oracle
vi Oracle</pre>
<p>and enter the following:</p>
<pre>#!/bin/sh</pre>
<pre># Suppress the annoying "$1: unbound variable" error when no option
# was given
if [ -z $1 ] ; then
  echo "Usage: $0 [start|stop|restart] "
  exit 1
fi</pre>
<pre># source the common startup script
. /etc/rc.common</pre>
<pre># Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for the installation
ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_HOME DYLD_LIBRARY_PATH</pre>
<pre># change the value of ORACLE to the login name of the
# oracle owner at your site
ORACLE=oracle</pre>
<pre>PATH=$PATH:$ORACLE_HOME/bin</pre>
<pre># Set shell limits for the Oracle Database
ulimit -Hu 2068
ulimit -Su 2068
ulimit -Hn 65536
ulimit -Sn 65536</pre>
<pre>StartService()
{
  ConsoleMessage "Starting Oracle Databases"
  su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
}</pre>
<pre>StopService()
{
  ConsoleMessage "Stopping Oracle Databases"
  su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
}</pre>
<pre>RestartService()
{
  StopService
  StartService
}</pre>
<pre>RunService "$1"</pre>
<p>and then make this script executable</p>
<pre>chmod a+x Oracle</pre>
<p>and in addition create properties file:</p>
<pre>vi StartupParameters.plist</pre>
<p>with the following contents:</p>
<pre>{
  Description     = "Oracle Database Startup";
  Provides        = ("Oracle Database");
  Requires        = ("Disks");
  OrderPreference = "None";
}</pre>
<p>Now you can verify that these scripts are working. Open new terminal and try</p>
<pre>sudo /Library/StartupItems/Oracle/Oracle stop</pre>
<p>to stop the database and</p>
<pre>sudo /Library/StartupItems/Oracle/Oracle start</pre>
<p>to start again the database. And later you can reboot your computer also to verify that Oracle database will be started automatically.</p>
<h3>Hide oracle user from login window</h3>
<p>After computer reboot you probably noticed that now you got oracle user in initial login window. To get rid of it execute this from terminal:</p>
<pre>sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add oracle</pre>
<h3>What next?</h3>
<p>Now when you have Oracle database installed you would need some development tools that you could use to access the database. Here are some links:</p>
<ul>
<li><a href="http://www.oracle.com/technology/products/database/sql_developer/index.html">Oracle SQL Developer</a> &#8211; free Oracle GUI tool that supports Mac OS X as well</li>
<li>If you would like to use Ruby and Ruby on Rails then check out my tutorial <a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/">how to setup Ruby and Oracle client</a></li>
<li>If you would like to use PHP then <a href="http://www.oracle.com/technology/pub/articles/bibbs-php-leopard.html">you can check out this tutorial</a></li>
</ul>
<p>Please comment if you find any issues with Oracle Database 10g installation using this tutorial.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=74&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2009/04/12/how-to-install-oracle-database-10g-on-mac-os-x-intel/feed/</wfw:commentRss>
		<slash:comments>104</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>
	</item>
		<item>
		<title>Using mod_rails with Rails applications on Oracle</title>
		<link>http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/</link>
		<comments>http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/#comments</comments>
		<pubDate>Wed, 21 May 2008 21:49:47 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rayapps.wordpress.com/?p=28</guid>
		<description><![CDATA[As many others I also got interested in new mod_rails deployment solution for Rails applications. And when I read how to use it for development environment needs I decided to try it out. As you probably know I am using Mac for development and using Oracle database for many Rails applications. So if you do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=28&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>As many others I also got interested in new <a href="http://modrails.com/">mod_rails</a> deployment solution for Rails applications. And when I read <a href="http://nubyonrails.com/articles/ask-your-doctor-about-mod_rails">how to use it for development environment needs</a> I decided to try it out.</p>
<p>As you probably know I am using Mac for development and using Oracle database for many Rails applications. So if you do it as well then at first you need to <a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/">setup Ruby and Oracle on your Mac</a>.</p>
<p>After that I installed and did setup of mod_rails according to <a href="http://www.fngtps.com/2008/04/using-passenger-on-osx-for-rails-development">these instructions</a> and <a href="http://nubyonrails.com/articles/ask-your-doctor-about-mod_rails">these additional notes</a>.</p>
<p>One additional thing that I had to do was to change the user which will be used to run Apache httpd server as otherwise default www user did not see my Rails applications directories. You should do it in /etc/apache2/httpd.conf:</p>
<pre>
User yourusername
Group yourusername
</pre>
<p>And then I started to fight with the issue that ruby which was started from mod_rails could not load ruby-oci8 library as it could not find Oracle Instant Client shared library. And the reason for that was that mod_rails launched ruby with very minimal list of environment variables. E.g. as DYLD_LIBRARY_PATH environment variable was not specified then ruby-oci8 could not find Oracle Instant Client libraries.</p>
<p>The issue is that there is no documented way how to pass necessary environment variables to mod_rails. Unfortunately mod_rails is ignoring SetEnv settings from Apache httpd.conf file. Therefore I needed to find some workaround for the issue and finally I did the following solution.</p>
<p>I created executable script file /usr/local/bin/ruby_with_env:</p>
<pre>
#!/bin/bash
export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2:$DYLD_LIBRARY_PATH"
export SQLPATH=$DYLD_LIBRARY_PATH
export TNS_ADMIN="/usr/local/oracle/network/admin"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
/usr/bin/ruby $*
</pre>
<p>and then in Apache httpd.conf file I changed RailsRuby line to</p>
<pre>
RailsRuby /usr/local/bin/ruby_with_env
</pre>
<p>As a result in this way I was able to specify necessary environment variables before Ruby and Rails was started and after this change ruby-oci8 libraries were successfully loaded.</p>
<p>You can use this solution also on Linux hosts where you will deploy Rails applications in production.</p>
<p>Currently I still have issue with mod_rails that it fails to execute RMagick library methods (which is compiled with ImageMagick). I get strange errors in Apache error_log:</p>
<pre>
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
[error] [client ::1] Premature end of script headers:
</pre>
<p>When I was running the same application with Mongrel then everything was running correctly. If anyone has any ideas what could be the reason please write some comment.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rayapps.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rayapps.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=28&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>
	</item>
		<item>
		<title>How to setup Ruby and new Oracle Instant Client on Leopard</title>
		<link>http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/</link>
		<comments>http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 11:52:22 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rayapps.wordpress.com/?p=24</guid>
		<description><![CDATA[!!! Update !!! New version of instructions for Snow Leopard is available here. Introduction We waited for it long, long time and finally it has arrived &#8211; Oracle Instant Client for Intel Mac. I was lucky to test beta version of the client already for the last couple of weeks and so far everything was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=24&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<h3>!!! Update !!!</h3>
<p><a href="http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/">New version of instructions for Snow Leopard is available here.</a></p>
<h3>Introduction</h3>
<p>We waited for it long, long time and finally it has arrived &#8211; <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">Oracle Instant Client for Intel Mac</a>. I was lucky to test beta version of the client already for the last couple of weeks and so far everything was working OK. Therefore as the final version is now available to everybody I am here rewriting <a href="http://blog.rayapps.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/">my previous instructions</a> on how to get Ruby working with Oracle on Mac.</p>
<h3>Installing Oracle Instant Client for Intel Mac</h3>
<p>At first you need to <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">download Oracle Instant Client for Intel Mac</a>. Download &#8220;Instant Client Package &#8211; Basic&#8221; and &#8220;Instant Client Package &#8211; SDK&#8221; and also I suggest &#8220;Instant Client Package &#8211; SQL*Plus&#8221; if you would like to have command line sqlplus utility.</p>
<p>Unzip downloaded archives and move it where you would like to have it &#8211; I am keeping it in /usr/local/oracle/instantclient_10_2. Then go to this directory and make symbolic links for dynamic libraries</p>
<pre>
sudo ln -s libclntsh.dylib.10.1 libclntsh.dylib
sudo ln -s libocci.dylib.10.1 libocci.dylib
</pre>
<p>Then I recommend to create and place somewhere your tnsnames.ora file where you will keep your database connections definitions &#8211; I place this file in directory /usr/local/oracle/network/admin.</p>
<p>Then finally you need to set up necessary environment variables &#8211; I place the following definitions in my .bash_profile script:</p>
<pre>
export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
export SQLPATH="/usr/local/oracle/instantclient_10_2"
export TNS_ADMIN="/usr/local/oracle/network/admin"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH=$PATH:$DYLD_LIBRARY_PATH
</pre>
<p>Use your path to Oracle Instant Client if it differc from /usr/local/oracle/instantclient_10_2. And as you see I also define NLS_LANG environment variable &#8211; this is necessary if your database is not in UTF8 encoding but in Ruby you want to get UTF-8 encoded strings from the database. Specifying this NLS_LANG environment variable you will force that Oracle Instant Client will do character set translation.</p>
<p>After these steps relaunch Terminal application (so that new environment variables are set), specify database connection in tnsnames.ora file and try if you can access your database with sqlplus from command line.</p>
<h3>Ruby installation</h3>
<p>If you are using Leopard then I assume that you are using preinstalled Ruby which is the simplest option. I tried to compile Ruby from sources on Mac OS X Leopard but when I compared performance then original Ruby was a little bit faster on some benchmarks and therefore I sticked with original one.</p>
<h3>Compile and install ruby-oci8</h3>
<p>Download the latest version of <a href="http://rubyforge.org/projects/ruby-oci8/">ruby-oci8</a> (version 1.0.0 at time of writing this post).</p>
<p>As Oracle Instant Client is available just for Intel i386 architecture you need to change in file /usr/lib/ruby/1.8/universal-darwin9.0/rbconfig.rb line 17 to:</p>
<pre>
'-arch i386'
</pre>
<p>Then go to directory where you extracted ruby-oci8 source and execute ruby-oci8 standard installation sequence:</p>
<pre>
ruby setup.rb config
make
sudo make install
</pre>
<p>After that you can change back file /usr/lib/ruby/1.8/universal-darwin9.0/rbconfig.rb line 17 to:</p>
<pre>
'-arch ppc -arch i386'
</pre>
<p>Now try</p>
<pre>
ruby -r oci8 -e "OCI8.new('scott', 'tiger','orcl').exec('select * from emp') do |r| puts r.join(','); end"
</pre>
<p>or similar to verify that you can access Oracle database from ruby.</p>
<p>That&#8217;s it! Please write in comments if something is not working according to these instructions.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rayapps.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rayapps.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=24&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>
	</item>
		<item>
		<title>Video from Euruko 2008</title>
		<link>http://blog.rayapps.com/2008/04/05/video-from-euruko-2008/</link>
		<comments>http://blog.rayapps.com/2008/04/05/video-from-euruko-2008/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 21:22:03 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rayapps.wordpress.com/?p=23</guid>
		<description><![CDATA[I made short video from Euruko 2008 conference where you can see Matz, Koichi, JRuby guys, DrNic ar me as well :) I posted my presentation slides in my previous post.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=23&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I made <a href="http://ruby.lv/files/Euruko_2008.m4v">short video from Euruko 2008 conference</a> where you can see Matz, Koichi, JRuby guys, DrNic ar me as well :)</p>
<p><span style='text-align:center;display:block;'><object width='400' height='330' type='application/x-shockwave-flash' data='http://video.google.com/googleplayer.swf?docId=-1237678620877495277'><param name='allowScriptAccess' value='never' /><param name='movie' value='http://video.google.com/googleplayer.swf?docId=-1237678620877495277'/><param name='quality' value='best'/><param name='bgcolor' value='#ffffff' /><param name='scale' value='noScale' /><param name='wmode' value='opaque' /></object></span></p>
<p>I posted my presentation slides in my <a href="http://blog.rayapps.com/2008/04/03/my-presentation-on-using-ruby-with-oracle-at-euruko-conference/">previous post</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rayapps.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rayapps.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=23&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2008/04/05/video-from-euruko-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>
	</item>
		<item>
		<title>How to setup Ruby and Oracle client on Intel Mac</title>
		<link>http://blog.rayapps.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/</link>
		<comments>http://blog.rayapps.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/#comments</comments>
		<pubDate>Sun, 26 Aug 2007 23:01:22 +0000</pubDate>
		<dc:creator>Raimonds Simanovskis</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.rayapps.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/</guid>
		<description><![CDATA[!!! Update !!! New version of this instruction for Intel Macs with Leopard is available here. New version of instructions for Snow Leopard is available here. Introduction I have been using Oracle technologies for many years but just some time ago discovered Ruby and Rails. As I had ideas how to make Ruby on Rails [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=10&subd=rayapps&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<h3>!!! Update !!!</h3>
<p><a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/">New version of this instruction for Intel Macs with Leopard is available here.</a></p>
<p><a href="http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/">New version of instructions for Snow Leopard is available here.</a></p>
<h3>Introduction</h3>
<p>I have been using Oracle technologies for many years but just some time ago discovered Ruby and Rails. As I had ideas how to make Ruby on Rails frontends for existing Oracle based systems I started to explore how to use Ruby on Rails together with Oracle databases.</p>
<p>Just recently I switched from PC notebook to MacBook Pro and unfortunately found out that <a href="http://forums.oracle.com/forums/thread.jspa?threadID=481059">Oracle Instant Client is not yet released for Intel Macs</a>. As there is no promise when it will be released and as I could not wait for that I decided to make old <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/macsoft.html">PowerPC version of Oracle Instant Client</a> to run on Intel Mac.  As I didn&#8217;t find any good description how to do that I decided to write description of it by myself &#8211; hopefully it will help others.</p>
<h3>Universal or &#8220;fat&#8221; binary Ruby</h3>
<p>The first thing is that you need to get &#8220;universal&#8221; or &#8220;fat&#8221; binary installation of Ruby &#8211; it means that it contains both Intel and PowerPC (PPC) binary code. You will need PPC version of Ruby when you will work with Oracle and you will need Intel version of Ruby when you will do other things. PPC code is running in emulation mode on Intel processors and therfore is slower as well as there are some compatibility issues with some other libraries (I will mention later what issues I found out).</p>
<p>It is possible to get and install precompiled Ruby either from <a href="http://www.macports.org/">MacPorts</a> or using <a href="http://rubyosx.rubyforge.org/">Ruby One-Click Installer</a>. But I prefer to compile Ruby from source code as it gives me more control what is installed and where. I used <a href="http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx">Hivelogic guide</a> to compile Ruby from source code.</p>
<p>Here are my additional notes what I changed to Hivelogic guide to make &#8220;fat&#8221; binaries.</p>
<h3>Installing &#8220;readline&#8221;</h3>
<p>At first you need to install &#8220;readline&#8221; shared libraries. At first I tried to make them from &#8220;readline&#8221; library source code but I always got just Intel binaries. Therefore I found and downloaded &#8220;readline&#8221; library <a href="http://downloads.sourceforge.net/rudix/readline-5.2-8universal.dmg?modtime=1185921225&amp;big_mirror=0">installer package</a> with universal binaries and installed it. If you previously installed Intel binary of &#8220;readline&#8221; library then it is better to restart Mac to ensure that new dynamic library will be loaded.</p>
<h3>Compiling Ruby</h3>
<p>Next you need to download and extract Ruby 1.8.6 source code.</p>
<p>Before running &#8220;configure&#8221; command I made the following change in &#8220;configure&#8221; file:</p>
<pre># Choose a default set of architectures based upon platform.
case "$target_os" in
darwin*)
    TARGET_ARCHS="<strong>ppc i386</strong>"
    ;;</pre>
<p>You can specify this also on command line but this change ensures that you will not forget it :) Then you need to run &#8220;configure&#8221; script with additional parameter at the end:</p>
<pre>./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local \
--enable-shared --enable-fat-binary</pre>
<p>After running &#8220;make&#8221; hopefully you will get everything compiled and you should get &#8220;fat&#8221; ruby binary. You can verify it with the following command and should see the following result:</p>
<pre>$ file ruby
ruby: Mach-O universal binary with 2 architectures
ruby (for architecture ppc):    Mach-O executable ppc
ruby (for architecture i386):   Mach-O executable i386</pre>
<p>If you do not see that ruby binary contains both ppc and i386 executables then something went wrong. If it is OK then you can do &#8220;sudo make install&#8221; to install binaries in target directories.</p>
<h3>Make PPC and &#8220;fat&#8221; versions of Ruby</h3>
<p>As you will need to be able to force to run PPC version of Ruby later then we need to extract PPC executable in a separate file and store original &#8220;fat&#8221; binary in another file:</p>
<pre>ditto -arch ppc /usr/local/bin/ruby /usr/local/bin/ruby_ppc
mv /usr/local/bin/ruby /usr/local/bin/ruby_fat</pre>
<p>Then I recommend to create simple scripts that will help you to switch between &#8220;fat&#8221; and PPC versions of Ruby:</p>
<p>ppc_ruby.sh:</p>
<pre>#!/bin/bash
sudo ln -fs /usr/local/bin/ruby_ppc /usr/local/bin/ruby</pre>
<p>fat_ruby.sh:</p>
<pre>#!/bin/bash
sudo ln -fs /usr/local/bin/ruby_fat /usr/local/bin/ruby</pre>
<p>So when you need to have PPC version of Ruby then run &#8220;ppc_ruby.sh&#8221; script and when you need &#8220;fat&#8221; version (which will actually run Intel binary) then run &#8220;fat_ruby.sh&#8221; script.</p>
<h3>Install Oracle Instant Client for PPC</h3>
<p>Install Oracle Instant Client according to the <a href="http://creativi.st/blog/articles/2005/06/25/rails-oracle-client-on-mac-os-x">following description</a>.</p>
<h3>Compile and install ruby-oci8</h3>
<p>I used the <a href="http://blog.sven-tissot.de/files/ror_and_oracle.html">following description</a> as a basis but some additional changes were needed for ruby-oci8-1.0.0-rc3 compilation.</p>
<p>Open ruby-oci8 README file and find section &#8220;=== Intel Mac&#8221;  where are described what to do to compile ruby-oci8 on Intel Mac.</p>
<p>Before running any ruby scripts you need to run ppc_ruby.sh script to switch to PPC binary.</p>
<p>If you compiled &#8220;fat&#8221; Ruby from source code then you need to modify file /usr/local/lib/ruby/1.8/fat-darwin8.10.1/rbconfig.rb according to README file (make backup of file before modifications). If you installed Ruby from binary distribution then find where is located your rbconfig.rb file.</p>
<ul>
<li>find lines with CONFIG["CFLAGS"] and CONFIG["LDFLAGS"] and CONFIG["ARCH_FLAG"]</li>
<li>remove &#8220;-arch i386&#8243; if present (was not present in my case)</li>
<li>and add &#8220;-arch ppc&#8221; to all of these lines.</li>
</ul>
<p>Make and install ruby-oci8 and if it finishes successfully then restore rbconfig.rb file from backup.</p>
<p>Try</p>
<pre>ruby -r oci8 -e "OCI8.new('scott', 'tiger','orcl').exec('select * from emp') do |r| puts r.join(','); end"</pre>
<p>or similar to verify that you can access Oracle database from ruby.</p>
<p>Congratulations! You have managed to connect to Oracle DB from Ruby on Intel Mac! If you got some issues at some point then please write it in comments and I will try to help with that.</p>
<h3>Post installation notes</h3>
<p>If you previously installed (or if you will install in future) any Ruby gems with native extensions (e.g. Mongrel or MySQL C API) then you need to reinstall these gems with &#8220;fat&#8221; Ruby (i.e. running &#8220;fat_ruby.sh&#8221; script and then &#8220;sudo gem install&#8221;). It will ensure that all gems will also have &#8220;fat&#8221; native extensions so that you can run them both in PPC Ruby and Intel Ruby.</p>
<h3>Known issues with PPC Ruby</h3>
<p>So far I have got the following issues with running PPC version of Ruby:</p>
<ul>
<li>Capistrano is failing to make SSH connection when running in PPC Ruby (I was testing with new Capistrano 2.0). Therefore you need always to switch to &#8220;fat&#8221; Ruby before running &#8220;cap deploy&#8221;.</li>
<li>As I also wanted that MySQL is running under PPC I got some issues with MySQL native extensions compilation &#8211; I solved them using the <a href="http://www.fatmixx.com/2007/05/30/ruby-mysql-gem-error/">following description</a>.</li>
<li>ruby-ldap connections were failing when running  in PPC Ruby within Ruby on Rails. I managed to fix it by putting &#8220;require ldap&#8221; as a first line in config/environment.rb file.</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rayapps.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rayapps.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rayapps.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rayapps.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rayapps.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rayapps.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rayapps.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rayapps.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rayapps.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rayapps.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rayapps.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rayapps.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.rayapps.com&blog=1589116&post=10&subd=rayapps&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.rayapps.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a94fbe334eb75d80da9dd0d3d352df1b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">elietas</media:title>
		</media:content>
	</item>
	</channel>
</rss>