Tuesday 18 March 2014

Set up Oracle 11gR2 in Ubuntu 12.04

Prerequisites:-
Download Oracle 11gR2
Steps:-
1.      Installing Dependencies
To install dependencies, run
sudo apt-get update
sudo apt-get install gcc make binutils gawk x11-utils rpm build-essential libaio1 libaio-dev libmotif4 libtool expat alien ksh pdksh unixODBC unixODBC-dev sysstat elfutils libelf-dev binutils lesstif2 lsb-cxx libstdc++5
2.      We need to create some softlinks to start the installation. To do so run the following commands,
sudo ln -sf /bin/bash /bin/sh
sudo ln -s /usr/bin/awk /bin/awk
sudo ln -s /usr/bin/rpm /bin/rpm
sudo ln -s /usr/bin/basename /bin/basename
sudo ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
sudo ln -s /usr/lib/i386-linux-gnu/libc_nonshared.a /usr/lib/libc_nonshared.a
sudo ln -s /lib/i386-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
sudo ln -s /usr/lib/i386-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so.6
3.      Also we need to add oracle user and oinstall, dba, nobody group. Run following commands,
sudo addgroup oinstall
sudo addgroup dba
sudo addgroup nobody
sudo usermod -g nobody nobody
sudo useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
sudo mkdir /home/oracle
sudo chown -R oracle:dba /home/oracle
4.      We need to do changes in start-up script, run following commands as root
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
5.      Now we will create the directory for installation, and changes it owner to oracle. Run following commands to do the same
sudo mkdir -p /u02/oradata/MYDB
sudo chown -R oracle:dba /u01
6.      We also need to modify the kernel parameter, to do so run following commands as root
echo "#">> /etc/sysctl.conf
echo "# Oracle 11gR2 entries">> /etc/sysctl.conf
echo "fs.aio-max-nr=1048576" >> /etc/sysctl.conf
echo "fs.file-max=6815744" >> /etc/sysctl.conf
echo "kernel.shmall=2097152" >> /etc/sysctl.conf
echo "kernel.shmmni=4096" >> /etc/sysctl.conf
echo "kernel.sem=250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range=9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default=262144" >> /etc/sysctl.conf
echo "net.core.rmem_max=4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default=262144" >> /etc/sysctl.conf
echo "net.core.wmem_max=1048586" >> /etc/sysctl.conf
echo "kernel.shmmax=1073741824" >> /etc/sysctl.conf
7.      Note: kernel.shmmax = max possible value, e.g. size of physical memory in bytes. In my case machine is having 2GB so we are specifying 1GB. Adjust the parameter as per your configuration

Load new kernel parameters, by running following,
sudo sysctl -p
8.      We have to change shell configuration, to do the same run following commands as root user,
cp /etc/security/limits.conf /etc/security/limits.conf.original
echo "#Oracle 11gR2 shell limits:">>/etc/security/limits.conf
echo "oracle soft nproc 2048">>/etc/security/limits.conf
echo "oracle hard nproc 16384">>/etc/security/limits.conf
echo "oracle soft nofile 1024">>/etc/security/limits.conf
echo "oracle hard nofile 65536">>/etc/security/limits.conf
9.      Download Oracle 11g R2 database from Oracle Download Center for linux.

I have downloaded both the zip in /home/oracle. We need to extract both the zip to start the installation. To unzip run,
cd /home/oracle
unzip linux_11gR2_database_1of2.zip
unzip linux_11gR2_database_2of2.zip
10.  Now we will start the installation. You can start the installation from /home/oracle/database.
Login as a oracle user.
su oracle
11.  Go to the binaries and start the installation as a oracle user,
cd /home/oracle
chmod 777 -R database
cd database
./runInstaller -ignoreSysPrereqs
12.  Next we go though the installation (I don’t have the “Oracle Support Password” so just skip in here):

In Selection Installation Option, choose Create and configure a database:

In System Class, choose Server Class (we hope to give a full control during installation):

In Node Selection, choose Single instance database installation:

In Select Install Type, choose Advanced install:

In Select Product Languages, I choose to install English language:

In Select Database Edition, I choose Enterprise Edition:

In Specify Installation Location, it should default as below:
Oracle Base: /u02/oradata/MYDB
Sofeware Location: /u02/oradata/MYDB/product/11.2.0/dbhome_1
13.  In Create Inventory, it should default as below:
Inventory Directory: /u02/app/oraInventory
oraInventory Group Name: oinstall
14.  In Select Configure Type, choose General Purpose / Transaction Processing:

(IMPORTANT!) In Specify Database Identifiers, configure as below:
Global database name: mydb.asaptp.com
Oracle Service Identifier (SID): MYDB
15.  In Specify Configuration Options, configure as below:
Memory -> Enable Automatic Memory Management: TRUE
Character sets: Use Unicode (AL32UTF8)
16.  In Specify Management Options, choose Use Database Control for database management but keep other else empty:

In Specify Database Storage Options, choose File System where:

Specify database file location: /u02/oradata/MYDB/oradata

In Specify Recovery Options, choose Do not enable automated backups:

In Specify Schema Passwords, I am a bit lazy so choose Use the same password for all accounts (don’t do this in production server!):

In Privileged Operating System Groups, confirm as below:
Database Administrator (OSDBA) Group: dba
Database Operator (OSOPER) Group: oinstall
17.   In Preform Prerequisite Checks, just simply ignore all warning message (since we are using Debian but not Oracle officially supported OS):
18.   Special note for Ubuntu 12.04: If you face error during installation so update as below:
19.   When you see the above error, open a new session to the Server and execute the below commands:
export ORACLE_HOME=/u02/oradata/MYDB/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
20.   Then press Continue and keep going …

21.   Now following the instructions and run the following commands with root user:
/u02/app/oraInventory/orainstRoot.sh
/
u02/oradata/MYDB/product/11.2.0/dbhome_1/root.sh
22.   Confirm with installation progress
23.   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

24.   login as oracle user root@ubs-desktop:~# su – oracle
25.   startup lsnrctl
oracle@ubs-desktop:~$ lsnrctl start
26.   startup database
oracle@ubs-desktop:~$ sqlplus sys as sysdba
SQL> startup;
SQL> alter user scott identified by tiger;
SQL> alter user scott account unlock;
SQL> exit

Troubleshoot -EM Daemon is not running

Quite often, the Enterprise Manager Database Control doesn’t work.  An error is seen as follows
$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
http://bassam-desktop:1158/em/console/aboutApplication
EM Daemon is not running.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Logs are generated in directory /u02/app/oracle/product/carried-desktop_orcl/sysman/log
FIX:-
Set date/time

  •         SQL>ALTER database SET TIME_ZONE ='Asia/Calcutta';
Run following commands

  1.        $ORACLE_HOME/sysman/lib
  2.        make -f ins_emagent.mk "agent"
  3.        snip ... -lnmemso -lcore11 -lnnz11 ...snip
Still not fixed????
Try  running:-

  •          emca -config dbcontrol db -repos recreate