One of my current work rails projects at SciMed Solutions has a requirement to use an Oracle database.
I just spent a frustrating day or so installing Oracle on my MacBook running the current Snow Leopard. One of my colleagues suggested this how-to blog article by Raimonds Simanovskis, to which all roads starting from a google search "install oracle snow leopard" seem to lead. He said it worked for him, with no problems not too many days before.
Not so for me. I'm not sure why, but I had lots of problems getting Oracle to create a database. First I ran into permissions problems, perhaps from missing something in Ray's excellent walk-through, then I had to deal with problems getting the Database Configuration Assistant to talk to the server when creating the first database.
I eventually found another article which gave the solution to this problem, once I figured out what it was saying, and where and when in the installation process to make the crucial patch.
So to document this, and hopefully save some frustration for others, here's what I did.
Background
As far as I know, the only version of Oracle for OS X which has ever been released is "Oracle Database 10g Release 2 (10.2.0.4.0) for MAC OS X on Intel x86-64" which was released shortly before Apple released Snow Leopard(10.6), and which won't work on OS X 10.6 without tweaks. The main source of information on these tweaks is Ray's blog article, but that article is nearly two years old at the time of this writing, and things have changes a bit in Snow Leopard since then.
My steps
- I already have Xcode installed. If you don't you'll need it.
- Follow along with the first steps of Ray's blog article, to create an oracle user, oinstall group, create a home directory for the oracle user, and set the oracle user's password, using the dscl, mkdir, chown, and passwd commands.
sudo -i dscl . -create /groups/oinstall dscl . -append /groups/oinstall gid 600 dscl . -append /groups/oinstall passwd "*" 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 passwd oracle - Again following Ray's article, edit /etc/sysctl.conf to add the kernel parameters recommended by Ray:
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 Note that using "sudo -i" in the prior step left the shell in sudo mode, you might prefer as I did, to use sudo for each command instead.
- Ray's next step, to create a symbolic link so that Java version 1.4.2 will resolve as Java version 1.5.0 is no longer needed nor desirable. Since the article was written, shortly after Snow Leopard release (possibly using a developer pre-release at that), OS X 10.6 already does that link albeit in a slightly less direct manner.
- Pro-Tip: I you haven't set it already, while you are still logged in as an admin user, you might want to use System Preferences>Accounts>Login Options, and turn on the "fast user switching menu" which lets you log in as multiple users without logging out from the existing user.
- Reboot to make the kernel parameter changes take effect, and then log in as the oracle user.
- Now I edited /Users/oracle/.bash_profile as directed by Ray. Actually I'm pretty sure you might as well go ahead and make the latter changes to this file as well at this point. I had to retry the installation several times, removing installed directories and such, but never altered .bash_profile again after the first time. So here is the full .bash_profile for the oracle user:
export DISPLAY=:0.0 export ORACLE_BASE=$HOME umask 022 ulimit -Hn 65536 ulimit -Sn 65536 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 - Next I executed the bash profile, alteratively you could open a new terminal window.
- The next step was to download the oracle software. The link in Ray's article is obsolete, you want "Oracle Database 10g Release 2 (10.2.0.4.0) for MAC OS X on Intel x86-64" which can be found here.
- Now unzip the db.zip file and cd to db/Disk1, as per Ray
- Now run the installer make sure you run it with the -J-d32 optionI kept forgetting this when I made my various attempts.
./runInstaller -J-d32 - You should see the error Ray mentions “Error in invoking target ‘all_no_orcl ipc_g ihsodbc32’ …” (message truncated). Follow his instructions, don't press any buttons in the warning dialog. Leave the installation program running, and edit the file ~/oracle/product/10.2.0/db_1/rdbms/lib. Find the line containing "$(HSODBC_LINKLINE)" and comment it out with a hash("#").
- Now we come to the patch in the second article, which fixes the ORA-03113 error when you try to create a database later. The oracle server is crashing because without this patch it's being built incorrectly for Snow Leopard, something you might never know from the error message unless you happened to look at ~/Library/Logs/CrashReporter in the OS X console app. The reason we needed to wait to edit this and the last file is that they are apparently created by the installer. I guess it's a lucky thing that the $(HSOBC_LINKLINE) problem is there, otherwise it would be much more difficult to fix this. So edit the file "$ORACLE_HOME/rdbms/lib/env_rdbms.mk" find the line which sets the variable ORACLE_LINKER, and insert the parameters "-mmacosx-version-min=10.5 -Wl,-no_compact_linkedit" after the -flat-namespace parameter so you end up with:
ORACLE_LINKER=gcc -flat_namespace -mmacosx-version-min=10.5 -Wl,-no_compact_linkedit $(OLAPPRELINKOPTS) $(LDFLAGS) $(COMPSOBJS) - Now go back to the installation program and press the retry button.
- At the end of the install process copy the command it asks you to run as root, which should be "/Users/oracle/oracle/product/10.2.0/db_1/root.sh". Then either in the same terminal window/tab or a new one use the su command to switch to your regular admin user with sudo privileges and run it the command by either pasting it or typing it after sudo:
su - username sudo /Users/oracle/oracle/product/10.2.0/db_1/root.sh Substitute your user name for username.
If you didn't open a new window or tab for this use the exit command to get back to the oracle user.
- You should now be at the "Creation of Database" step in Ray's how-to. We already made the additional changes to /Users/oracle/.bash_profile, so we can skip that step.
- You do need to modify $ORACLE_HOME/jdk/bin/java and add the -d32 parameter to the java command. This was another step which I forgot several times in my repeated re-tries, since it isn't really highlighted well enough in Ray's article for my aging eyesight.
- Now run netca and select all the default options as Ray suggests. Again, as I made my repeated attempts netca would tell me that the listener already existed, I then used netca to delete the listener and created it again. This is the kind of thing I'm trying to save you from by documenting these steps.
- Now run dbca and follow Ray's selections. through running sqlplus to verify that you can connect to the new database.
I haven't made any other of the changes in Ray's article, yet. But...
Giving access to Oracle from YOUR user
In order to get at the oracle database and use the oracle commands like sqlplus, you need to do two things:
- Set the same environment variables in your shell environment, either by adding them to .bash_profile, or whereever you set your shell environment variables. Again these are:
export ORACLE_BASE=$HOME 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 I don't think you need to export your X11 display, or use the umask and ulimit commands in your own profile, although I might be wrong.
- Add your user to the oinstall group.
This was another stumbling block, Snow Leopard introduced changes to user/group administration. The trick is to use the dseditgroup command
dseditgroup -o -edit -u `whoami` -p `whoami` -t user oinstall This should prompt you for your password, and add you to the group.
The Punchline
So now I can run the Oracle DB on my MBP, and I can access it from my login.
Then at the end of the day, I got an email saying that the representative data dump from the client's Oracle DB was available, but when I tried to import it using the oracle imp command, I got this.
IMP-00010: not a valid export file, header failed validation
Google tells me, and I have 99 44/100% confidence, that this is because the dump came from an Oracle 11g system, and as I pointed out at the top of this article the only version of Oracle that runs on the Mac is Oracle 10g. Oracle dumps are not compatible across versions. So back to the drawing board.
Don't you just love "Enterprise Quality" software?
Original article writen by Rick DeNatale and published on Talk Like A Duck | direct link to this article | If you are reading this article elsewhere than Talk Like A Duck, it has been illegally reproduced and without proper authorization.