Saturday, December 20, 2014

Oracle Database 11g Release 2 RAC On Oracle Linux 5.5 Using VirtualBox

Resources:



Software
Enterprise Linux 5.4 64-bit: https://edelivery.oracle.com/linux/


- Install Enterprise Linux 5.5 x64 Bit:


rac1.example.com
rac2.example.com
internal Network (eth0)
1.0.5.5
1.0.5.6
internal Network (eth1)
1.0.6.5
1.0.6.6
Nat (eth2)
10.0.4.5
10.0.4.6
HDD
50GB
50GB
RAM
4GB
4GB

Desktop Environments > GNOME Desktop Environment
Applications > Editors
Applications > Graphical Internet
Development > Development Libraries
Development > Development Tools
Servers > Server Configuration Tools
Base System > Administration Tools
Base System > Base
Base System > System Tools
Base System > X Window System

- install Packages
 


# From Oracle Linux 5 DVD
cd /media/cdrom/Server
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh elfutils-libelf-0.*
rpm -Uvh elfutils-libelf-devel-*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh-2*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
rpm -Uvh pdksh-5*
cd /
eject



- Linux Kernel Parameters for Oracle 11gR2 on RHEL 5, Edit the /etc/sysctl.conf and add following lines:
 

vim /etc/sysctl.conf
# kernel parameters for 11g installation
kernel.shmmni = 4096 
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128
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


- Now execute “sysctl -p” command to apply the new settings:
 

/sbin/sysctl -p


- Edit the /etc/security/limits.conf file and add following lines:
 

vim /etc/security/limits.conf
# shell limits for users oracle 11gR2
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   nofile   131072
oracle   hard   nofile   131072
oracle   soft   core     unlimited
oracle   hard   core     unlimited
oracle   soft   memlock  50000000
oracle   hard   memlock  50000000


- Edit the /etc/pam.d/login file and add following line:
 

vim /etc/pam.d/login
session    required     pam_limits.so


- To make the change permanent, modify the /etc/sysconfig/selinux change value of SELINUX variable to disabled:
 

vim  /etc/sysconfig/selinux
SELINUX=disabled


- To permanently disable the firewall we will disable the service:
 

service iptables stop
chkconfig iptables off


- create the user oracle account and the OS groups:
 

groupadd dba
groupadd oper
groupadd oinstall
groupadd asmdba
groupadd asmadmin
useradd -g oinstall -G dba,oper,asmdba,asmadmin oracle
passwd oracle


- Create the directories in which the Oracle software will be installed.
 

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


- Login as the "oracle" user and add the following lines at the end of the "/home/oracle/.bash_profile" file.
 

vim /home/oracle/.bash_profile
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR


ORACLE_HOSTNAME=rac1.example.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=racdb.example.com; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
GRID_HOME=/u01/app/11.2.0/grid; export GRID_HOME
DB_HOME=$ORACLE_BASE/product/11.2.0/db_1; export DB_HOME
ORACLE_HOME=$DB_HOME; export ORACLE_HOME
ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
BASE_PATH=/usr/sbin:$PATH; export BASE_PATH
PATH=$ORACLE_HOME/bin:$BASE_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


alias grid_env='. /home/oracle/grid_env'
alias db_env='. /home/oracle/db_env'


- Create a file called "/home/oracle/grid_env" with the following contents.
 

vim /home/oracle/grid_env
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_HOME=$GRID_HOME; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$BASE_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


- Create a file called "/home/oracle/db_env" with the following contents.
 

ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_HOME=$DB_HOME; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$BASE_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


- Amend the hostname in the "/etc/sysconfig/network" file.
 

vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac1.example.com


- Enter following data to “/ect/hosts”, rac-scan section is commented to avoid error "oracle cluster verification utility failed" must be resolved be DNS Server
 

vim /etc/hosts
127.0.0.1       localhost.localdomain   localhost


# Public
1.0.5.5   rac1.example.com   rac1
1.0.5.6   rac2.example.com   rac2


# Private
1.0.6.5   rac1-priv.example.com      rac1-priv
1.0.6.6   rac2-priv.example.com      rac2-priv


# Virtual
1.0.5.11   rac1-vip.example.com       rac1-vip
1.0.5.12   rac2-vip.example.com       rac2-vip


# SCAN
#1.0.5.15   rac-scan.example.com       rac-scan
#1.0.5.16   rac-scan.example.com       rac-scan
#1.0.5.17   rac-scan.example.com       rac-scan


- install oracle asm packages for os kernel
 

uname -rm # to know os kernel &  arch
rpm -Uvh oracleasm-support-2.1.7-1.el5.x86_64.rpm oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm oracleasmlib-2.0.4-1.el5.x86_64.rpm
/etc/init.d/oracleasm disable 
/etc/init.d/oracleasm enable
/etc/init.d/oracleasm configure -i
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: 


- Install Guest Additions: Log into the VM as the root user and add the "divider=10" option to the kernel boot options in "/etc/grub.conf" file to reduce the idle CPU load.
 


vim /etc/grub.conf
kernel /vmlinuz-2.6.18-308.24.1.0.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet numa=off divider=10




######### clone Virtual Machine rac1 to rac2 #######################
######## in rac1
-Use the "fdisk" command to partition the disks sdb to sde.
 

# fdisk /dev/sdb > n > p > 1 > w
# fdisk /dev/sdc > n > p > 1 > w
# fdisk /dev/sdd > n > p > 1 > w
# fdisk /dev/sde > n > p > 1 > w


- in rac1 create ASM disks, Mark the five shared disks as follows.
 

# /usr/sbin/oracleasm createdisk DISK1 /dev/sdb1
# /usr/sbin/oracleasm createdisk DISK2 /dev/sdc1
# /usr/sbin/oracleasm createdisk DISK3 /dev/sdd1
# /usr/sbin/oracleasm createdisk DISK4 /dev/sde1


###### in rac1, rac2 scan for refersh ASM disks
 

/usr/sbin/oracleasm scandisks
/usr/sbin/oracleasm listdisks


- Amend the hostname in the "/etc/sysconfig/network" file.
 

vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rac2.example.com


- Edit the "/etc/sysconfig/network-scripts/ifcfg-eth0, eth1 to change ip address for rac2
 

eth0 1.0.5.6  255.255.255.0   internal Network
eth1 1.0.6.6  255.255.255.0   internal Network
eth2 10.0.4.6 255.255.255.0   10.0.4.2 nat


- Edit the "/home/oracle/.bash_profile" file on the "rac2" node to correct the ORACLE_SID and ORACLE_HOSTNAME values.
 



ORACLE_SID=racdb2; export ORACLE_SID
ORACLE_HOSTNAME=rac2.example.com; export ORACLE_HOSTNAME


- Also, amend the ORACLE_SID setting in the "/home/oracle/db_env" and "/home/oracle/grid_env" files. - Create a file called "/home/oracle/grid_env" with the following contents.
 

vim /home/oracle/grid_env
ORACLE_SID=+ASM2; export ORACLE_SID


- edit a file called "/home/oracle/db_env" with the following contents.
vim /home/oracle/db_env
ORACLE_SID=racdb2; export ORACLE_SID



############ install NTP server #################

 

1.0.5.6  rac2.example.com NTP Server
1.0.5.5  rac1.example.com NTP Server



- NTP Server configure rac1,rac2 to load in boot startup
 
      
chkconfig ntpd on


- edit NTP server configuration file "/etc/ntp.conf"
 

vim /etc/ntp.conf
restrict 1.0.5.0 mask 255.255.255.0 nomodify notrap
server  1.0.5.5
server  1.0.5.6
fudge   1.0.5.6 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
   

- edit "/etc/sysconfig/ntpd" by add '-x' and '-g'
 

 vim /etc/sysconfig/ntpd
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"
SYNC_HWCLOCK=no


- start NTP server in rac1, rac2 and verify it's working
 

/etc/init.d/ntpd start
ntpdate -u 1.0.5.6  
ntpq -p



############# DNS Master & Slave Server configuration #################

 

1.0.5.5  rac1.example.com DNS Master
1.0.5.6  rac2.example.com DNS Slave



########### DNS Master configuration (rac1) ################
 

yum install -y bind bind-libs bind-utils system-config-bind
system-config-bind # to generate configuration files just run one time


- Edit main DNS file "named.conf"
 

vim /etc/named.conf 
options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
};


zone "." IN {
        type hint;
        file "named.root";
};


zone "example.com." IN {
        type master;
        file "example.fwd";
        allow-update { none; };
        allow-transfer { 1.0.5.6; };
};


zone "5.0.1.in-addr.arpa." IN {
        type master;
        file "example.rev";
        allow-update { none; };
        allow-transfer { 1.0.5.6; };
};

include "/etc/rndc.key";


- Create "example.fwd" for forward zone
 

cd /var/named/
cp -v localdomain.zone example.fwd
cp -v named.local example.rev


vim /var/named/example.fwd
$TTL    86400
@               IN SOA  rac1.example.com. root.rac1.example.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
         IN NS   rac1.example.com.
         IN NS   rac2.example.com.
rac1            IN A    1.0.5.5
rac2            IN A    1.0.5.6   
rac1-vip        IN A    1.0.5.11      
rac2-vip        IN A    1.0.5.12       
rac-scan        IN A    1.0.5.15       
rac-scan        IN A    1.0.5.16      
rac-scan        IN A    1.0.5.17



- create file "example.rev" for reverse zone:
 

vim /var/named/example.rev
$TTL    86400
@       IN      SOA     rac1.example.com. root.rac1.example.com.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN NS   rac1.example.com.
        IN NS   rac2.example.com.
5       IN PTR  rac1.example.com.
6      IN PTR  rac2.example.com.
11     IN PTR  rac1-vip.example.com.
12     IN PTR  rac2-vip.example.com.
15     IN PTR  rac-scan.example.com.
16     IN PTR  rac-scan.example.com.
17     IN PTR  rac-scan.example.com.


- change chroot premission to "named" group
 

chgrp named /etc/named.conf
chgrp named /var/named/example.fwd
chgrp named /var/named/example.rev


- Test DNS configuration and zone files for any syntax errors
 

named-checkconf  /etc/named.conf 
named-checkzone example.com /var/named/example.fwd
named-checkzone example.com /var/named/example.rev



########### Configure Slave DNS Server ##############
 


yum install -y bind bind-libs bind-utils system-config-bind
system-config-bind # to generate configuration files just run one time


- Edit main DNS file "named.conf"
 


vim /var/named.conf 
options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
};
zone "." IN {
        type hint;
        file "named.root";
};


zone "example.com." IN {
        type slave;
        file "slaves/example.fwd";
        allow-update { none; };
        masters { 1.0.5.5; };
};
zone "5.0.1.in-addr.arpa." IN {
        type slave;
        file "slaves/example.rev";
        allow-update { none; };
        masters { 1.0.5.5; };
};
include "/etc/rndc.key";



- Edit "/etc/resolv.conf" file in clients in rac1, rac2
 

vim /etc/resolv.conf
nameserver 1.0.5.5
nameserver 1.0.5.6
nameserver 8.8.8.8
search example.com



- Network Additions for DNS Server in rac1, rac2
 

vim /etc/sysconfig/network-scripts/ifcfg-eth0 >> PEERDNS=no
vim /etc/sysconfig/network-scripts/ifcfg-eth1 >> PEERDNS=no
vim /etc/sysconfig/network-scripts/ifcfg-eth2 >> PEERDNS=no


- restart DNS server in rac1, rac2
 

/etc/init.d/named restart


- Verfiy DNS Server working in rac1, rac2
 

dig rac1.example.com
dig rac2.example.com
dig -x 1.0.5.5
dig -x 1.0.5.6
nslookup rac1
nslookup rac2
nslookup rac1-vip
nslookup rac2-vip
nslookup rac-scan



############### install grid software ##################
- Extract grid software to rac1 and extract it to gird as user oracle
 

unzip -d /tmp /media/db_112010_lnx64/linux.x64_11gR2.zip
unzip -d /tmp /media/db_112010_lnx64/linux.x64_11gR2_database_1of2
unzip -d /tmp /media/db_112010_lnx64/linux.x64_11gR2_database_2of2


- generate ssh keys between rac1,rac2 using grid software utility (sshUserSetup.sh)
 

cd /tmp/grid/sshsetup/
./sshUserSetup.sh -user oracle -hosts "rac1 rac2" -noPromptPassphrase -confirm -advanced

 - test rac1,rac2 using grid software utility (runcluvfy.sh)
cd /tmp/grid/
./runcluvfy.sh stage -pre crsinst -n rac1,rac2
./runInstaller




########## Verify RAC installation ###########

 


srvctl config database -d racdb
srvctl status database -d racdb
srvctl status listener
srvctl status asm


Status of your database can be visible in OEM 
https://rac1.example.com:1158/em/



########## shutdown RAC databases #############

 


emctl stop dbconsole
srvctl stop database -d racdb
srvctl stop instance -d racdb -i racdb1,racdb2
srvctl stop asm -n rac1 -o immediate


No comments:

Post a Comment