Installing Oracle 11gR2 on Ubuntu 12.04

This howto should guide you though the installation of an Oracle Database 11g Release 2 on Ubuntu 12.04.
Ubuntu is not officially supported by Oracle so there will be a few tweaks to achieve a working solution.
I hope this might help you if you aim for a similar task.

Before we start with this Chapter I assume you have a clean Ubuntu 12.04
Server up and running. If that is not the case please check out my previous
post Ubuntu 12.04 LTE Server on Virtualbox 4.1 installation.

 

1. Download Oracle

first download the full Version of Oracle 11gR2 for linux OS from the Oracle sideSafe the 2 files somewhere
on your local PC. We will transfer them later to the VM.

 

2. Prepare the System

We have to install a few required packages for Oracle. Best way to install those is to use the standard
debian package manager. As I have installed Ubuntu on my Server and work primary on my MacBook Air
I will open a Terminal session and SSH into the Server as root. You can of course also just enter the
commands direct into the VM’s terminal to install the following packages:

aptitude  -y  install alien binutils build-essential libaio1 libaio-dev unixODBC unixODBC-dev
expat sysstat libelf-dev elfutils pdksh ia32-libs  unzip libstdc++ 5 libstdc++ 6 cpp- 4.4
g++- 4.4  gawk ksh lesstif2 lib32bz2-dev lib32z1-dev libbeecrypt7 libdb4.8 libmotif4
libodbcinstq4- 1 libodbcinstq4- 1:i386 libqt4-core libqt4-gui lsb lsb-cxx lsb-qt4

 

3. Pre-Checks

check your /etc/hostname that it looks like below:

localhost.localdomain

and also check that in /etc/hosts the below line is present:

127.0.0.1        localhost.localdomain    localhost

 

4. Configure Memory Settings

For the installation we need a minimum of 1GB physical memory which we define when we setup the
Virtual Machine earlier, else you can check it with the following command:

grep MemTotal  /proc /meminfo

Because the Oracle installation is demanding in resources we create some temp swap-space that will
disappear after a reboot. Bare that in mind, if you reboot the Server before completing the Oracle
installation you have to redo the below steps.

Check your current swap-space with this command:

grep SwapTotal  /proc /meminfo

Now let’s create a temporary swap file for the installation.

dd  if= /dev /zero  of= /tmp /swap  bs=1M  count= 4096
chmod  600  /tmp /swap
mkswap  /tmp /swap
swapon  /tmp /swap

Execute the command again to confirm the added swap-space

grep SwapTotal  /proc /meminfo

Shared Memory is also important for Oracle, else you might face some ORA-00845 errormessages.
Check your current Shared Memory with this command:

df  -kh  /dev /shm /

If you have less than 512MB edit /etc/fstab and add (either 1024M or 1512M) I am adding here 1.5GB
by adding the following line:

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

After remount and check the new size once again:

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

 

5. System Group and Users

remember we did not create any Users with our Ubuntu installation so lets do that now

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

 

6. Configure Kernel

Oracle requires additional kernel parameters, you either create a new kernel parameter file or add it to
the existing system kernel. I choose to add them to the existing system file. So lets make first a backup

Backup the original system file /etc/sysctl.conf by executing:

cp  /etc /sysctl.conf  /etc /sysctl.conf.original

Execute the following command to simply paste in the parameters:

cat -  >>  /etc /sysctl.conf

Now cut and paste the following

# Oracle 11gR2 kernel parameters
fs.aio-max-nr= 1048576
fs.file-max= 6815744
net.ipv4.ip_local_port_range= 9000  65500
net.core.rmem_default= 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048586
kernel.sem= 250  32000  100  128
kernel.shmmax= 2147483648

then press Ctrl-d to write the file

Note:

kernel.shmmax = max possible value, e.g. size of physical RAM.

Verify the above with:

cat  /etc /sysctl.conf

and load the new Kernel parameter with the following command:

sysctl  -p

Verify the new kernel settings:

sysctl  -q fs.aio-max-nr

that should return — fs.aio-max-nr = 1048576

Before we now set the Oracle limits lets backup the original file:

cp  /etc /security /limits.conf  /etc /security /limits.conf.original

Next add the following limits to /etc/security/limits.conf:

cat -  >>  /etc /security /limits.conf

cut and paste the following and then write to the file with Ctrl-d

#Oracle 11gR2 shell limits
oracle soft nproc  2048
oracle hard nproc  16384
oracle soft nofile  1024
oracle hard nofile  65536
oracle soft stack  10240

Check/add if the following line exits within /etc/pam.d/login

session required  /lib /security /pam_limits.so

Check if the following line exits within /etc/pam.d/su

session required pam_limits.so

 

7. Create Oracle directories

It’s time to create some directories for Oracle and set the permissions.

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

 

8. Configuring the oracle user’s environment

Add following lines to /var/lib/oracle/.profile
We are creating here a AL32UTF8 database, so change this to US7ASCII if you want to create and
ASCII database. This will also map Oracle’s /bin to your $PATH to run Oracle’s binary directly at login:

# for Oracle User
if  [  "$USER" = oracle  ]then
if  [  $SHELL =  "/bin/ksh"  ]then
ulimit  -p  16384
ulimit  -n  65536
else
ulimit  -u  16384  -n  65536
fi
fi
umask 022
export  ORACLE_BASE= /u01 /app /oracle
export  ORACLE_HOME= $ORACLE_BASE /product /11.2.0 /dbhome_1
export  ORACLE_SID=AL32UTF8
export  NLS_LANG=.AL32UTF8
unset TNS_ADMIN
if  [  -d  "$ORACLE_HOME/bin"  ]then
PATH= "$ORACLE_HOME/bin:$PATH"
fi

 

9. Fake Oracle installer

As mentioned before , Ubuntu is not listed as Oracle officially support platform and so we need
to fake it by creating symbolic links:

mkdir  /usr /lib64
ln  -s  /etc  /etc /rc.d
ln  -s  /usr /bin / awk  /bin / awk
ln  -s  /usr /bin / basename  /bin / basename
ln  -s  /usr /bin /rpm  /bin /rpm
ln  -s  /lib /x86_64-linux-gnu /libgcc_s.so.1  /usr /lib64 /
ln  -s  /usr /lib /x86_64-linux-gnu /libc_nonshared.a  /usr /lib64 /
ln  -s  /usr /lib /x86_64-linux-gnu /libpthread_nonshared.a  /usr /lib64 /
ln  -s  /usr /lib /x86_64-linux-gnu /libstdc++.so.6  /usr /lib64 /

Mask ourself as RedHat:

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

 

10. Copy the Oracle installation files to the Server

We discussed in the pre-post PuTTY, so we going to use that now to copy the files over to the Server.
Copy the file 2 files (linux.x64_11gR2_database_*.zip to oracle’s home directory and unzip them

cp linux.x64_11gR2_database_1of2.zip  /var /lib /oracle
cp linux.x64_11gR2_database_2of2.zip  /var /lib /oracle
cd  /var /lib /oracle
unzip  -q linux.x64_11gR2_database_1of2.zip
unzip  -q linux.x64_11gR2_database_2of2.zip
chown  -Rf oracle:oinstall  /var /lib /oracle /

In case that cp don’t work use the scp command that comes with PuTTY to copy the files over.

scp linux.x64 * oracle @ip_address: /var /lib /oracle

 

11. Starting Oracle Installer

Before we can do that we have to export the Display on our Ubuntu Server as root.
Go to your Ubuntu VM and login as root if not already and execute the following commands:

DISPLAY=: 0.0
export DISPLAY

Next go back to PuTTY session and login to the Server as oracle (su – oracle if you are already as root).
No change to the database directory and start the installer with the following command:

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

 

At the first screen of the Oracle Installer you can add your support Account if you have one, In case
you don’t just leave it empty and remove the default tick box for the email.

 

 

 

 

 

 

 

 

 

 

 

 

 

At the next tab [Select Installation Option] – choose the first setting Create and configure a database:

Installing Oracle 11gR2 on Ubuntu 12.04_第1张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [System Class] – choose Server Class:

Installing Oracle 11gR2 on Ubuntu 12.04_第2张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Node Selection] – choose the option Single instance database installation:

Installing Oracle 11gR2 on Ubuntu 12.04_第3张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Select Install Type] – choose Advanced install:

Installing Oracle 11gR2 on Ubuntu 12.04_第4张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Select Product Languages] – choose to install at your demand I select all available languages:

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Select Database Edition] – choose Enterprise Edition:

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Installation Location] – the default settings should be as below:

Oracle Base: /u01/app/oracle
Sofeware Location: /u01/app/oracle/product/11.2.0/dbhome_1

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Create Inventory] –  it should default as below:

Inventory Directory: /u01/app/oraInventory
oraInventory Group Name: oinstall

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Select Configure Type] – choose General Purpose / Transaction Processing:

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Database Identifiers] – configure as below:

Global database name: AL32UTF8.localdomain
Oracle Service Identifier (SID): AL32UTF8

Installing Oracle 11gR2 on Ubuntu 12.04_第5张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Configuration Options] – configure as below:

Memory -> Enable Automatic Memory Management: TRUE
Character sets: Use Unicode (AL32UTF8)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Management Options] – choose Use Database Control for database management
and leave the rest as default:

Installing Oracle 11gR2 on Ubuntu 12.04_第6张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Database Storage Options] – choose File System where:

Specify database file location: /u01/app/oracle/oradata

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Recovery Options] – choose Do not enable automated backups:

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Specify Schema Passwords] – choose to your passwords and write them down:

Installing Oracle 11gR2 on Ubuntu 12.04_第7张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Privileged Operating System Groups] – confirm as below:

Database Administrator (OSDBA) Group: dba
Database Operator (OSOPER) Group: oinstall

 

 

 

 

 

 

 

 

 

 

 

 

 

In [Preform Prerequisite Checks] –  just simply ignore all warning message
(since we are using Debian but not Oracle officially supported OS):

 

 

 

 

 

 

 

 

 

 

 

 

 

So just confirm everything in Summary:

Installing Oracle 11gR2 on Ubuntu 12.04_第8张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

And now let’s go for a coffee/tee break – you deserve it

Installing Oracle 11gR2 on Ubuntu 12.04_第9张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

Special note for Ubuntu 12.04: If you face error during installation so update as below:

 

 

 

 

 

 

 

 

 

 

 

 

 

When you see the above error, open a new session to the Server and execute the below commands:

export  ORACLE_HOME= /u01 /app /oracle /product /11.2.0 /dbhome_1
sed  -i  's/^(s*$(MK_EMAGENT_NMECTL))s*$/1 -lnnz11/g'  $ORACLE_HOME /sysman /lib /ins_emagent.mk
sed  -i  's/^($LD $LD_RUNTIME) ($LD_OPT)/1 -Wl,--no-as-needed 2/g'  $ORACLE_HOME /bin /genorasdksh
sed  -i  's/^(s*)($(OCRLIBS_DEFAULT))/1 -Wl,--no-as-needed 2/g'  $ORACLE_HOME /srvm /lib /ins_srvm.mk
sed  -i  's/^(TNSLSNR_LINKLINE.*$(TNSLSNR_OFILES)) ($(LINKTTLIBS))/1 -Wl,--no-as-needed 2/g'  $ORACLE_HOME /network /lib /env_network.mk
sed  -i  's/^(ORACLE_LINKLINE.*$(ORACLE_LINKER)) ($(PL_FLAGS))/1 -Wl,--no-as-needed 2/g'  $ORACLE_HOME /rdbms /lib /env_rdbms.mk

Then press Continue and keep going …

 

 

 

 

 

 

 

 

 

 

 

 

 

Now following the instructions and run the following commands with root user:

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh

Installing Oracle 11gR2 on Ubuntu 12.04_第10张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

Confirm with installation progress

 

 

 

 

 

 

 

 

 

 

 

 

 

In previous screen the installer mentioned that we can access Enterprise Manager Database Control URL
from https://localhost.localdomain:1158/em, so now let’s open the browser and test it with following account:

User Name: SYS
Password: your_secret_password
Connect As: SYSDBA

Once login it should show as below:

 

12. Post Configurations – Autostart Oracle during system boot

I like if everything boots up automatic so lets configure Oracle to start during system boot. You can of course
turn this feature later off, but the init.d script is very useful too. First we need to specify which database
instant will be started together with Oracle. (of course this is the first but maybe you have already done
this a few times).
Edit /etc/oratab as below:

AL32UTF8: /u01 /app /oracle /product /11.2.0 /dbhome_1:Y

Now lets create the init.d script as /etc/init.d/oracle

cat -  >>  /etc /init.d /oracle

copy and paste all below and complete it with Ctrl-d

#!/bin/bash
#

# Run-level Startup script for the Oracle Instance and Listener
#
### BEGIN INIT INFO
# Provides: Oracle
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Startup/Shutdown Oracle listener and instance
### END INIT INFO
ORA_HOME= "/u01/app/oracle/product/11.2.0/dbhome_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

Set the Permission:

chmod  755  /etc /init.d /oracle

Finally we need to install the script so Oracle will start during system bootup:

update-rc.d-insserv oracle defaults  99 01

NOTE: You may find the following error message during /etc/init.d/oracle/stop:
Shutdown Oracle: ulimit: 25: bad number

You can then update /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl
with #!/bin/bash to solve the problem:

export  ORACLE_HOME= /u01 /app /oracle /product /11.2.0 /dbhome_1
sed  -i  's/^#!/bin/sh -fs*/#!/bin/bash -f/g'  $ORACLE_HOME /bin /emctl

 

你可能感兴趣的:(Installing Oracle 11gR2 on Ubuntu 12.04)