After many requests from readers, I’ve put together new, revised version of the Oracle 11g on Ubuntu recipe. This new version is a little different than the first one published: it’s based on a bare-bones install of Ubuntu 7.10 (Gutsy Gibbon) server version instead of the desktop version. As an improvement, I’ve tried to pare down dependencies to a minimal set.
Your feedback is more than welcome — it’s the main reason why I wrote a new version of this HOWTO. I’ve also tested and repeated this procedure twice. Even so, it might still have problems, so please let me know so we can improve it 1.
We start with a freshly installed Ubuntu 7.10 server. The only modification made on the base installation was installing an
sshd 2 server and a
nfs client 3 to use the distribution files on another box in the office. Change
192.168.x.y to the IP address of your new server.
bott@mybox:~$ xhost +192.168.x.y 192.168.x.y being added to access control list
After that, almost all we need to do can be done via a single SSH session. This first part must be executed as
root, so we execute
sudo -s to gain super-user access. After that, we proceed to update our mirrors so we can upgrade the installed base packages:
root@idlebox:~# uname -a Linux idlebox 2.6.22-14-server #1 SMP Sun Oct 14 23:34:23 GMT 2007 i686 GNU/Linux root@idlebox:~# apt-get update (...) root@idlebox:~# apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be upgraded: libssl0.9.8 tzdata 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 3479kB of archives. After unpacking 262kB of additional disk space will be used. Do you want to continue [Y/n]?
Afterwards, we install some package dependencies. This is the smallest number of packages I’ve been able to test so far (the first version of this HOWTO required 18 extra packages). Since I had the Ubuntu distribution CD-ROM available, very few packages must be downloaded from the network:
root@idlebox:~# apt-get install gcc make binutils libaio1 gawk ksh libc6-dev rpm libmotif3 alien lsb-rpm libtool Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: autotools-dev cpp cpp-4.1 debhelper dpkg-dev gcc-4.1 gcc-4.1-base gettext html2text intltool-debian libbeecrypt6 libice6 libneon25 librpm4 libsm6 libx11-6 libx11-data libxau6 libxdmcp6 libxext6 libxml2 libxmu6 libxp6 libxt6 linux-libc-dev patch po-debconf x11-common Suggested packages: lintian binutils-doc cpp-doc gcc-4.1-locales dh-make debian-keyring gcc-multilib manpages-dev autoconf automake1.9 flex bison gdb gcc-doc gcc-4.1-multilib gcc-4.1-doc cvs gettext-doc glibc-doc libtool-doc automaken g77 fortran77-compiler gcj make-doc diff-doc Recommended packages: libmudflap0-dev libltdl3-dev xml-core libmail-sendmail-perl libcompress-zlib-perl The following NEW packages will be installed: alien autotools-dev binutils cpp cpp-4.1 debhelper dpkg-dev gawk gcc gcc-4.1 gcc-4.1-base gettext html2text intltool-debian ksh libaio1 libbeecrypt6 libc6-dev libice6 libmotif3 libneon25 librpm4 libsm6 libtool libx11-6 libx11-data libxau6 libxdmcp6 libxext6 libxml2 libxmu6 libxp6 libxt6 linux-libc-dev lsb-rpm make patch po-debconf rpm x11-common 0 upgraded, 40 newly installed, 0 to remove and 0 not upgraded. Need to get 5355kB/21.2MB of archives. After unpacking 69.8MB of additional disk space will be used. Do you want to continue [Y/n]?
After the necessary packages are installed, we change the default replacement for
bash so we don’t have surprises from scripts depending on bash-like behavior.
root@idlebox:~# cd /bin root@idlebox:~# ls -l /bin/sh lrwxrwxrwx 1 root root 4 2007-11-04 15:29 /bin/sh -> dash root@idlebox:/bin# ln -sf bash /bin/sh root@idlebox:/bin# ls -l /bin/sh lrwxrwxrwx 1 root root 4 2007-11-05 10:42 /bin/sh -> bash
We make some modifications to our base system (line numbers added for clarity):
01 root@idlebox:~# addgroup oinstall Adding group `oinstall' (GID 1001) ... Done. 02 root@idlebox:~# addgroup dba Adding group `dba' (GID 1002) ... Done. 03 root@idlebox:~# addgroup nobody Adding group `nobody' (GID 1003) ... Done. 04 root@idlebox:~# usermod -g nobody nobody 05 root@idlebox:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle 06 root@idlebox:~# passwd -l oracle Password changed. 07 root@idlebox:~# mkdir /home/oracle 08 root@idlebox:~# chown -R oracle:dba /home/oracle 09 root@idlebox:~# ln -s /usr/bin/awk /bin/awk 10 root@idlebox:~# ln -s /usr/bin/rpm /bin/rpm 11 root@idlebox:~# ln -s /usr/bin/basename /bin/basename 12 root@idlebox:~# mkdir /etc/rc.d 13 root@idlebox:~# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done 14 root@idlebox:~# mkdir -p /u01/app/oracle 15 root@idlebox:~# chown -R oracle:dba /u01
01-03add the groups we need.
nobodyusers so the Oracle installer doesn’t get confused.
- On lines
05-08we create the Oracle user, lock that account so no one can login with it, and create a
HOMEdirectory for the user (not the same as
- On lines
09-13we create some symlinks so we can fool the Oracle installer.
- Finally, on lines
14-15we create our
ORACLE_HOME. Alternatively, you can copy/paste this 4.
We also need to change some system-wide defaults. There is some explanation for all these system modifications on the first post on installing Oracle 11g on Ubuntu.
First, add this to the end of your
/etc/sysctl.conf. It extends the number of allowed file descriptors, the size of shared memory, and does some tweaking with the network subsystem.
fs.file-max = 65535 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 1024 65535 net.core.rmem_default = 1048576 net.core.rmem_max = 1048576 net.core.wmem_default = 262144 net.core.wmem_max = 262144
Then, add this at the end of your
oracle soft nproc 2047 oracle hard nproc 16383 oracle soft nofile 1023 oracle hard nofile 65535
Add this to
/etc/pam.d/login to enforce what we added to
cat >> /etc/pam.d/login << EOF session required /lib/security/pam_limits.so session required pam_limits.so
(See footnote 5 for an alternative method to performing these last three steps.)
The last thing to do is reload the configuration on
/etc/sysctl.conf so the system is affected without a reboot. It’s also a good idea to logout and login again so the
limits specified above take place.
root@idlebox:~# sysctl -p kernel.printk = 4 4 1 7 kernel.maps_protect = 1 fs.file-max = 65535 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default = 1048576 net.core.rmem_max = 1048576 net.core.wmem_default = 262144 net.core.wmem_max = 262144
I’ve made the distribution files available on a NFS mount on
/media/database, so we
su to the
oracle user and start our installation on a remote X server. Please note the
-ignoreSysPrereqs flag to the Oracle installer.
root@idlebox:~# su - oracle oracle@idlebox:~$ export DISPLAY=Xserver.IPaddress:0.0 oracle@idlebox:~$ cd /media/database/ oracle@idlebox:/media/database$ ./runInstaller -ignoreSysPrereqs Starting Oracle Universal Installer... Checking Temp space: must be greater than 80 MB. Actual 6555 MB Passed Checking swap space: must be greater than 150 MB. Actual 400 MB Passed Checking monitor: must be configured to display at least 256 colors >>> Could not execute /usr/bin/xdpyinfo Failed <<<< >>> Ignoring required pre-requisite failures. Continuing... Preparing to launch Oracle Universal Installer from /tmp/OraInstall2007-11-04_09-39-05PM. Please wait ...
The installation should be pretty smooth. If, after some seconds, a window like this one shows up, you’re right on track. Hit Next.
I’ve changed the group to
dba before hitting Next:
On this one, I left the defaults and hit Next:
-ignoreSysPrereqs option? Click on all the checkboxes on the list to change their state from “Failed” or “Warning” to “User Verified” and it will let you hit Next.
In my case, I just installed the software and created a database afterwards with
Since this is a test box, I modified the groups to be
A quick summary show appear, and it’s time to hit Install:
This will take a while. The first time I run the installer, it took so long I thought it was frozen. Let it run. At some point it will reach the “linking” stage.
Let it run and you’ll be presented with a request to run two scripts as root:
They should output something like this:
root@idlebox:~# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory to 770. Changing groupname of /u01/app/oraInventory to dba. The execution of the script is complete root@idlebox:~# /u01/app/oracle/product/11.1.0/db_1/root.sh Running Oracle 11g root.sh script... The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /u01/app/oracle/product/11.1.0/db_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: (hit enter) Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed. Finished product-specific root actions.
And finally, the Oracle installer will congratulate you with some good news:
For the final steps of this setup, two more things must be done. First, add this to
/etc/profile, so you can run
dbca after login in again as the
oracle user: 6
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 export PATH=$PATH:/u01/app/oracle/product/11.1.0/db_1/bin
Also, I’ve made some adjustments to the startup script. It should be useful after creating a database and setting it to start on
#!/bin/bash # # /etc/init.d/oracledb # # Run-level Startup script for the Oracle Listener and Instances # It relies on the information on /etc/oratab export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 export ORACLE_OWNR=oracle export PATH=$PATH:$ORACLE_HOME/bin if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] then echo "Oracle startup: cannot start" exit 1 fi 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/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/oracle echo "OK" ;; reload|restart) $0 stop $0 start ;; *) echo "Usage: `basename $0` start|stop|restart|reload" exit 1 esac exit 0
After saving it as
/etc/init.d/oracledb and making it owned by
root, run this to make it executable:
root@idlebox:~# chmod a+x /etc/init.d/oracledb
If you want this script to be run at every boot, execute this:
root@idlebox:/bin# update-rc.d oracledb defaults 99 Adding system startup for /etc/init.d/oracledb ... /etc/rc0.d/K99oracledb -> ../init.d/oracledb /etc/rc1.d/K99oracledb -> ../init.d/oracledb /etc/rc6.d/K99oracledb -> ../init.d/oracledb /etc/rc2.d/S99oracledb -> ../init.d/oracledb /etc/rc3.d/S99oracledb -> ../init.d/oracledb /etc/rc4.d/S99oracledb -> ../init.d/oracledb /etc/rc5.d/S99oracledb -> ../init.d/oracledb
It would be a good idea to add yourself to the
dba group, by using
usermod or by directly editing the
/etc/group file. Locate the line starting with
dba and add your username after the comma:
After creating a database and firing it up (either manually or with the script provided), we test our installation:
pythian@idlebox:~$ sqlplus /nolog SQL*Plus: Release 126.96.36.199.0 - Production on Mon Nov 5 12:23:20 2007 Copyright (c) 1982, 2007, Oracle. All rights reserved. SQL> connect /as sysdba Connected. SQL>
And now we can safely say: we’re done!
Again, please share your thoughts and your experiences with this.
So now, dear reader, we hope we have helped you figure out something you needed to know. It turns out that you can help us here at Pythian with something we need to know! If you are aware of a DBA requirement within your organization, salaried or consulting, please pop in your email address here:
We respect your privacy and will not share your address with any third party. As a thank you for just participating, we will enter you into a monthly draw for a year’s membership in the ACM, which includes access to 600 books from the O’Reilly Bookshelf Online, 500 books from Books24x7 and 3000 online courses from SkillSoft, including tons of courseware on Oracle, SQL Server, and MySQL.
1. The method described here should work just fine on Gutsy desktop version since it shares a common base with the server version, so package dependencies for Oracle should be the same on both versions. back
2. The steps regarding
X forwarding to another box probably can be skipped if you have a
X Server on the server itself. I built this document on a server without a
X Server and forwarded the output to my box. back
3. If you are want to copy the distribution files directly to the server and use them from a local filesystem, you can skip the
nfs-client installation. You will need the
unzip package installed to extract the contents of the download. back
4. Users and groups configuration. Paste this as
addgroup oinstall addgroup dba addgroup nobody usermod -g nobody nobody useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle passwd -l oracle mkdir /home/oracle chown -R oracle:dba /home/oracle ln -s /usr/bin/awk /bin/awk ln -s /usr/bin/rpm /bin/rpm ln -s /usr/bin/basename /bin/basename mkdir /etc/rc.d for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done mkdir -p /u01/app/oracle chown -R oracle:dba /u01
5. Paste this as
cat >> /etc/sysctl.conf << EOF fs.file-max = 65535 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 1024 65535 net.core.rmem_default = 1048576 net.core.rmem_max = 1048576 net.core.wmem_default = 262144 net.core.wmem_max = 262144 EOF cat >> /etc/security/limits.conf << EOF oracle soft nproc 2047 oracle hard nproc 16383 oracle soft nofile 1023 oracle hard nofile 65535 EOF cat >> /etc/pam.d/login << EOF session required /lib/security/pam_limits.so session required pam_limits.so EOF
6. Paste the following, as
cat >> /etc/profile << EOF export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 export PATH=$PATH:/u01/app/oracle/product/11.1.0/db_1/bin EOF
Interested in working with Augusto? Schedule a tech call.