Thursday, January 28, 2010

Oracle XE swap space workaround (a dpkg -X adventure!)

First off, if you must work with Oracle databases (and many of us must) Oracle XE comes in awfully handy sometimes. I've installed Oracle XE on every platform available. I need a dev install of
Oracle 10g more often than I'd care to admit.

Having run RH distros for years, I favor Debian these days. Usually, installing Oracle XE from the repo is trivial:

Add deb http://oss.oracle.com/debian unstable main non-free to /etc/apt/sources.list
Add Oracle's public signing key to the keychain and then install Oracle XE
    Get the key:
    # wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle
    # apt-key add RPM-GPG-KEY-oracle ...
    and install: # aptitude update # aptitude install oracle-xe
    # wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle
    # apt-key add RPM-GPG-KEY-oracle
    ... and install:
    # aptitude update
    # aptitude install oracle-xe

    (I use aptitude, sub apt-get or whatever floats your boat.)

    This time, it failed! The installer requires a certain amount of swap, which you may not have if you're running in a VM. Note that anything Oracle does require significant hardware resources, so be ready for performance issues. But for experimental and dev type use I usually don't care.

    If you get the swap error, try installing manually. The following works for me.

    XE does depend on libaio, so make sure you have it:
    # aptitude install libaio
    It also depends on libc6. You should already have that ;)

    Unless you've aptitude clean'ed, the deb that failed to install should be in /var/cache/apt/archives/. The deb is also downloadable from the Oracle website. You'll need a login for that.

    Copy/move the deb to a temp directory & unpack
    To do this you can use the dpkg -X command.
    $ dpkg -X oracle-xe-universal_10.2.0.1-1.1_i386.deb temp_directory
    will unpack a bunch of files.

    Copy the content of the deb archive to the right place. Note the #, you must su/sudo su to root or sudo these commands:

    # cd temp_directory
    # cp -R ./usr /
    # cp -R ./etc /

    Create a new user and a new group:

    # groupadd dba
    # useradd oracle -g dba

    Give the ownership of the /user/lib/oracle to this user :
    # chown -R oracle:dba /usr/lib/oracle

    Edit the nls_lang.sh and replace #!/bin/sh by #!/bin/bash:
    # nano /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh

    Run the oracle_env.sh to simplify the process:
    # cd /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/
    # chmod +x oracle_env.sh
    # ./oracle_env.sh

    Change the user rights on the oracle binary :
    # chmod u+s $ORACLE_HOME/bin/oracle; chmod g+s $ORACLE_HOME/bin/oracle

    You'll need to set two Oracle  settings.  Hat tip to Le Blog de Dun!
    Search for the variables:
    # cd /usr/lib/oracle
    # find . -exec grep "%sga_" '{}' \; -print

    I suggest searching. I found init.ora and initXETemp.ora (I'm betting the latter isn't used) but I'd rather be safe. Save a copy while you're at it. :)

    Grep should turn up two .ora files, you have to search for the %sga_target% variable and %pga_aggregate_target% and set them. In nano find is ^W.


    I suggest the following, but this will depend on how much memory you have.


    sga_target=146800640
    pga_aggregate_target=42205184

    Last step: execute the configuration script :
    # /etc/init.d/oracle-xe configure

    I suggest using a different port for the webserver (default is 8080), since you likely have or will have other apps on your machine who also want 8080. I usually take 4080.

    The other port is an Oracle default, you may need to change this if you have other Oracle installs on your machine.

    0 comments:

    Post a Comment