• No results found

Setting Up an Oracle Service

I. Using the Red Hat Cluster Manager

5. Database Services

5.1. Setting Up an Oracle Service

A database service can serve highly-available data to a database application. The application can then provide network access to database client systems, such as Web servers. If the service fails over, the application accesses the shared database data through the new cluster system. A network-accessible database service is usually assigned an IP address, which is failed over along with the service to maintain transparent access for clients.

This section provides an example of setting up a cluster service for an Oracle database. Although the variables used in the service scripts depend on the specific Oracle configuration, the example may aid in setting up a service for individual environments. Refer to Section 5.2Tuning Oracle Servicefor information about improving service performance.

In the example that follows:

• The service includes one IP address for the Oracle clients to use.

• The service has two mounted file systems, one for the Oracle software (/u01/) and the other for the Oracle database (/u02/), which are set up before the service is added.

• An Oracle administration account with the nameoracleis created on the cluster systems that run the service before the service are actually added.

• The administration directory is on a shared disk that is used in conjunction with the Oracle service (for example,/u01/app/oracle/admin/db1).

Create a consistent user/group configuration that can properly access Oracle service for each cluster system. For example:

mkdir /users groupadd -g 900 dba groupadd -g 901 oinstall

useradd -u 901 -g 901 -d /users/oracle -m oracle usermod -G 900 oracle

The Oracle service example uses three scripts that must be placed in/users/oracleand owned by the Oracle administration account. Theoraclescript is used to start and stop the Oracle ser- vice. Specify this script when you add the service. This script calls the other Oracle example scripts. Thestartdbandstopdbscripts start and stop the database. Note that there are many ways for an application to interact with an Oracle database.

68 Chapter 5. Database Services

The following is an example of theoraclescript, which is used to start, stop, and check the status of the Oracle service.

#!/bin/sh #

# Cluster service script to start, stop, and check status of oracle # cd /users/oracle case $1 in start) su - oracle -c ./startdb ;; stop) su - oracle -c ./stopdb ;; status) status oracle ;; esac

The following is an example of thestartdbscript, which is used to start the Oracle Database Server instance:

#!/bin/sh # #

# Script to start the Oracle Database Server instance. #

######################################################################## #

# ORACLE_RELEASE #

# Specifies the Oracle product release. # ######################################################################## ORACLE_RELEASE=9.2.0 ######################################################################## # # ORACLE_SID #

# Specifies the Oracle system identifier or "sid", which is the name of # the Oracle Server instance.

# ######################################################################## export ORACLE_SID=TEST ######################################################################## # # ORACLE_BASE #

# Specifies the directory at the top of the Oracle software product and # administrative file structure.

#

######################################################################## export ORACLE_BASE=/u01/app/oracle

Chapter 5. Database Services 69

######################################################################## #

# ORACLE_HOME #

# Specifies the directory containing the software for a given release. # The Oracle recommended value is $ORACLE_BASE/product/ release

# ######################################################################## export ORACLE_HOME=/u01/app/oracle/product/${ORACLE_RELEASE} ######################################################################## # # LD_LIBRARY_PATH #

# Required when using Oracle products that use shared libraries. # ######################################################################## export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:$LD_LIBRARY_PATH ######################################################################## # # PATH #

# Verify that the users search path includes $ORACLE_HOME/bin #

######################################################################## export PATH=$PATH:${ORACLE_HOME}/bin

######################################################################## #

# This does the actual work. #

# Start the Oracle Server instance based on the initSID.ora # initialization parameters file specified.

#

######################################################################## /u01/app/oracle/product/9.2.0/bin/sqlplus << EOF

sys as sysdba

spool /home/oracle/startdb.log

startup pfile = /u01/app/oracle/product/9.2.0/admin/test/scripts/init.ora open; spool off

quit; EOF exit

The following is an example of thestopdbscript, which is used to stop the Oracle Database Server instance:

#!/bin/sh # #

# Script to STOP the Oracle Database Server instance. #

###################################################################### #

70 Chapter 5. Database Services

#

# Specifies the Oracle product release. # ###################################################################### ORACLE_RELEASE=9.2.0 ###################################################################### # # ORACLE_SID #

# Specifies the Oracle system identifier or "sid", which is the name # of the Oracle Server instance.

# ###################################################################### export ORACLE_SID=TEST ###################################################################### # # ORACLE_BASE #

# Specifies the directory at the top of the Oracle software product # and administrative file structure.

# ###################################################################### export ORACLE_BASE=/u01/app/oracle ###################################################################### # # ORACLE_HOME #

# Specifies the directory containing the software for a given release. # The Oracle recommended value is $ORACLE_BASE/product/ release

# ###################################################################### export ORACLE_HOME=/u01/app/oracle/product/${ORACLE_RELEASE} ###################################################################### # # LD_LIBRARY_PATH #

# Required when using Oracle products that use shared libraries. # ###################################################################### export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:$LD_LIBRARY_PATH ###################################################################### # # PATH #

# Verify that the users search path includes $ORACLE_HOME/bin #

###################################################################### export PATH=$PATH:${ORACLE_HOME}/bin

###################################################################### #

Chapter 5. Database Services 71

# This does the actual work. #

# STOP the Oracle Server instance in a tidy fashion. # ###################################################################### /u01/app/oracle/product/9.2.0/bin/sqlplus << EOF sys as sysdba spool /home/oracle/stopdb.log shutdown abort; spool off quit; EOF exit

5.1.1. Oracle and the Cluster Configuration Tool

To add an Oracle service using theCluster Configuration Tool, perform the following:

1. Start theCluster Configuration Toolby choosingMain Menu=>System Settings=>Server Settings=>Clusteror by typingredhat-config-clusterat a shell prompt. TheCluster

Status Toolappears by default.

2. Start theCluster Configuration Toolby selecting Cluster=>Configurefrom theCluster Status Toolmenus.

3. Click theServicestab. 4. Add the Oracle service.

• ClickNew. TheServicedialog appears.

Figure 5-1. Adding an Oracle Service

• Enter aService Namefor the Oracle service. • Select aFailover Domainor leave it asNone.

• Type a quantity (seconds) to check the health of the Oracle service through the status function of the init script.

• Enter aUser Script, such as/home/oracle/oracle. • ClickOK

5. Add an IP address for the Oracle service. • Select the Oracle service and clickAdd Child.

72 Chapter 5. Database Services

• SelectAdd Service IP Addressand clickOK. TheService IP Addressdialog appears. • Enter anIP Address.

• Enter aNetmask, or leave itNone.

• Enter aBroadcast Address, or leave itNone. • ClickOK.

6. Add a device for the Oracle service and administrative files. • Select the Oracle service and clickAdd Child.

• SelectAdd Deviceand clickOK. TheDevicedialog appears. • Enter theDevice Special File(for example,/dev/sdb5). • In theMount Pointfield, enter/u01.

• Select the file system type inFS Typeor leave it blank. • Enter any mount pointOptions, includingrw(read-write). • Check or uncheckForce Unmount.

• ClickOK.

7. Add a device for the Oracle database files. • Select the Oracle service and clickAdd Child.

• SelectAdd Deviceand clickOK. TheDevicedialog appears. • Enter theDevice Special File(for example,/dev/sdb6). • In theMount Pointfield, enter/u02.

• Select the file system type inFS Typeor leave it blank. • Enter any mount pointOptions, includingrw(read-write). • Check or uncheckForce Unmount.

• ClickOK.

8. ChooseFile=>Saveto save the Oracle service.