Professional Documents
Culture Documents
Hands-on Workshop
January 2012
Authors:
Efran Snchez
Platform Technology Manager
Oracle Server Technologies, PTS
Contributors / Reviewers:
Andr Sousa
Senior Technologist
Oracle Server Technologies, PTS
Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
U.S.A.
Worldwide Inquiries:
Phone: +1.650.506.7000
Fax: +1.650.506.7200
www.oracle.com
During this RAC workshop you will setup a RAC cluster using Oracle Clusterware and Oracle Database
11g. The cluster will be setup on Oracle Enterprise Linux.
A cluster comprises multiple interconnected computers or servers that appear as if they are one server
to end users and applications. Oracle Database 11g Real Application Clusters (RAC) enables the
clustering of the Oracle Database. RAC uses the Oracle Clusterware for the infrastructure to bind
multiple servers so that they operate as a single system.
Your first step in the workshop will be configuring the operating system for the Clusterware and RAC
software.
Each server in the cluster will have one public network interface and one private network interface.
The public network interface is the standard network connection, which connects the server to all of
the other computers in your network. The private network interface is a private network connection
shared by only the servers in the cluster. The private network interface is use by the Oracle
Clusterware and RAC software to communicate between the servers in the cluster.
All of the database files in the cluster will be stored on shared storage. The shared storage allows
multiple database instances, running on different servers, to access the same database information.
Your next step in the workshop will be to install the Oracle Clusterware, which binds multiple servers
into a cluster. During the Clusterware install you will specify the location to create two Clusterware
components: a voting disk to record node membership information and the Oracle Cluster Registry
(OCR) to record cluster configuration information. The Clusterware install is performed on one server
and will be automatically installed on the other servers in the cluster.
After the Clusterware is installed, you will install the Oracle Database and RAC software. The installer
will automatically recognize that the Clusterware has already been installed. Like the Clusterware
install, the database and RAC install is performed on one server and the software will be automatically
installed on the other servers in the cluster.
A virtual IP address is an alternate public address that client connections use instead of the standard
public IP address. If a node fails, then the node's VIP fails over to another node on which the VIP
cannot accept connections. Clients that attempt to connect to the VIP receive a rapid connection
instead of waiting for TCP connect timeout messages.
After the database software is installed you will create a database using the Database Configuration
Assistant.
Some parts of this workshop are based on the article Build Your Own Oracle RAC 11g Cluster on Oracle
Enterprise Linux and iSCSI by Jeffrey Hunter.
Platform Technology Solutions, Latin America
We hope going through this step by step guide to install Oracle Real Application Clusters (RAC) will be a
great learning experience for those interested in trying out Oracle Grid technology. This guide is an
example of installing a 2-node RAC cluster, but the same procedure applies for single instance
database managed by the grid infrastructure services.
This guide performs the roles of both sys admin and a DBA. You must have root privileges to perform
some of the steps
Operating System
This guide assumes the systems are pre-installed with either Oracle Enterprise Linux 5 or Red Hat
Enterprise AS/ES 5. If your system does not have the correct operating system some steps will not
work and the install may not perform as expected.
Storage
Oracle Real Application Clusters requires shared storage for its database files. This guide will use
Oracle Automatic Storage Management (ASM) during the install for the storage management.
Platform Technology Solutions, Latin America
1. Login as root user and open a terminal window, review the local-cdrom repository
configuration using cat to display the file content:
[ol5_u7_base_cdrom]
name=Oracle Linux $releasever - U7 - $basearch - base cdrom
baseurl=file:///media/cdrom/Server/
gpgcheck=0
enabled=1
[ol5_u7_cluster_cdrom]
name=Oracle Linux $releasever - U7 - $basearch - cluster cdrom
baseurl=file:///media/cdrom/ClusterStorage/
gpgcheck=0
enabled=1
Insert the DVD or configure the ISO file in Virtualbox, right click the cdrom icon on the
Virtualbox status bar, click Choose a virtual CD/DVD disk file and select the corresponding
ISO File.
Un-mount the cdrom from the current automount directory and re-mount it in /mnt/cdrom
umount /dev/cdrom
mount /dev/cdrom /media/cdrom
yum repolist
2. The oracle-validated package verifies and sets system parameters based configuration
recommendations for Oracle Linux, the files updated are:
/etc/sysctl.conf
/etc/security/limits.conf
/etc/modprobe.conf
/boot/grub/menu.lst
This package will modify module parameters and re-insert them, it also installs any required
packages for Oracle Databases.
It's recommended that you also install these packages for previous versions compatibility :
4. Clean all cached files from any enabled repository. It's useful to run it from time to time to
make sure there is nothing using unnecessary space in /var/cache/yum.
Eject the cdrom and disable the ISO image in order not to boot the OS Installation on next re-
boot.
Optionally you can configure the public yum repository to install new updates in the future, skip this
step for the workshop:
6. Download and install the Oracle Linux 5 repo file to your system.
# cd /etc/yum.repos.d
# wget http://public-yum.oracle.com/public-yum-el5.repo
7. Enable both the [ol5_u7_base] repositories in the yum configuration file by changing enable=0
to enable=1 in those sections.
# yum update
Platform Technology Solutions, Latin America
Open a terminal window, su to root and run the following commands. Alternatively, if you are not
comfortable with scripting the update to the /etc/sysctl file.
vi /etc/sysctl.conf
Optionally for production systems you can configure the OS to reboot in case of a kernel panic
Review also the following files modified by the oracle-validated package on each node of the cluster:
/etc/security/limits.conf
/etc/pam.d/login
Open a terminal window and run the following commands. Alternatively use vi to update the values in
the default profile file.
Run the following command to make the changes immediately effective instead of rebooting the
machine.
/sbin/sysctl -p
Disable secure Linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set
as follows:
SELINUX=disabled
/etc/rc.d/init.d/iptables stop
chkconfig iptables off
Repeat these the same procedure for each database node in the cluster.
Platform Technology Solutions, Latin America
# Admin Network
10.0.3.11 db1
10.0.3.12 db2
# Private Network
10.0.4.11 db1-priv
10.0.4.12 db2-priv
10.0.4.21 nas01
After the /etc/hosts file is configured on db1 copy the file to the other node(s) (db2) using scp. You
will be prompted to enter the root password of the remote node(s) for example:
As root, verify network configuration by pinging db1 from db2 and vice versa. As root, run the
following commands on each node.
ping -c 1 db1
ping -c 1 db2
ping -c 1 db1-priv
ping -c 1 db2-priv
Platform Technology Solutions, Latin America
Note that you will not be able to ping the virtual IPs (db1-vip, etc.) until after the clusterware is
installed, up and running.
If you find any problems, run as root user, the network configuration program:
/usr/bin/system-config-network
To make this change permanent, add MTU=1500 at the end of this the eth1 configuration file
nslookup db-cluster-scan
Server: 10.0.5.254
Address: 10.0.5.254#53
Name: db-cluster-scan.local.com
Address: 10.0.5.20
Platform Technology Solutions, Latin America
If the Network Time Protocol (NTP) service is not available or properly configured, you can use Cluster
Time Synchronization Service to provide synchronization service in the cluster but first you need to de-
configure and de-install current NTP configuration.
To deactivate the NTP service, you must stop the existing ntpd service, disable it from the
initialization sequences and remove the ntp.conf file. To complete these steps on Oracle Enterprise
Linux, run the following commands as the root user on both Oracle RAC nodes:
Also remove the following file (This file maintains the pid for the NTP daemon) :
rm /var/run/ntpd.pid
modprobe hangcheck-timer
Run the following command as root to start hangcheck-timer automatically on system startup
As root on both db1 and db2, create the groups, dba, oinstall and the user oracle.
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/groupadd oper
/usr/sbin/groupadd asmadmin
/usr/sbin/groupadd asmdba
/usr/sbin/groupadd asmoper
The following command will create the oracle user and the users home directory with the default group
as oinstall and secondary group as dba. The user default shell will be bash. Useradd unix man pages
will provide additional details on the command:
Set the password for the oracle and grid account, use welcome1.
passwd oracle
passwd grid
Verify that the attributes of the user oracle are identical on both db1 and db2
id oracle
id grid
Platform Technology Solutions, Latin America
uid=54321(oracle) gid=54321(oinstall)
groups=54321(oinstall),54322(dba),54324(asmadmin),54325(asmdba)
uid=102(grid) gid=54321(oinstall)
groups=54321(oinstall),54324(asmadmin),54325(asmdba),54326(asmoper)
Enable xhost permissions is case you want to login with root and switch to oracle or grid user:
xhost +
Re-Login or switch as oracle OS user and edit .bash_profile file with the following:
umask 022
if [ -t 0 ]; then
stty intr ^C
fi
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/rac
#export ORACLE_SID=<your sid>
export ORACLE_PATH=/u01/app/oracle/common/oracle/sql
export ORACLE_TERM=xterm
PATH=${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
Login or switch as grid user and edit .bash_profile with the following
umask 022
if [ -t 0 ]; then
stty intr ^C
fi
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/grid/11.2.0/infra
#export ORACLE_SID=<your sid>
export CV_NODE_ALL=db1,db2
export CVUQDISK_GRP=oinstall
export ORACLE_PATH=/u01/app/oracle/common/oracle/sql
export ORACLE_TERM=xterm
PATH=${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
mkdir -p /u01/app/oracle/product/11.2.0/rac
chown -R oracle:oinstall /u01/app
mkdir -p /u01/app/grid/11.2.0/infra
chown -R grid:oinstall /u01/app/grid
OPTIONAL: Oracle 11gR2 installer now configures ssh keys across all nodes in the cluster, but if you
want to manually configure them, use the following steps:
NOTE: If you switch or oracle user, you must use the - option for example: su oracle, so
that the shell environment correctly set
mkdir .ssh
Create RSA and DSA type public and private keys on both nodes.
ssh-keygen -t rsa
ssh db2 /usr/bin/ssh-keygen -t rsa
This command writes the public key to the /home/oracle/.ssh/id_rsa.pub file and the private key
to the /home/oracle/.ssh/id_rsa file.
ssh-keygen -t dsa
ssh db2 /usr/bin/ssh-keygen -t dsa
This command writes the public key to the /home/oracle/.ssh/id_dsa.pub file and the private key
to the /home/oracle/.ssh/id_dsa file.
On node 1:
Concatenate the rsa and dsa public keys of both nodes into one file called authorized_keys with the
following commands, execute one-by-one.
Check the connections with the following commands in both nodes. Execute each line, one at a
time and choose to permanently add the host to the list of known hosts.
ssh db1 date; ssh db2 date; ssh db1-priv date; ssh db2-priv date
To allow Oracle Clusterware to better tolerate network failures with NAS devices or NFS
mounts, enable the Name Service Cache Daemon (nscd).
To change the configuration to ensure that nscd is on for both run level 3 and run level 5, enter
the following command as root:
#!/bin/sh
BUS=${1}
HOST=${BUS%%:*}
LUN=`echo ${BUS} | cut -d":" -f4` [ -e /sys/class/iscsi_host ] || exit 1
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session:session*/targetname"
target_name=`cut -d":" -f2 ${file}`
if [ -z "${target_name}" ]; then
exit 1
fi
echo "${target_name} ${LUN}"
Check that the /dev/iscsi links are created, notice the order assigned.
ls -l /dev/iscsi
chkconfig iscsid on
service iscsid start
setsebool -P iscsid_disable_trans=1
Now we are going to partition the disks, we will use the the first partition for the grid infrastructure
diskgroup.
Partition1 100 Mb
Partition2 Remaining space
First Disk
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1009, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1009, default 1009): +100M
WARNING: Re-reading the partition table failed with error 16: Device or
resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
A method for cloning a partition table in linux is to use sfdisk, we are going to apply the same
configuration for all disks.
sfdisk -d /dev/iscsi/nas01.disk01.p>disk01part.txt
sfdisk /dev/iscsi/nas01.disk02.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk03.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk04.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk05.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk06.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk07.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk08.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk09.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk10.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk11.p<disk01part.txt
sfdisk /dev/iscsi/nas01.disk12.p<disk01part.txt
Platform Technology Solutions, Latin America
Initialize all block devices with the following commands from db1:
partprobe
Make sure the two ASM packages are installed in both nodes, becase asmlib driver is implemented on
the new Oracle Unbrekable Kernel we no longer need to install oracleasmlib package:
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Every disk that ASMLib is going to be accessing needs to be made available. This is accomplished by
creating an ASM disk in db1:
/etc/init.d/oracleasm listdisks
When a disk is marked with asmlib, other nodes have to be refreshed, just run the 'scandisks' option on
db2:
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks [ OK ]
NAS01_GRID01
NAS01_GRID02
NAS01_GRID03
NAS01_GRID04
Because we are going to use asmlib support, we no longer need to assign permissions to block devices
upon reboot in /etc/rc.local file, asmlib will take care of that.
Platform Technology Solutions, Latin America
The nslookup binary will be executed by the Cluster Verification Utility during the Oracle grid
infrastructure install.
Server: 10.0.5.254
Address: 10.0.5.254#53
Name: node-cluster-scan.local.com
Address: 10.0.5.20
We need to add at least 1 VNC user/group, open the file /etc/sysconfig/vncservers as root and
add the information shown:
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768 -depth 16"
To add some security we need to add a password that must be given before a connection can be
established, open a terminal and type:
$ vncpasswd
To start the server we type the command 'vncserver' and the session you wish to start, in this case
root(if you have set up more than 1 entry in the /etc/sysconfig/vncservers file:
[root@db1 ~] vncserver :1
Now the server is started and a user could connect, however they will get a plain grey desktop by
default as the connection will not cause a new session of X to start by default, to fix this we need to
edit the startup script in the .vnc folder in your home directory.
vi ~/.vnc/xstartup
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
As the file says make sure the two lines at the top are uncommented by removing the leading # sign.
Next we need to restart vncserver to pick up the changed we just made. To restart the vncserver we
need to kill the process and start a new one as root:
$ vncserver -kill :1
$ vncserver :1
The Cluster Verify Utility automatically checks all nodes that are specified, but first we need to install
the cvuqdisk rpm required for the CVU, on both nodes.
su -
export CVUQDISK_GRP=asmadmin
cd /install/11gR2/grid/rpm
rpm -ivh cvuqdisk-*
ssh root@db2
export CVUQDISK_GRP=asmadmin
rpm -ivh /install/11gr2/grid/rpm/cvuqdisk-*
Re-login in the OS Desktop graphical user interface using the grid user, execute the following
commands (if you are installing only one node replace -n all switch with -n db1) :
cd /install/11gR2/grid
Ignore memory and kernel parameters errors, installer will generate a script for you to run as
root user to change them to the correct kernel values.
You may need to update some rpms as ROOT user in BOTH NODES
Check time difference between the nodes, if there is more than one second, update the time manually
as root user using an ntp server and update hardware clock:
2.1 Install 11g Grid Infrastructure, former 10g Cluster Ready Services
(CRS)
The installer needs to be run from one node in the cluster under an X environment. Run the following
steps in VNC (or another X client) on only the first node in the cluster as grid user.
/install/11gR2/grid/runInstaller
Identify the network interface to be used for the "Public" and "Private" network.
Make any changes necessary to match the values in the table below:
/dev/oracleasm/disks/*
Create an ASM Disk Group that will be used to store the Oracle Clusterware files
according to the values in the following values:
Click Next
Review default values, those are preloaded from the environment variables we
already set in the OS user.
Specify Installation Location
Click Next
Inventory Directory: /u01/app/oraInventory
Create Inventory oraInventory Group Name: oinstall
If OUI detects an incomplete task that is marked "fixable", then you can easily fix
the issue by generating the fixup script by clicking the [Fix & Check Again] button.
The fixup script is generated during installation. You will be prompted to run the
Prerequisite Checks script as root in a separate terminal session.
Ignore the Device Checks for ASM error by selecting the Ignore All checkbox
The installer performs the Oracle grid infrastructure setup process on both Oracle
Setup
RAC nodes.
Run the orainstRoot.sh script on both nodes in the RAC cluster:
Within the same new console window on both Oracle RAC nodes in the cluster,
(starting with the node you are performing the install from), stay logged in as the
root user account. Run the root.sh script on both nodes in the RAC cluster one at a
time starting with the node you are performing the install from:
The root.sh script can take several minutes to run. When running root.sh on the
last node, you will receive output similar to the following which signifies a
successful install:
...
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.
Go back to OUI and acknowledge the "Execute Configuration scripts" dialog window.
Finish At the end of the installation, click the [Close] button to exit the OUI.
Install verification
The Installed Cluster Verify Utility can be used to verify the CRS installation.
Run the Cluster Verify Utility as grid user, if running from one node replace all for the node name for
example: db1.
Reboot the server, in the following section we'll execute some commands to make sure all services
started successfully.
Platform Technology Solutions, Latin America
Troubleshooting:
If something goes wrong when executing the root.sh you can review the log and repair the error, but
before executing the script again, de-configure the node and then re-execute the root.sh script.
After the installation of Oracle grid infrastructure, you should run through several tests to verify the
install was successful. Run the following commands on both nodes in the RAC cluster as the grid user.
[grid@db1 ~]$ ps -ef | grep lsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}'
LISTENER_SCAN1
LISTENER
[grid@db2 ~]$ ps -ef | grep lsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}'
LISTENER
Platform Technology Solutions, Latin America
If you installed the OCR and voting disk files on Oracle ASM, then use the following command
syntax as the Grid Infrastructure installation owner to confirm that your Oracle ASM installation
is running:
Note: To manage Oracle ASM or Oracle Net 11g release 2 (11.2) or later installations, use the srvctl
binary in the Oracle grid infrastructure home for a cluster (Grid home). When we install Oracle Real
Application Clusters (the Oracle database software), you cannot use the srvctl binary in the database
home to manage Oracle ASM or Oracle Net which reside in the Oracle grid infrastructure home.
Platform Technology Solutions, Latin America
In prior releases, it was highly recommended to back up the voting disk using the dd command after
installing the Oracle Clusterware software. With Oracle Clusterware release 11.2 and later, backing up
and restoring a voting disk using the dd is not supported and may result in the loss of the voting disk.
Backing up the voting disks in Oracle Clusterware 11g release 2 is no longer required. The voting disk
data is automatically backed up in OCR as part of any configuration change and is automatically
restored to any voting disk added.
To learn more about managing the voting disks, Oracle Cluster Registry (OCR), and Oracle Local
Registry (OLR), please refer to the Oracle Clusterware Administration and Deployment Guide 11 g
Release 2 (11.2).
Oracle recommends that you back up the root.sh script after you complete an installation. If you
install other products in the same Oracle home directory, then the installer updates the contents of
the existing root.sh script during the installation. If you require information contained in the original
root.sh script, then you can recover it from the root.sh file copy.
In order for JDBC Fast Connection Failover to work, you must start Global Service Daemon (GSD) for the
first time on each node as root user, this step is optional.
Next time you reboot the server or restart cluster services, GSD services will start automatically.
3.0 ASM Disk-groups Provisioning
Run the ASM Configuration Assistant (asmca) as the grid user from only one node in the cluster (db1) to
create the additional ASM disk groups which will be used to create the clustered database.
During the installation of Oracle grid infrastructure, we configured one ASM disk group named +GRID
which was used to store the Oracle clusterware files (OCR and voting disk).
In this section, we will create two additional ASM disk groups using the ASM Configuration Assistant
(asmca). These new ASM disk groups will be used later in this guide when creating the clustered
database.
The first ASM disk group will be named +DATA and will be used to store all Oracle physical database
files (data, online redo logs, control files, archived redo logs).
Normally a second ASM disk group is created for the Fast Recovery Area named +FLASH, but for this lab
we will use only one diskgroup.
Before starting the ASM Configuration Assistant, log in to db1 as the owner of the Oracle Grid
Infrastructure software which for this article is grid. Next, if you are using a remote client to connect
to the Oracle RAC node performing the installation (SSH or Telnet to db1 from a workstation configured
with an X Server) or directly using the console.
ASMCMD> lspwusr
Perform the following tasks as the grid user to create two additional ASM disk groups:
The "Create Disk Group" dialog should show two of the ASMLib volumes we
created earlier in this guide.
When creating the datbase ASM disk group, use "DATA" for the "Disk Group
Name".
Finally, check all the ASMLib volumes remaining in the "Select Member Disks"
section, If necessary change the Disk Discovery Path to:
/dev/oracleasm/disks/*
After verifying all values in this dialog are correct, click the [OK] button.
After creating the first ASM disk group, you will be returned to the initial dialog,
Disk Groups
if necessary you can create additional diskgroups
Exit the ASM Configuration Assistant by clicking the [Exit] button.
Disk Groups
Congratulations, you finished the first installation stage, see you tomorrow for the
next lab.