Wednesday, November 28, 2007

Installing Oracle 10g Enterprise Edition on Ubuntu 7.10 gutsy gibbon

Snuzzle by chezmichelle from flickr (CC-NC)

As Trampoline Systems is doing "Enterprise" software we don't have a luxury of choosing whatever database we want (most likely mysql or postgresql, at least as far am I'm concerned), but need to support whichever database our customers use. I don't think there's any objective reason for customers being interested in database used by application any more than they should be interested in its programming language or ORM library, but for some reason the current tradition says that in "Enterprise" software applications can use any programming language and ORM they want, but the customer determines the database.

Now some people who never tried it claim that moving Rails application from one database to another is just a matter of a single line configuration change. How do I know they never tried it ? Because we did. At the very least it requires all tests to be run twice, once with mysql and the second time with Oracle. And number of things which work differently is just enormous. To make things worse most people here use Intel Macs, and there are not even Oracle clients for them, let alone servers, so when any problems happen they need to be fixed on a Linux server over ssh or on a borrowed Windows machine. It all works, but it's far from trivial.

Now since I wiped out OSX on my machine and installed Ubuntu, I thought I might be able to install Oracle 10g Enterprise Edition on it. Unfortunately Ubuntu is not an officially supported platform for Oracle, and Express Edition is apparently different enough that we don't want to use it. In the end it all worked quite less with just a little bit of hacking.

First you need to get Linux installer (10201_database_linux32.zip) and unpack it. The installer relies on some binaries being in /bin instead of /usr/bin so you need to make a few links.

$ sudo ln -s /usr/bin/basename /bin/basename
$ sudo ln -s /usr/bin/awk /bin/awk


Now you need to add a "nobody" group. Debian-based system use nobody.nogroup instead of nobody.nobody, but we aren't losing any security by creating an extra group.
$ sudo addgroup nobody


Now enter installer directory (database), and run the installer. There are many questions, but they are straightforward to answer even if you know little about Oracle. You do not need to do it as root.
$ ./runInstaller -ignoresysprereqs


After you do that the installer will ask you to run two scripts as root. Paths to these scripts (shown in installer dialog) depend on your system, for me they were:
$ sudo /home/taw/oraInventory/orainstRoot.sh
$ sudo /home/taw/oracle/product/10.2.0/db_1/root.sh


Now test if it works with your Rails. If it doesn't due to being unable to load oci8lib.so either recompile OCI8, or more easily add the following line to your .bashrc:
export LD_LIBRARY_PATH=/home/taw/oracle/product/10.2.0/db_1/lib/


By this point you should have Oracle working. The only thing missing is getting it working again after reboot. Just create a /etc/init.d/oracle like this one (correct path and oracle account):
#!/bin/bash

ORACLE_HOME=/home/taw/oracle/product/10.2.0/db_1
ORACLE_OWNR=taw

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_OWNR -c $ORACLE_HOME/bin/dbstart
touch /var/lock/subsys_oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_OWNR -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/subsys_oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 start|stop|restart|reload"
exit 1
esac
exit 0


and create symlinks to it:
$ sudo ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle
$ sudo ln -s /etc/init.d/oracle /etc/rc2.d/S99oracle
$ sudo ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle

23 comments:

  1. Given your need to support whichever database your customers use, and given that its Oracle, it may be worth your while reading:
    "Expert Oracle Database Architecture 9i and 10g Programming Techniques and Solutions" by Tom Kyte from Apress.

    Cheers,
    Paul

    ReplyDelete
  2. Anonymous04:48

    Figure this works on 32-bit Ubuntu, what about Oracle Enterprise Edition 10.2.0.1 on Ubuntu 64-bit (7.10) ?

    ReplyDelete
  3. Murre: Most of the changed I had to do are distribution-related (path names, user accounts etc.) and seem architecture independent. So if it works under other 64-bit Linux distributions it should work under 64-bit Ubuntu, even if a few details will be different from what I did.

    ReplyDelete
  4. Anonymous15:04

    Hi Taw,

    I followed your recipe to install 10g on Gutsy. The Universal Installer (UI) starts just fine but around the middle of the installation I get several errors when the UI runs some makefiles. Make is looking to find a a binary named /lib/idcpp. Google tells me that this (and other /lib/id???) came with SCO Linux and are required by the UI.

    So my questions:

    1) What Ubuntu version (server or desktop) did you installed?

    2) Are there other packages (aside from the basic Ubuntu) installed on your machine?

    BTW, great blog!
    Thanks

    - Michel

    ReplyDelete
  5. I installed it on desktop version.

    I was never asked for /lib/idcpp. Maybe it needs any cpp. Just install all dev packages (build-essential etc.) and try again.

    ReplyDelete
  6. build-essential definitely helped. Thanks for the article and the followups :)

    ReplyDelete
  7. First, thanks for the very clear log of what you did, it helped.

    In thanks, allow me to answer your implicit question about why you were required to use Oracle.

    I work for a Fortune 50 company as a Data Architect. We treat database platform choice differently for two reasons: we wind up maintaining way too many supposed 'package' solutions, and the data generated by the app is a corporate asset in its own right. The data as asset meme is slowly catching on, as more top execs look to manage by metric and KPI.


    Pain tho it might be to port to Oracle, doing so should open more corporate markets to your product. Fair warning - many of the big companies also have strong policies about security and privileges when you want to load your app in their databases.

    ReplyDelete
  8. OlGrizz: You are right that data generated by the app is a corporate asset. And that's why the app provides a very extensive set of APIs to access this data. It's realy pointless to access database directly without going through the ORM layer - you would be reimplementing parts of the app and you are going to do it wrong.

    ReplyDelete
  9. The raw data, the computations used to produce cleansed data, the associations constructed between data elements and the business processes those associations were intended to capture are _all_ assets to the corporation, and all are subject to the same information asset protection policies.

    You want the corporation to treat your app like a black box? What you are asking that corp. to do is provide the infrastructure needed for your app, including but not limited to acquisition, licensing and administration, when it doesn't already have an investment in that technology.

    If you really want to be treated like a black box, sell your app as a turnkey service, with secured tunnel access to and from the corporate intranet. With suitable bonding and guarantees matched to the criticality of the functions your app provides, you can go run LAMP stack to your heart's content: as a service provider, you have assumed all the costs of due diligence and all the risks of service provision, and the only thing I and my opposite numbers elsewhere will care about is how well you've met your SLA's in the past.

    ReplyDelete
  10. OlGrizz: But why would anybody ever want to access application data using raw SQL directly? It's about as pointless as accessing database files as bytes. All the data can be exported in a series of meaningful XML formats, every sensible operation can be done via API, and if somehow this isn't enough, you can use ORM classes to access the database.

    Unless you intend to develop the application, you don't need direct SQL access. And if you do, there's plenty more that you need to worry about like programming languages, frameworks etc., all much more important than choice of the database engine.

    ReplyDelete
  11. Great blog thanks, but in 8.10 (Intrepid) I needed to install libstc++5, after first make realted error.

    Cheers
    Raul

    ReplyDelete
  12. Michel, this is documented in the 10g installation manual for Linux:

    To configure GCC as the primary compiler:
    1. Using a text editor, open the spnc_commands configuration file. In a default installation, the spnc_commands file is located in the $ORACLE_HOME/plsql directory.
    2. Look for the following line of text and comment it out:

    /opt/intel/compiler70/ia32/bin/icc -Qlocation,as,/usr/bin/
    -Qlocation,ld,/usr/bin/ %(src) -O1 -fPIC -fp -mp1 -fp_port
    -I$(ORACLE_HOME)/plsql/include -I$(ORACLE_HOME)/plsql/public -Wl,-s -shared -o %(so)

    3. Look for the following lines, which pertain to GCC, and uncomment them:

    # /usr/bin/gcc -B/usr/bin/ %(src) -c -O1 -fPIC -I$(ORACLE_HOME)/plsql/include
    -I$(ORACLE_HOME)/plsql/public -o %(obj)
    /usr/bin/ld -s -shared %(obj) -o %(so)

    4. Save and close the spnc_commands configuration file.

    ReplyDelete
  13. Hi,

    It is maybe 2 years late, but I was following your steps and I found out I needed to install the following dependencies on top of standard Ubuntu 7.10 install.

    apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool rpm lsb-rpm libstdc++5

    Then, I also added link to rpm and change the default sh

    ln -s /usr/bin/rpm /bin/rpm
    ln -fs /bin/bash /bin/sh

    Regards,
    Yoga

    ReplyDelete
  14. Anonymous10:38

    Hi,

    I'm trying to install Oracle 10g on Ubuntu 8.0 Server VM image and am getting the following exception:

    Exception java.lang.UnsatisfiedLinkError: /tmp/OraInstall2009-11-10_03-28-57AM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory occurred..
    java.lang.UnsatisfiedLinkError: /tmp/OraInstall2009-11-10_03-28-57AM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory

    Please help!!

    Thanks,

    Raj

    ReplyDelete
  15. Raj: You should have files like /usr/lib/libXp.so.6 which are part of X GUI.

    Desktop edition should have it all by default, but server excludes too many as unessential.

    So, install X, and try again?

    ReplyDelete
  16. I had done a install gnome and was hoping it had gotten everything but the file you mention libXp.so.6 is not there in the /usr/lib folder so I tried running sudo apt-get install X but get error saying could not find package X!

    Raj

    ReplyDelete
  17. Raj: It's old library, it's supposedly in xorg-x11-deprecated-libs package now.

    ReplyDelete
  18. Managed to install the libXp through the synaptic package manager and installed Oracle. However even though the installed products show oracle installed successfully, I did get some errors regarding "ORA-12547: TNS: lost contact" so am worried that one of the agents towards the end of the install did not get properly installed. Is there a quick test I could do to check if Oracle is installed with all required agents?

    Thanks, as always!

    ReplyDelete
  19. If I recall correctly, "ORA-12547: TNS: lost contact" can indicate wide range of problems with start up. I cannot really think anything out, you'd need to experiment yourself.

    This guide is getting quite old, someone should update it for more recent versions of Ubuntu (and/or Oracle).

    ReplyDelete
  20. Anil14:54

    It is now Apr 2011 and this post still works!! I installed Oracle EE 10.2.0.1.0 on Ubuntu 10.10 on VirtualBox following these instructions from taw's post and Yoga's comment, where he mentioned additional packages to install.

    ReplyDelete
  21. Anil: That's great news! I'm not using Oracle any more, so I cannot write an updated post, but if it works anyway ;-)

    ReplyDelete
  22. Hi, I am getting this error when running the runinstaller command what could be the problem please help me.

    ./runInstaller: 63: /media/New: not found

    ReplyDelete
  23. savagepriest: It looks like installer script doesn't know how to deal with spaces in paths. Many shell program have this bug.

    Rename "/media/New something" to "/media/New_something" and try again.

    ReplyDelete