Thursday, February 27, 2014

Step by Step Oracle (11.2.0.3) Installation on OEL 5.9

-- Check Physical RAM.
# grep MemTotal /proc/meminfo
MemTotal:      2075424 kB

-- Check Swap Space.
# grep SwapTotal /proc/meminfo
SwapTotal:     3148732 kB


# df -h /dev/shm/
Filesystem            Size  Used Avail Use% Mounted on
tmpfs                1014M     0 1014M   0% /dev/shm

#gedit /etc/fstab

tmpfs  /dev/shm    tmpfs  size=42G  0 0

For Permanent:
mount -o remount /dev/shm

Make sure that there is an entry in /etc/hosts file for your machine like this:

[IP-address]  [fully-qualified-machine-name]  [machine-name]

Next we need to adjust the Linux Kernel Parameters to support Oracle.
Open /etc/sysctl.conf and add the following lines:

# Oracle settings
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
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
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304

-- Make the kernel parameters changes effective immediately:
# /sbin/sysctl -p


Now setup User that we will use as Oracle owner and the groups that it will need for installing and managing Oracle.

/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/groupadd oper
/usr/sbin/useradd -g oinstall -G dba,oper oracle
/usr/bin/passwd oracle

Create directories where the Oracle Software and database will be installed.

mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01
chmod -R 0775 /u01

Open /etc/security/limits.conf and add these lines.

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

Open /etc/pam.d/login and add the following line if it is already not there.

session    required     pam_limits.so

Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows:

SELINUX=disabled

cd /dvd_mount_point/Server

For RHEL 5 (32-bit):

rpm -Uvih libaio-devel-0*
rpm -Uvih numactl-devel-0*
rpm -Uvih sysstat-7*
rpm -Uvih unixODBC-2*
rpm -Uvih unixODBC-devel-2*


For RHEL 5 (64-bit):

rpm -ivh binutils-2.17.50.0.6-12.el5.x86_64.rpm compat-libstdc++-33-3.2.3-61.* libstdc++-devel-4.1.2-46.el5.* elfutils-libelf-* gcc-4.1.2-46.el5.x86_64.rpm gcc-c++-4.1.2-46.el5.x86_64.rpm glibc-2.5-42.* glibc-devel-2.5-42.* glibc-headers-2.5-42.x86_64.rpm ksh-20080202-14.el5.x86_64.rpm --aid --force


rpm -Uvih numactl-devel-0*`uname -p`*
rpm -Uvih sysstat-7*`uname -p`*
rpm -Uvih unixODBC-2*`uname -p`*
rpm -Uvih unixODBC-2*i386*
rpm -Uvih unixODBC-devel-2*`uname -p`*
rpm -Uvih unixODBC-devel-2*i386*
rpm -Uvih libaio-devel-0*`uname -p`*
rpm -Uvih libaio-devel-0*i386*
rpm -Uvih glibc-devel-2*i386*


Allow the user oracle to use X server, which it will need to run Oracle Universal Installer.

# xhost +SI:localuser:oracle

Now switch to the user oracle.

# su - oracle

-- Let's see which shell is being used by the user Oracle.
$ echo $SHELL
/bin/bash

If the returned shell is bash then open ~/.bash_profile and add these lines:

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

# If /tmp doesn't have 1G space free then you can workaround it by
# pointing the variables TMP AND TMPDIR to a location where you have
# sufficient space.

#ORACLE_HOSTNAME=ora11g.home.com; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=dbname; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH

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

umask 022


Now run the following command to make these changes effective in the current session of user oracle.

-- for bash shell
$ source ~/.bash_profile



Once Download/Copy is done unzip the media as follows:

$ cd /home/oracle
$ ls
linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip
$
$ unzip linux_11gR2_database_1of2.zip
$ unzip linux_11gR2_database_2of2.zip


Once the unzip is finished go to the "database" directory unzipped in the previous step and start the Oracle Universal Installer.

$ cd /home/oracle/database/
$ ./runInstaller



Step by Step Switchover and Switchback from Physical standby to Primary in Oracle 11g R2

 STEPS OF ACTIVE DATAGUARD SWITCHOVER

* Here Prim is a Primary and Stan is Standby Database*
                                 
Convert primary database to standby


First verify that the primary database can be switched to the standby role

 SQL>  select open_mode,database_role,switchover_status from v$database;

OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- ---------------- --------------------
READ WRITE           PRIMARY          TO STANDBY


CONNECT SYS/SYS123@PRIM AS SYSDBA
ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN;

NOW DATABASE IS DOWN MODE

STARTUP
OR
{
STARTUP NOMOUNT;
ALTER DATABASE MOUNT STANDBY DATABASE;
ALTER DATABASE OPEN;
}

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
RECOVERY NEEDED

-- Convert standby database to primary

CONNECT SYS/SYS123@STAN AS SYSDBA
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

SQL> select status from v$instance;
STATUS
------------
MOUNTED

NOW DATABASE IS MOUNT MODE

ALTER DATABASE OPEN;

SQL> select status from v$instance;
STATUS
------------
OPEN


ON OLD PRIMARY

CONNECT SYS/SYS123@PRIM AS SYSDBA
ALTER DATABASE  RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION ;


SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
NOT ALLOWED




*************************

For Switchback  follow in reverse order