Practice Create Oracle 12c R1 Two-Node RAC Database
Practice Create Oracle 12c R1 Two-Node RAC Database
Practice Overview
In this practice you will create an Oracle 12c R1 two-node RAC database on the virtual machines that
you created in the previous practice. To accomplish this target, you will perform the following:
Practice Assumptions
The practice assumes that you have the virtual machines srv1 and srv2 up and running.
Practice Environment Architecture
The following diagram shows the Oracle RAC database architecture that you will create in this
practice:
Practice Environment Preparation Procedure
# .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
2. In the .bash_profile file of the oracle account in srv2, change the value assigned to
ORACLE_SID from rac1 to rac2.
3. In the terminal sessions connected to srv1 and srv2, switch to grid user.
4. In srv1 and srv2, set the OS environment variables in the grid user profile:
mv ~/.bash_profile ~/.bash_profile_bk
vi ~/.bash_profile
# .bash_profile
# OS User: grid
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
# it must not be under the ORACLE_BASE
ORACLE_HOME=/u01/app/12.1.0/grid; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
PATH=.:${PATH}:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
export PATH
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
5. In .bash_profile file of the grid account in srv2, change the value assigned to ORACLE_SID from
+ASM1 to +ASM2.
B. Set the resource limits for the Oracle software installation owners
6. In srv1 and srv2, switch user to root and set the resource limits for the software installation
owner users. It is set for oracle user. You need to set it the same for grid user.
# take backup of existing file:
mv /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf
/etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf.bak
7. In srv1 and srv2, set the number of processes a user can create to 2048
vi /etc/security/limits.d/90-nproc.conf
8. In the Oracle VirtualBox window, login as grid to srv1. Open a terminal window, change the
current window to the GI installation files and start the installer.
# the following source command is needed only if you were already logged on when
# you edited the profile file.
source .bash_profile
cd /media/sf_staging/grid
./runInstaller
Installation Option Install and Configure Oracle Grid Infrastructure for a Cluster
Note: If the Setup was successful but the Test failed, you may need
to restart the nodes and try again.
Failure Isolation select "Do not use Intelligent Platform Management Interface (IPMI)"
Note: If you receive other warnings, check their details. Resolve the
issue and click on "Check Again" button.
In the end of the installation, you will receive the following error:
"Oracle Cluster Verification Utility failed"
The log file has details of the error causes. The following causes can
be safely ignored:
- Sufficient physical memory is not available on node ...
- Sufficient swap size is not available on node ...
- Group of device "/dev/oracleasm/disks/DISK1" did not match the
expected group
- Attempt to get udev information from node ...
10. In srv1, check the status of the running clusterware resources. The state of all the resources
should be ONLINE.
crsctl status resource -t
11. Ensure that all the cluster services are up and running in all the cluster nodes.
crsctl check cluster -all
Note: in real life scenario, you are always advised to apply the latest patch set on the grid software
home straight away after installing it. You will learn how to apply a PSU on Oracle Grid Infrastructure
later in the course.
D. Mount the ASM Disk Groups
In this section of the practice, you will mount the DATA and FRA diskgroups in ASM.
12. In the Oracle VirtualBox window, make sure you are logged on as grid to srv1.
15. In the Disk Group Name field enter DATA, for Redundancy select "External", and mark DISK2,
then click on OK button. You should see after a few seconds a diskgroup creation success
message.
16. Similarly, create FRA diskgroup.
17. Eventually, the asmca window should look like the following screenshot. All the diskgroups must
be mounted and see by the two nodes.
18. In the Oracle VirtualBox window, logout from srv1 and login as oracle.
19. Create the sqlnet.ora file and add the following code in it.
mkdir -p $ORACLE_HOME/network/admin
vi $ORACLE_HOME/network/admin/sqlnet.ora
DIAG_ADR_ENABLED=ON
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
20. Change the directory to the installation files directory and start the installer.
cd /media/sf_staging/database/
./runInstaller
Operating System select dba group for all the options except OSOPER keep it blank
Groups
Note: If you receive other warnings, check their details. Resolve the
issue and click on "Check Again" button.
Note: as is the case with Oracle grid software, it is recommended to apply the latest patch sets on the
Oracle software straight away after installing it. This is much faster than applying them after creating
the database.
F. Create the Oracle RAC Database
22. In the Oracle VirtualBox window, make sure you are logged on as oracle.
Note: observe that you do not create a listener in oracle home. The listener starts up from the grid
home and controlled by the clusterware.
Database Template Make sure the Database Type is Oracle Real Application Clusters
(RAC) database
Change the Configuration Type to Admin Managed
Make sure that the General Purpose or Transaction Processing
option is selected.
Database Placement Move the node srv2 from the Available list to the Selected list
Management Options Unmark the "Run Cluster Verification Utility (CVU) Checks
Periodically" checkbox
Mark the "Configure Enterprise Manager (EM) Database
Express" checkbox
In this section of the practice, you will perform some initial checking on the create RAC database.
26. Make sure that the SCAN hostname replies to ping command.
ping -c 3 srv-scan
28. Identify the database instance names that are currently running on srv1 from the OS command
shell.
ps -ef | grep -i pmon
29. Login as sysdba to the database and examine the contents of v$active_instances
sqlplus / as sysdba
col inst_name format a50
SELECT INST_NUMBER , INST_NAME FROM V$ACTIVE_INSTANCES;
30. Make sure the tnsnames.ora file has been configured for connecting to rac database. This has
automatically been done by the dbca utility.
cat $TNS_ADMIN/tnsnames.ora
Note: Applications should connect to the RAC database using dynamic services. Services will be
covered in a later practice.
31. In the following sub-steps, you will examine how the client sessions are distributed among the
database instances. You will create multiple SQL*Plus sessions and check to which instance every
session is connected to.
a. Connect to rac database as system using the password authentication.
sqlplus system/oracle@rac
b. Retrieve the instance name that the current SQL*Plus session is connected to.
SELECT INSTANCE_NAME FROM V$INSTANCE ;
c. Issue the following command in SQL*Plus. This command will open a new OS sub-shell.
The SQL*Plus session is still active. When you exit from the OS sub-shell, you will get back
to the SQL*Plus session.
!
d. Open another SQL*Plus session using the same credential.
sqlplus system/oracle@rac
e. Check the instance name that current SQL*Plus session is connected to.
f. Repeat the previous steps twice, and check the current instance name in each time. You will
observe that the sessions are distributed in a round-robin fashion.
g. Exit from all the SQL*Plus sessions created above.
H. Shutdown the RAC database
In this section of the practice, you will learn the clean way of shutting down the Oracle RAC database
and the Clusterware technology stack.
32. Make sure you are logged on as oracle to srv1 in a Putty session then issue the following
command to display help information about using srvctl stop command.
This is a handy way to remember the format of using the command when you forget it.
srvctl stop database -h
33. Use the srvctl to stop rac database. This command shuts down the instances in all the cluster
nodes.
-d can be replaced with “-database”, and “-o” is a shortcut to “stop_options”
srvctl stop database -d rac -o immediate
srvctl status database -d rac
34. Log in as root to srv1 and issue the following command. This command shuts down the
Clusterware technology stack.
Observe that the full path of the crsctl should be used. This is because that path of this utility is
not included in the PATH variable defined for the root user. When you use the crsctl utility with
grid user, you do not have to use the full utility pathname because it is included in the PATH
value for the grid user.
Some clusterware commands should be executed by root and some of them should be run by
grid.
/u01/app/12.1.0/grid/bin/crsctl stop crs
35. Log in as root to srv2 and issue the same command as in the previous step to stop the
Clusterware technology stack.
If you want to make a copy of the existing virtual machines to use them on another machine or move
them to another disk drive, the traditional method of copying the virtual machine folders will not work.
This is because the disk UID of the shared disks is registered in Oracle VirtualBox. If you just copy the
disk file, Oracle VirtualBox will return an error complaining that the same disk UID is being used.
In the following steps, you will learn the steps that you should follow how to make a copy of the
virtual machines.
Note: you do not have to perform this procedure. Refer to it only if you wish to relocate the system.
oifi90 If your target is to make a backup copy of the existing environment, you do not have to
perform this procedure. Shutting down the machines and copying their parent folder is fair enough.
37. In the VirtualBox Manager open click on File menu | Virtual Media Manager. Then select the
first shared disk used by the virtual machines (DISK1).
38. Click on the "Release" icon and then confirm in the pop-up window. Note that this disk now
shows as "Not attached".
39. Perform the same previous two steps on the remaining two shared disks: DISK2 and DISK3.
40. Select DISK1 and then click on "Copy" to start the Disk Copying Wizard.
42. Accept the VDI Virtual disk file type and click on "Next".
44. On the next screen you can set the location and name of the new file. After that, click on "Next".
48. Export srv1 and srv2 virtual machines: in the VirtualBox Manager select the VM, then click on
File | Export Appliance.
a. Select the virtual machines, click on Next
b. Set the location where you want to export the appliances. Click on Next
c. Accept the appliance settings, click on Export
49. You can now copy the exported file and the copy of the shared disks to the new location.
50. Re-attach the shared disks in srv1: in Oracle VirtualBox, select the virtual machine, click on
Settings, select Storage option from the right pane, click on the Sata Controller, then click on
Add Hardisk. Click on Choose Existing Disk option.
By default, when you boot up a cluster node, the Clusterware stack itself automatically starts up and it
starts up the database service to its pervious open state. If the database was up when you shut down
the node, the Clusterware starts up the database when you reboot the server. If the database was
down when you shut down the node, the Clusterware will NOT start up the database when you reboot
the server.
Note: You will learn the details of the auto-restart setting in the next lecture.
55. Check the AUTO_START attribute value of the rac database service.
This attribute controls whether the resource should be automatically started when the machine is
rebooted or not. Observe that this is different from the auto-restart mechanism in the single-
instance database.
crsctl status res ora.rac.db -f | grep AUTO_START
The restore value means that the resource will be started to the same state that it was in when
the server stopped. Oracle Clusterware attempts to restart the resource if the value of TARGET
was ONLINE before the server stopped.
56. Make sure the autostart service is enabled (must be run as root).
su -
/u01/app/12.1.0/grid/bin/crsctl config has
In this section of the practice, you will open the Oracle Enterprise Manager Database Express. Because
the pre-installed Mozilla Firefox in the virtual appliance does not have the Adobe Flash plug-in installed
in it by default, you need to install the plug-in in the browser.
https://srv-scan.localdomain:5500/em
60. You will receive a warning message about trusting the URL source, as follows:
61. Click on the "Add Exception" button. You will see the following message popping up:
64. If your VM appliance has access to the Internet, go to next step. If you VM appliance does not
have a connection to the Internet, you can install the Flash plug-in manually by performing the
following steps.
g. The page that follows appears in the browser. Select ".rpm for Linux" option from the drop
list then click on Download button.
j. The following message appears to you. Enter the root password then click on Authenticate
button
66. After the Flash plugin got installed, close the browser and open it again.
67. Enter the EM URL. You should be able to see the EM Database Express page as follows. Enter the
sys username, its password, mark the "as sysdba" option then click on Login button.
68. You should see the EM Database Express opening and displaying a page similar to the following:
Summary