Monday, September 7, 2015

Oracle 11g Release 2 (11.2.0.4.0) Database Installation On Red Hat Enterprise Linux Server release 6.7(Santiago)

This Document shows the step by step of installing and setting up Oracle 11g Release 2 (11.2.0.4.0) database on Red Hat Enterprise Linux Server release 6.7 (Santiago) server.

The Installation is divided into three parts:
1. Pre-Installation Tasks
2. Installation of Oracle 11g Release 2 (11.2.0.4.0) 64bit Database
3. Post-Installation Tasks

1. Pre-Installation tasks.
1.1. Unpack Files
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip

1.2. Hosts File
The "/etc/hosts" file must contain a fully qualified name for the server.
172.31.10.34 qpaydb.nblbd.com   qpaydb

1.3. Kernel Parameter settings
Oracle recommend following kernel parameter setting
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
#kernel.shmmax = 536870912
kernel.shmmax = 10737418240
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586

The current parameter setting can be tested below following command
#/sbin/sysctl -a | grep net.core.wmem_max

Add or amend the following lines in the "/etc/sysctl.conf" file.
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
#kernel.shmmax = 536870912
kernel.shmmax = 10737418240
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586


1.4. Hard and soft limit setup
Add the following lines to the "/etc/security/limits.conf" file.
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  4096
oracle              hard    nofile  65536
oracle              soft    stack   10240

Add the following lines to the " /etc/security/limits.d/90-nproc.conf" file.
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited
# To this
* - nproc 16384

1.5. Set Secure Linux to disable
Set secure Linux to disable/permissive by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.
SELINUX=disabled

1.6. Patch Requirement Check 
>Login as "root" user
binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6.i686
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6.i686
ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6.i686
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6.i686
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6.i686
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6.i686
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)
numactl-devel-2 (x86_64)
sysstat-9(x86_64)
compat-libstdc++-33.i686
compat-libcap
unixODBC-2.2.14-11.el6 (x86_64) or later
unixODBC-2.2.14-11.el6.i686 or later
unixODBC-devel-2.2.14-11.el6 (x86_64) or later
unixODBC-devel-2.2.14-11.el6.i686 or later
elfutils-libelf-devel-0.97

Note: yum install elfutils* [From yum install]

Command:
rpm -qa |grep -i binutils-2*
rpm -qa |grep -i make-3*
rpm -Uvh binutils-2*

1.7. Create required Groups and user.
-Enter the following commands to create the oinstall and dba groups (from "root" user):

# groupadd oinstall
# groupadd dba
# groupadd oper

 -Complete the following actions to create oracle user (from root user):
# useradd -g oinstall -G dba,oper oracle
# passwd oracle

#chown oracle:oinstall /home/oracle
$chmod -R 777 .bash_profile  [Login as "oracle" user]

1.8. Create required Directories.
-Login as "root" user
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/product/11.2.0.4.0/dbhome_1
chown -R oracle:oinstall /u01/app
chown -R oracle:oinstall /u01/app/oracle/product/11.2.0.4.0/dbhome_1
chmod -R 775 /u01/app
chmod -R 775 /u01/app/oracle/product/11.2.0.4.0/dbhome_1

1.9. Create oracle user environment.
-Login as "oracle" user

$ vi .bash_profile
ORACLE_HOSTNAME=qpaydb.nblbd.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=remitdb; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=remitdb; export ORACLE_SID

PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

$. ./.bash_profile   [To run Profile]
$echo ORACLE_HOME  [To check profile variable] 

<<Use full Command>>
# grep dba /etc/group   [Group Check]
# grep MemTotal /proc/meminfo  [RAM Size[
#cat /etc/redhat-release   [ Redhat Release]
#uname -m [system architecture[
# grep SwapTotal /proc/meminfo  [swap total]
#free [Availabe  memory and swap space
# df -h /dev/shm/  --Amount of shared memory available
#/sbin/sysctl -a | grep <param-name> --kernel paramter current value

2. Installation of Oracle 11g Release 2 (11.2.0.4.0) 64-bit Database

-Login as "oracle" user
-xmanager3 for GUI
$ cd /u01/soft/database
$./runInstaller

a. Un-check i wise to receive security updates via oracle support and click next >

b. Choose Skip Software Updates.

c. Select radio button 'Install database software only' and click Next> 

d. Select radio button 'Single instance database installation' and click Next>

e. Accept 'English' as language and click Next > 

f. Select radio button 'Enterprise Edition' and click Next>



g. Specify path for oracle base(ORACLE_BASE) and location where we want to store the software (ORACLE_HOME). Click ' Next>'

h. Specify path for oracle Inventory and Click 'Next >'


i. Assign groups as below:
Database Administrator (OSDBA) Group: dba
Database Operator(OSOPER) Group(Optional): oper

j. Perform pre-requisite check.

k. Pre-requisite.

l. Pre-requisite(again).

m. Summary.

n. Install product.

o. Run Scripts.

p. Installation complete.

>>Run NETCA to Create Listener
su - oracle
cd $ORACLE_HOME/bin/
netca

a. Net configuration Assistance: welcome

b. Net configuration Assistance: Listener Configuration, Listener

c. Net configuration Assistance: Listener Configuration, Listener Name

d. Net configuration Assistance: Listener Configuration, Select protocols

e. Net configuration Assistance: Listener Configuration, Select port

f. Net configuration Assistance: Listener Configuration, More Listener?

g. Net configuration Assistance: Listener Configuration, done

>>Run DBCA to Create Database
su - oracle
cd $ORACLE_HOME/bin/
dbca
a. welcome to Database configuration assistant.

b. Choose option 'Create a Database' and click 'Next >'

c. Select the database template that you want to use for your database and click ' next >'

d. Select the global database name that you want to use for your database and click ' next >'

e. select the options you want use to manage your database and click 'Next >'
>>Enterprise Manager

>>Enable automatic maintenance tasks

f. Type the password you want to use and click 'Next >'

g. select database file location for all database files. Storage type-File system.

h. select Fast Recovery area and Fast recovery area size & enable archiving.

> File location variables.

i. Select if you want to have sample schemas created in database and click 'Next>'

j. Review and change the settings for-
>>Memory Settings
>>Character sets

>>Connection mode

>>All initialization parameters setting

k. Database storage setting- 
>> Control files:

>> Data files:

>> Redo log groups:

l. Make sure the tick box 'Create Database' is ticked and click 'Finish'. 

n. Review the database configuration details again and click 'Ok'.

>> The generation of the script is successful

Note: AWR operation failed CATPROC not valid (it doesn't make any problem overall installation)

>> The database configuration has completed successfully


 m. The database is now created, we can either change or unlock password or just click Exit to finish the database creation.



3. Post-Installation Tasks
a. Listener & tnsnames
[oracle@qpaydb ~]$ cd $ORACLE_HOME/network/admin
[oracle@qpaydb admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.31.10.34)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@qpaydb admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

REMITDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.31.10.34)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = remitdb.nblbd.com)
    )
  )
b. Automatic startup and shutdown database
>> Login as "Root" user
>> Edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.
[root@qpaydb ~]# vi /etc/oratab
#



# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
remitdb:/u01/app/oracle/product/11.2.0.4.0/dbhome_1:Y

>> Create a file called dbora in /etc/init.d
[root@qpaydb ~]#vi /etc/init.d/dbora
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.

ORA_OWNER=oracle

case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        # Remove "&" if you don't want startup as a background process.
        su $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" &

        touch /var/lock/subsys/dbora
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        su $ORA_OWNER -c "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
        rm -f /var/lock/subsys/dbora
        ;;

esac

>> Use the chmod command to set the privileges to 750.
[root@qpaydb ~]#chmod 750 /etc/init.d/dbora

>> Associate the "dbora" service with the appropriate run levels and set it to auto-start using the following command.
[root@qpaydb ~]#chkconfig --add dbora

>>Create the "startup.sh" and "shutdown.sh" scripts in the "/home/oracle/scripts". First create the directory.
[root@qpaydb ~]# mkdir -p /home/oracle/scripts
[root@qpaydb ~]# chown oracle:oinstall /home/oracle/scripts

>>The "/home/oracle/scripts/startup.sh" script should contain the following commands.
[root@qpaydb ~]# vi /home/oracle/scripts/startup.sh
#!/bin/bash
export TMP=/tmp
export TMPDIR=$TMP
export PATH=/usr/sbin:/usr/local/bin:$PATH
export ORACLE_HOSTNAME=qpaydb.nblbd.com
export ORACLE_UNQNAME=remitdb
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4.0/dbhome_1

export ORACLE_SID=remitdb
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES

# Start Listener
lsnrctl start

# Start Database
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF

# start the Enterprise Manager db console

$ORACLE_HOME/bin/emctl start dbconsole

>>The "/home/oracle/scripts/shutdown.sh" script should contain the following commands.
[root@qpaydb ~]# vi /home/oracle/scripts/shutdown.sh
#!/bin/bash

export TMP=/tmp
export TMPDIR=$TMP
export PATH=/usr/sbin:/usr/local/bin:$PATH
export ORACLE_HOSTNAME=qpaydb.nblbd.com
export ORACLE_UNQNAME=remitdb
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4.0/dbhome_1

export ORACLE_SID=remitdb
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES

# Stop Database
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF

# Stop Listener
lsnrctl stop

# stop the Enterprise Manager db console
$ORACLE_HOME/bin/emctl stop dbconsole

>> permissions and ownership of the files.
[root@qpaydb ~]# chmod u+x /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh
[root@qpaydb ~]# chown oracle:oinstall /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh

>> The listener and database will now start and stop automatically with the machine. You can test them using the following command as the "root" user.
[root@qpaydb ~]# service dbora start

[root@qpaydb ~]# service dbora stop

c.  Create Tablespace and user.

>>Tablespace
CREATE TABLESPACE QPAYDB DATAFILE '/qpaydb/remitdb/qpaydb01.dbf' SIZE 30g REUSE AUTOEXTEND ON NEXT 100M MAXSIZE unlimited LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
CREATE TABLESPACE QPAYDBINDEX DATAFILE '/qpaydb/remitdb/qpaydbindex01.dbf' SIZE 5g REUSE AUTOEXTEND ON NEXT 100M MAXSIZE unlimited LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; 

>>User
CREATE USER nblrms IDENTIFIED BY nblrms DEFAULT TABLESPACE QPAYDB TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON QPAYDB QUOTA UNLIMITED ON QPAYDBINDEX QUOTA UNLIMITED ON SYSTEM ACCOUNT UNLOCK;
GRANT CREATE VIEW TO NBLRMS;
GRANT DEBUG ANY PROCEDURE TO NBLRMS;
GRANT DEBUG CONNECT SESSION TO NBLRMS;
GRANT UNLIMITED TABLESPACE TO NBLRMS;
GRANT EXECUTE ON SYS.DBMS_CRYPTO TO NBLRMS;
GRANT CONNECT TO NBLRMS;
GRANT EXP_FULL_DATABASE TO NBLRMS;
GRANT IMP_FULL_DATABASE TO NBLRMS;
GRANT RESOURCE TO NBLRMS;
GRANT dba TO NBLRMS;

CREATE USER sms IDENTIFIED BY sms DEFAULT TABLESPACE QPAYDB TEMPORARY TABLESPACE TEMP ACCOUNT UNLOCK;
GRANT CREATE SESSION TO SMS;
GRANT UNLIMITED TABLESPACE TO SMS;
GRANT SELECT ON NBLRMS.AGENT TO SMS;
GRANT UPDATE ON NBLRMS.AGENT TO SMS;
GRANT SELECT ON NBLRMS.COUNTRY TO SMS;
GRANT UPDATE ON NBLRMS.COUNTRY TO SMS;
GRANT SELECT ON NBLRMS.SMS_INFO TO SMS;
GRANT UPDATE ON NBLRMS.SMS_INFO TO SMS;
GRANT RESOURCE TO SMS;

>>Directory
create directory recon_dir as '/u01/soft';

grant read,write,execute on directory recon_dir to nblrms; 

>>Import user
impdp nblrms/nblrms directory=recon_dir dumpfile=RMS_QPAYDB_V27.08.15.DMP logfile=RMS_QPAYDB_V27_08_15.log

>>Log file
ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE ADD LOGFILE GROUP 1 ('/qpaydb/remitdb/redo01a.rdo', '/qpaydb/remitdb/redo01b.rdo') SIZE 100M;

ALTER DATABASE DROP LOGFILE GROUP 2;
ALTER DATABASE ADD LOGFILE GROUP 2 ('/qpaydb/remitdb/redo02a.rdo', '/qpaydb/remitdb/redo02b.rdo') SIZE 100M;

ALTER DATABASE DROP LOGFILE GROUP 3;
ALTER DATABASE ADD LOGFILE GROUP 3 ('/qpaydb/remitdb/redo03a.rdo', '/qpaydb/remitdb/redo03b.rdo') SIZE 100M;

ALTER DATABASE DROP LOGFILE GROUP 4;
ALTER DATABASE ADD LOGFILE GROUP 4 ('/qpaydb/remitdb/redo04a.rdo', '/qpaydb/remitdb/redo04b.rdo') SIZE 100M;

ALTER DATABASE DROP LOGFILE GROUP 5;
ALTER DATABASE ADD LOGFILE GROUP 5 ('/qpaydb/remitdb/redo05a.rdo', '/qpaydb/remitdb/redo05b.rdo') SIZE 100M;

No comments:

Post a Comment