Install Oracle 11gr2 on Ubuntu 10.04


The procedure described here is based on that posted by Don Seiler here
and by a number of articles by Tim Hull on his oracle-base website.

Download the Software
Download the Oracle software from OTN.
You need to login at Oracle Technology Network.I used a 32-bit version in this installation.

Unpack the (two) downloaded files
You should end up with the installation files under a directory "database."
$ unzip linux.x64_11gR2_database_1of2.zip
$ unzip linux.x64_11gR2_database_2of2.zip

Check and/or configure the server name
Make sure that the file "/etc/hosts" contain a fully qualified name for the server.


Consider Hardware requirements
(a) Memory
Oracle recommends at least 1Gb of RAM and 2Gb of swap space on the host. If you're installing the software on a virtual machine, adjust the memory size accordingly, or you will have a tremendous amount of swap activity. Check the RAM size and the configured swap space with:
$ grep MemTotal /proc/meminfo
MemTotal:         3087664Kb
$ grep Swaptotal /proc/meminfo
SwapTotal:        3502128Kb

(b) Disk space
You'll need at least 1GB in the /tmp directory.
On a 32-bit architecture, the oracle software will use close to 4GB in disk, and an initial database will use around 2GB.
In this way, plan to have around 6GB free in the partition in which you'll install oracle.

Consider Software requirements
(a) Installing Pre-requisite Packages
As pointed out in this and this other OTN Notes, you should start by checking whether some libraries are installed and install them, in case they're not.
$ sudo su -    # login as root
# apt-get install build-essential libaio1 libaio-dev libmotif3 libtool
# apt-get install expat alien ksh pdksh unixODBC unixODBC-dev
# apt-get install sysstat elfutils libelf-dev binutils
# apt-get install lesstif2 lsb-cxx lsb-rpm

You can also check whether a package is installed using the dpkg command:
# dpkg --get-selections | grep expat
expat                                           install
libexpat1                                       install
libxml-sax-expat-perl                           install

A few other initial arrangements:
# apt-get install vim-runtime         // to ensure vi arrow keys will work 
# apt-get install vim                 // properly
# apt-get install ssh                 // to enable remote ssh connectivity

Update the libstdc++ package
Ubuntu 10.04 comes with newer version (libstdc++6) of the Standard C++ Library than the one required by Oracle 11gR2 (libstdc++5).
Oracle might update this requirement in future patches or versions, but for now, the OUI will crash if you don't address this issue. So you will have to manually download and copy the libstdc++5 files onto Ubuntu 10.04.

You can look up a list of mirrors to download the 32 or 64-bit versions of this package at
http://packages.ubuntu.com/lucid-backports/libstdc++5
// check info on the package
http://packages.ubuntu.com/lucid-backports/i386/libstdc++5/download
//choose a mirror to download the package.

So to install the 32-bit library you need to (1) download the libsctdc++5 package; (2) unpack it into a new directory; (3) copy the library to the appropriate diretory on your system; and (4) create a symbolic link in that directory:
$ wget http://mirrors.us.kernel.org/ubuntu//pool/universe/g/gcc-3.3/libstdc++5_3.3.6-20~lucid1_i386.deb
$ dpkg -x libstdc++5_3.3.6-20~lucid1_i386.deb lib32bit
$ sudo cp lib32bit/usr/lib/libstdc++.so.5.0.7 /usr/lib/
# cd /usr/lib
# ln -s libstdc++.so.5.0.7 libstdc++.so.5

Now a few more adjustments, to allow the some of the installation scripts to find the expected directories and files on a mostly debian system...
(a) some scritps are expect to find a /usr/bin rather than /bin, so create some symbolic links to address this issue:
# ln -s /usr/bin/awk /bin/awk             // root.sh (post-installation)
# ln -s /usr/bin/basename /bin/basename   // makefile
# ln -s /usr/bin/rpm /bin/rpm

Set Kernel Parameters
Oracle recommend the following minimum parameter settings.

The current values for each parameter can be tested using the following command.
# /sbin/sysctl -a | grep <param-name>

To adjust kernel parameters, create or edit the /etc/sysctl.conf file. By specifying the values in the /etc/sysctl.conf file, they persist when you restart the system. You should backup this file prior to adding the lines below:
# Values for Oracle 11gR2
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 1048576
net.core.wmem_max = 1048576
net.ipv4.ip_local_port_range = 9000 65535
Finally, to load the new values on the kernel immediately, run:
# /sbin/sysctl -p

Configure appropriate user resource limits

Oracle recommends minimum soft and hard limits for some resources assigned to the installation owner (usually the user oracle).

To set the appropriate resource limits, add the following lines to the /etc/security/limits.conf file.
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
You can check the current value for soft and hard resources with ulimit:

$ ulimit -{S|H}{n|u|s}

where {n|u|s} - nofile | nproc | stack


Create User and Groups
You may choose (and oracle recommends that you do) to create one software owner to own each oracle software installation. Usually, the, you'd (1) create the user oracle for the database software; (2) create the user grid for the Oracle Restart and oracle ASM; and (3) create at least the groups dba and oinstall. (If you'll have grid infrastructure and oracle server owned by separate users, you may also want to create the asmdba, asmadmin and asmoper groups.)

Users grid and oracle should have oinstall as their primary group.
The dba group identifies operating system user accounts that have database administrative privileges (the SYSDBA privilege). For simplicity, we'll create only the user oracle and the oinstall group.

First create the oinstall and dba groups
$ sudo su -
# addgroup oinstall
# addgroup dba 
Then create the oracle user and assign it to those groups:
# useradd -g oinstall -G dba -d /home/oracle -s /bin/bash oracle
# passwd oracle                    // enter new password for the user
# mkdir /home/oracle
# chown -R oracle:dba /home/oracle 


user and group information are commonly kept in the files:
/etc/passwd
// has the same general format across Linux platforms.
// provides a list of the user accounts on the system.
// root directly edit the file, or use 'adduser' (Debian)
// or 'useradd' commands to add a new user.

username:password:uid:gid:user_info:home_dir:shell_type

/etc/shadow
// encrypted password file. Not typically directly edited.

username:encrypted password:11843:0:99999:7:::

/etc/group
// lists the existing groups and who is in each group.
// groups can be managed by directly creating new lines in the
// file or through 'groupadd' and 'addgroup' (Debian)

username:password:gid:username1,username2,username3

(If you plan to use Oracle Restart or Oracle ASM and plan have the grid infrastructure and the oracle server software owned by separate users (e.g. grid and oracle), you should also consider creating the asmdba,asmadmin and asmoper groups.)

You can also check whether the user oracle and group oinstall already exist on the machine with:

# grep oinstall /etc/group
# id oracle
# id grid


You may choose (in compliance with OFA) to create a partition for the oracle software, which you can mount on /u01. Then you can create the directory where the software will be installed and change the ownership of /u01 to oracle:oinstall
# mkdir -p /u01/app/oracle
# chown -R oracle:oinstall /u01 
# chmod -R 775 /u01/app/oracle 

Configure oracle user shell's environment variables
Logged as oracle, update the .bash_profile by adding the lines below:

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=ubuntu104.localdomain; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=DB11GR2; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
EDITOR=/usr/bin/vi; export EDITOR

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi


Installation
If you have downloaded the oracle software before creating the oracle user, you may need to change ownership of the directory database created after you unpacked the installation files.
# chown -R oracle:oinstall /path/database

To run the installation, run the commands below, logged in as oracle:

$ cd database
$ ./runInstaller


Prerequisites check failure
During the installation process, the OUI will probably indicate that a number of minimum requrirements for installation were not met. It will complain of not finding a number of packages and it may complain that the OS is not running in the expected run level. You may ignore these errors by clicking on the "Ignore All" box on the upper right corner.
The packages were not found because the installer thinks it is installing on a Red Hat-like Linux system, and search them on an (empty) rpm database. This is ok because you've installed these packages early on. The issue of the run level is a similar "misunderstanding." The system is running on level 2, which is equivalent to the expected by the OUI. So, ignore and proceed.

As you follow the installation screens, choose whether to install the software only or to create the started database. You may choose to create the database latter using the dbca (db configuration assistant).


Sources:
http://forums.oracle.com/forums/thread.jspa?threadID=1115155
http://forums.oracle.com/forums/thread.jspa?threadID=1077139&tstart=0

Server name: /etc/hosts vs. /etc/hostname

What is the relation between /etc/hosts and /etc/hostname?
What are the uses of these files? What security threat they can represent?

/etc/hosts
is usually used to maintain tables mapping hostnames to IP addresses.
This file contains one entry per line, consisting of an IP address, a hostname, and an optional list of aliases for the hostname. The fields are separated by spaces or tabs, and the address field must begin in the first column.

Each entry on /etc/hosts maps a hostname to an IP address.
By default, there are only two entries in the file:
(1) defines the loopback mapping, which maps the localhost name and the IP 127.0.0.1
(2) maps a name for the host with the explicit IP address of the machine's network adapter.
127.0.0.1    localhost.localdomain          localhost
174.46.1.2    veuler

The /etc/hosts provides a simple form of hostname resolution, and you may choose to use it even if you're using other naming resolution mechanism, such as DNS or NIS.
To add or remove hosts, or to reassign addresses, all you have to do is update the hosts file on all hosts.

You should try to keep the /etc/hosts file as short as possible. You can use the file to map all the hosts within a small private LAN, since this may improve performance of address resolution for the hosts within the local network. This is because it would be faster for an application to check the local /etc/hosts, than to send a request to the name server. However, for hosts outside the LAN, the general rule of thumb is that if a particular host has a DNS entry, it has no place in /etc/hosts.

The approach of using /etc/hosts as the network naming system, however, is suitable only for networks with a small number of hosts. As the number of hosts increases, the cost of maintaining /etc/hosts files in each server grows exponentially. This problem is similar to that faced by telephone companies in the early years of the telephone system.

The file /etc/host.conf allow you to configure the order in which the resolver will use the various naming resolution mechanisms available on your network. You may also use this file to direct all applications to use /etc/hosts exclusively.
The entries in /etc/host.conf tell the resolver library what services to use, and in what order to resolve names.
# /etc/host.conf
# first check the local file, then send a request to DNS
order  hosts bind
# Allow multiple addrs
multi   on 

option: order
determines the order in which the resolving services are tried. Valid options:
bind - for querying the name server
hosts - for lookups in /etc/hosts
nis - for NIS lookups

option: multi {on|off}
Determines if a host in /etc/hosts is allowed to have several IP addresses (whether a server can be ``multi-homed''). The default value is off.



/etc/hostname
You can temporarily set the hostname to name with the command below. Remember that this change will be lost during the next reboot, however.
# hostname name 
// usually you use this command to set the unqualified hostname
// so you would use 'vlab1' rather than 'vlab1.ptu.edu'

So, how to find out and/or change the name of a host?
To find out the name of a host, just type the command below. It will display the contents of the file /etc/hostname:
# hostname
veuler

To see the fully qualified domain name of the host, you can either
(a) check /etc/hosts or
(b) use
# hostname --fqdn
veuler.math.ptu.edu

To permanently change the name of a host you need to update the /etc/hosts file. This ensures that the new name will persist after the next restart.
When an application needs to find out the name of the host where it is running, it often does it through a call to a function in the resolverlibrary, which, on Linux, are part of the standard libc. These functions check the /etc/hosts file for the hostname.

Sources:
Linux Network Administrators Guide (Kirch and Dawson 2000).
Hacker Linux Uncovered (Flenov 2005).

(1) Introduction

Describe the Human Resources (HR) Schema
Introduction to SQL Developer
Introduction to PL/SQL