Oracle Database 11g Release 1 on Debian sid HOWTO

This is a simple HOWTO, for installing Oracle Database 11g Release 1 on Debian sid.

But why we need this HOWTO? Since Oracle only officially support Red Hat Enterprise Linux, SUSE Enterprise Linux and other enterprise level Linux distribution; BTW, there shouldn't be any problem if you hope to use with other distribution, which just need some special configuration and install required dependent packages. On the other hand, some dependent packages are obsoleted in Debian etch, but only available in oldstable or sid, so install with sid should be better than etch + hybrid sid packages.

"Hey man! Please stop for a while! I have no idea about how to working with Debian sid!"... Ooops... If this is your case, my other article should be your cup of tea. Go back now and let's enjoy with that for a bit while :-)

Before start you will need to prepare your Debian with:

  • A complete Debian sid installation with X11.
  • Static public IP address (or you may bind to localhost during installation).
  • Functional hostname, e.g. hardcode it within /etc/hostname and /etc/hosts.

Check your hardware setup

First of all, you need to have AT LEAST 1GB of physical memory. Check it with:

grep MemTotal /proc/meminfo

On the other hand, it is suggest to have swap with 1.5 time of your physical memory, e.g. around 2GB. Check it with:

grep SwapTotal /proc/meminfo

Shared memory is very important, too. Or else you may face the ORA-00845 error message. First check it with:

df -kh /dev/shm/

If you have less than 512MB (I will suggest for 1GB), edit your /etc/fstab and add/modify the following line:

tmpfs           /dev/shm        tmpfs   defaults,size=1024M    0       0

Then remount it and check the size once again:

mount -o remount /dev/shm
df -kh /dev/shm/

Prepare network connection

Oracle 11g is highly depend on a correct network connection setup, especially the hostname and domain must be a valid value. On the other hand, I will suggest bind your Debian as localhost only, so you will even able to migrate the installation to other IP without reconfigure the Oracle installation.

Configure your /etc/hostname as below. Be careful that you MUST have a valid domain name (e.g. localdomain):

lostlhost.localdomain

Also make sure your /etc/hosts have this line:

127.0.0.1       localhost.localdomain           localhost

Install dependence packages

As I assume you have Debian sid installed correctly with X11, we just need to dig into dependence packages installation directly:

apt-get install alien cpp-3.3 debhelper g++-3.3 gawk gcc-3.3 gcc-3.3-base gettext html2text intltool-debian ksh lesstif2 libaio-dev libaio1 libbeecrypt6 libdb3 libelf-dev libelf1 libg++2.8.1.3-glibc2.2 libltdl3 libltdl3-dev libmotif3 libodbcinstq1c2 libqt4-core libqt4-gui librpm4.4 libsqlite3-0 libstdc++2.10-glibc2.2 libstdc++5 libstdc++5-3.3-dev lsb lsb-core lsb-cxx lsb-desktop lsb-graphics lsb-qt4 odbcinst1debian1 pax po-debconf rpm sysstat unixodbc unixodbc-dev

Well, in case of AMD64, we need some modification:

apt-get install alien cpp-3.3 debhelper g++-3.3 gawk gcc-3.3 gcc-3.3-base gettext html2text intltool-debian ksh lesstif2 libaio-dev libaio1 libbeecrypt6 libdb3 libelf-dev libelf1 libltdl3 libltdl3-dev libmotif3 libodbcinstq1c2 libqt4-core libqt4-gui librpm4.4 libsqlite3-0 libstdc++5 libstdc++5-3.3-dev lsb lsb-core lsb-cxx lsb-desktop lsb-graphics lsb-qt4 odbcinst1debian1 pax po-debconf rpm sysstat unixodbc unixodbc-dev libc6-dev-i386

System groups and users

Check your existing setup with:

grep oinstall /etc/group
grep dba /etc/group
grep nobody /etc/group
id oracle
id nobody

Most likely, you should run the following command for create the required system groups and users. Latest Debian sid already come with user nobody so we don't need to retouch it:

addgroup --system oinstall
addgroup --system dba
useradd -r -g oinstall -G dba -m -s /bin/bash -d /var/lib/oracle oracle
passwd oracle

Configure kernel parameters

Check your existing setup with:

/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range

Then edit your /etc/sysctl.conf and add the following lines:

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144

Run the following command to reload these kernel parameters:

sysctl -p

Shell limits for oracle user

Add the following to /etc/security/limits.conf as below:

oracle          soft    nproc           2047
oracle          hard    nproc           16384
oracle          soft    nofile          1024
oracle          hard    nofile          65536

Check (or add) if the following line exits within /etc/pam.d/login:

session    required     /lib/security/pam_limits.so

Check (or add) if the following line exits within /etc/pam.d/su:

session    required   pam_limits.so

Add this lines to the tail of /etc/profile:

if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
              ulimit -p 16384
              ulimit -n 65536
        else
              ulimit -u 16384 -n 65536
        fi
fi

Create required directories

Create required directory and change permission:

mkdir -p /u01/app/oracle
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02

Configuring the oracle user's environment

Add following line to /var/lib/oracle/.profile (as i will create a AL32UTF8 database; change to US7ASCII if you will create ASCII database). This will also map Oracle's /bin to your $PATH so can run Oracle's binary directly when login as user oracle:

umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export ORACLE_SID=AL32UTF8
export NLS_LANG=.AL32UTF8
unset TNS_ADMIN
if [ -d "$ORACLE_HOME/bin" ]; then
    PATH="$ORACLE_HOME/bin:$PATH"
fi

Fake Oracle installer

As mentioned before , Debian is not listed as Oracle officially support platform and so we need to "fake" it. Create symbolic links:

ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
ln -s /etc /etc/rc.d

Also mask ourself as RedHat:

echo 'Red Hat Linux release 4' > /etc/redhat-release

Last step before installation start

First of all, login with your new oracle user, with X enabled.

If you are using PuTTY + Xming, for sure that the X11 forward is enabled.

Copy the file linux_11gR1_database.zip to oracle's home directory, then unzip it:

cp linux_11gR1_database.zip /var/lib/oracle
cd /var/lib/oracle
unzip -q linux_11gR1_database.zip

I will STRONGLY suggest for a complete reboot, and double-check ALL pre-installation BEFORE starting the next step.

In case of X86, be sure that your /usr/bin/gcc is linked to correct location, e.g.:

lrwxrwxrwx 1 root root      7 2008-07-06 15:36 /usr/bin/gcc -> gcc-4.1
-rwxr-xr-x 1 root root  80976 2007-01-04 02:48 /usr/bin/gcc-3.3
-rwxr-xr-x 1 root root 196932 2008-06-24 10:23 /usr/bin/gcc-4.1

In case of AMD64, you will need to take some hack to gcc. Originally, your /usr/bin/gcc may exist and similar as the case of that in X86. Remove it and replace with a new file as:

#!/bin/bash

if [ "$1" = "-m32" ]; then
gcc-4.1 -L/usr/lib32 $*
else
gcc-4.1 $*
fi

You need to do this BEFORE starting the Oracle 11g installer. After installation complete, you can roll this hack back as case before ;-)

Start the installer with:

cd /var/lib/oracle/database
./runInstaller

Next we go though the installation with screenshots.

Figure 1. Select Installation MethodFigure 1. Select Installation MethodAs we hope to have a full control to the installation, choose "Advanced Installation".

Figure 2. Specify Inventory directory and credentialsFigure 2. Specify Inventory directory and credentialsChange the path for inventory to /var/lib/oracle/oraInventory.

Figure 3. Select Installation TypeFigure 3. Select Installation TypeJust choose "Enterprise Edition". Remember to click on "Production Languages" button.

Figure 4. Language SelectionFigure 4. Language SelectionClick on ">>" so install all available languages.

Figure 5. Install LocationFigure 5. Install LocationJust keep default values.

Figure 6. Product-Specific Prerequisite ChecksFigure 6. Product-Specific Prerequisite ChecksThere will be a lot of exceptional message. Just let it be since we are using Debian sid but not RedHat.

Figure 7. Select Configuration OptionFigure 7. Select Configuration OptionIf this is your first installation, for sure that you will need to create a new database.

Figure 8. Select Database ConfigurationFigure 8. Select Database ConfigurationNothing special, just keep default as General Purpose / Transaction Processing.

Figure 9. Specify Database Configuration OptionsFigure 9. Specify Database Configuration OptionsThis is the most tricky part. For 10gR2 we don't need domain name, but that's required for 11gR1. That's why we need to specify our hostname as localhost.localdomain which seems to be a bit dummy.

Figure 10. Specify Database Config Details - Character SetsFigure 10. Specify Database Config Details - Character SetsUsually I will choose AL32UTF8, even database size will be a bit larger than that of US7ASCII.

Figure 11. Specify Database Config Details - Sample SchemasFigure 11. Specify Database Config Details - Sample Schemas(Optional) Usually I will install with sample schemas so able to test Apache2 + PHP5 + OCI8 with some data.

Figure 12. Select Database Management OptionFigure 12. Select Database Management Option(Optional) If you will use this server for production, enable email notifications should be a good idea.

Figure 13. Specify Database Storage OptionFigure 13. Specify Database Storage OptionPut all database files to /u02/oradata/.

Figure 14. Specify Backup and Recovery OptionsFigure 14. Specify Backup and Recovery Options(Optional) Again, active it if the installation will use as production server.

Figure 15. Specify Database Schema PasswordsFigure 15. Specify Database Schema PasswordsAs I am lazy, just choose Use the same password for all the accounts and apply the change.

Figure 16. Privileged Operationg System GroupsFigure 16. Privileged Operationg System GroupsThe default options should be fine, just keep them.

Figure 17. Oracle Configureation Manager RegistrationFigure 17. Oracle Configureation Manager Registration(Optional) Well... This is a payed services...

Figure 18. SummaryFigure 18. SummaryJust confirm and click Install to start the real installation procedures.

Figure 19. InstallFigure 19. InstallOkay, its time for a coffee break or even a bath :-)

Figure 20. Database Configuration AssistantFigure 20. Database Configuration AssistantIf you have choice to install with sample schemas, you will also face this screen.

Figure 21. Database Configuration Assistant - SummaryFigure 21. Database Configuration Assistant - SummaryNothing to do with this page.

Figure 22. Execute Configuration ScriptsFigure 22. Execute Configuration ScriptsRemember to execute these scripts as root.

Figure 23. End of InstallationFigure 23. End of InstallationThanks god! That's it!

Now you can access the EM page with https://localhost.localdomain:1158/em :-)

Autostart Oracle during system boot

There is almost for sure that you will hope to start your Oracle automatically during system boot. Even you may turn this feature off, but the init.d script is very useful, too.

First of all, specify which database instant will be started together with Oracle. Edit /etc/oratab as below:

AL32UTF8:/u01/app/oracle/product/11.1.0/db_1:Y

Next, create init.d script as /etc/init.d/oracle:

#!/bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance

ORA_HOME="/u01/app/oracle/product/11.1.0/db_1"
ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_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 - $ORA_OWNR -c "$ORA_HOME/bin/dbstart $ORA_HOME"
        su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"

        #Optional : for Enterprise Manager software only
        su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole"

        touch /var/lock/oracle
        echo "OK"
        ;;
    stop)
        # Oracle listener and instance shutdown
        echo -n "Shutdown Oracle: "

        #Optional : for Enterprise Manager software only
        su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole"

        su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
        su - $ORA_OWNR -c "$ORA_HOME/bin/dbshut $ORA_HOME"
        rm -f /var/lock/oracle
        echo "OK"
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0

Permission is very important, too:

chmod 755 /etc/init.d/oracle

Finally, install the script so Oracle will start during system bootup:

update-rc.d oracle defaults 99 01

Encore...

If your Oracle 11gR1 EM keep on eating up your CPU up to 100%, sorry that you face a bug as me... Please follow my other article for more information and solution...

References


Brilliant!

TTimo's picture

This is the most comprehensive and to the point howto I've found for 11g on debian. A very good summary of various bits of information that are spread out over the oracle forums and various blog postings.

I have a few updates to bring to this, I assume because sid has changed a bit since this was initially written:

First, about installing on etch, I think that would still be possible, the main problem will be a lack of 32 bit libaio, but I suppose you could get the lib from a 32 bit installation and put it in, or custom compile an updated package from sid for it.

Some of the recommended install packages are no longer available (gcc-3.3 for instance), and the generic package for 32 bit libraries is not mentioned.

I had problems with 32 bit libgcc.a not found, and apparently it's only in the gcc-snapshot package, so I made the gcc wrapper scripts point to that. I also made a g++ wrapper script, as some stuff in install/make.log indicated it was using it with -m32

The other problem I had was in the memory target when configuring the database, I couldn't set the target higher than ~2GB the system saying I didn't have that much available (a remnant from counting memory for 32 bit systems maybe). This system has 4GB and will only run the DB so I wanted to set my memory target fairly high .. anyway .. more space for OS buffers :)

Thanks for you support :-)

hswong3i's picture

Thanks for you support :-)

The problem of libaio can be solve easily in case of Debian etch, if you know and also able to PLAY with Debian's APT pinning system. E.g. you may first pin your Debian to etch and install most suggested packages; then pin it as sid for getting those missing part (including some required dependence upgrade); and finally pin back to etch for starting Oracle installation. I have been using this method for quite a long period, but I am not going to introduce it for newbie. You will need a lot more of technical knowledge for handling those pinning and packages dependence conflict, which is something belongs to Debian itself but not Oracle. Using Debian sid directly would be the most simple solution for power users, as a drawback you should be responsible to handle this lovely toy.

You may also need to be careful about the different between X86 and AMD64, and carefully following those installation guideline as mentioned above. In case of X86 (32bit), all required packages are mentioned and it is now working happily with my KVM virtual client; In case of AMD64 (64bit), ia32-libs is required for backward compatibility where the other are remain as 64bit, and additional gcc hack is needed (which will solve your -m32 problem).

The final question for memory should belongs to the different of X86 and AMD64. In case of X86, usually you will only able to use 3GB memory as maximum, where AMD64 is relatively unlimited (in TB scale). That may be a bit tricky in choosing X86 or AMD64 for base OS installation. According to my study, usually I will install the host OS as AMD64 (AMD X2 CPU + 4GB main memory: my most efficiency development testbed combination), and running Oracle installation as a X86 KVM virtual client (single qemu CPU + 2GB main memory). This is the most flexible solution that I have been discovered up to now, and hopefully may act as your reference :-)

----------------------------------------
Edison Wong

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <h1> <h2> <h3> <h4> <h5> <h6> <em> <strong> <code> <del> <blockquote> <q> <sub> <p> <br> <ul> <ol> <li> <dl> <dt> <dd> <a> <b> <u> <i> <sup> <acronym> <pre> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.