Wednesday, 16 December 2009

Oracle RAC and TAF to Guarantee availability

One of the most exciting new features in Oracle Database is Real Application Clusters (RAC). The Oracle RAC solution delivers 24/7 database availability, performance, and scalability. Cache Fusion is the key memory feature that enables Oracle RAC performance, and the new Transparent Application Failover (TAF) is what applications use to sync up with Oracle RAC availability. This article explores the cooperation between Oracle RAC, Cache Fusion, and TAF and offers insights into the architecture and use of these tools for continuous availability and infinite scalability.

Oracle RAC Architecture

Oracle has long recognized that a clustered environment is the best protection against hardware and software failure. In a clustered environment, many Oracle instances exist on separate servers, each with direct connectivity to a single Oracle database. Should any single server or instance fail, processing continues on the surviving servers.

Cache Fusion and Oracle RAC

The introduction of the Cache Fusion shared RAM cache for multiple Oracle instances is a breakthrough in clustered solutions. Oracle RAC fully implements Cache Fusion, which both provides high performance and enables continuous cluster availability. The high-availability capability of Oracle RAC is almost unfathomable. It's estimated that in a 12-computer configuration, any application running on Oracle RAC will not experience a catastrophic failure for well over 100,000 years.

Cache Fusion technology changes the internal configuration of the Oracle system global area (SGA). Cache Fusion moves the RAM data buffers from local RAM storage into a shared RAM area accessible by all Oracle instances.

Beyond high performance and high availability, Oracle RAC offers significant benefits as a scalability tool. Whenever the processing load becomes excessive in an existing Oracle RAC cluster, you can add additional processors—each with its own Oracle instance—to the Oracle RAC configuration. This allows companies to start small and scale infinitely as processing demands increase.

Oracle RAC and Hardware Failover

To detect a node failure, the Cluster Manager uses a background process—Global Enqueue Service Monitor (LMON)—to monitor the health of the cluster. When a node fails, the Cluster Manager reports the change in the cluster's membership to Global Cache Services (GCS) and Global Enqueue Service (GES). These services are then remastered based on the current membership of the cluster.

To successfully remaster the cluster services, Oracle RAC keeps track of all resources and resource states on each node and then uses this information to restart these resources on a backup node.

These processes also manage the state of in-flight transactions and work with TAF to either restart or resume the transactions on the new node. Now let's see how Oracle RAC and TAF work together to ensure that a server failure does not cause an unplanned service interruption.

Using Transparent Application Failover

After an Oracle RAC node crashes—usually from a hardware failure—all new application transactions are automatically rerouted to a specified backup node. The challenge in rerouting is to not lose transactions that were "in flight" at the exact moment of the crash. One of the requirements of continuous availability is the ability to restart in-flight application transactions, allowing a failed node to resume processing on another server without interruption. Oracle's answer to application failover is a new Oracle Net mechanism dubbed Transparent Application Failover. TAF allows the DBA to configure the type and method of failover for each Oracle Net client.

For an application to use TAF, it must use failover-aware API calls from the Oracle Call Interface (OCI). Inside OCI are TAF callback routines that can be used to make any application failover-aware.

While the concept of failover is simple, providing an apparent instant failover can be extremely complex, because there are many ways to restart in-flight transactions. The TAF architecture offers the ability to restart transactions at either the transaction (SELECT) or session level:

  • SELECT failover. With SELECT failover, Oracle Net keeps track of all SELECTstatements issued during the transaction, tracking how many rows have been fetched back to the client for each cursor associated with a SELECT statement. If the connection to the instance is lost, Oracle Net establishes a connection to another Oracle RAC node and re-executes the SELECT statements, repositioning the cursors so the client can continue fetching rows as if nothing has happened. The SELECT failover approach is best for data warehouse systems that perform complex and time-consuming transactions.
  • SESSION failover. When the connection to an instance is lost, SESSION failover results only in the establishment of a new connection to another Oracle RAC node; any work in progress is lost. SESSION failover is ideal for online transaction processing (OLTP) systems, where transactions are small.

Oracle TAF also offers choices on how to restart a failed transaction. The Oracle DBA may choose one of the following failover methods:

  • BASIC failover. In this approach, the application connects to a backup node only after the primary connection fails. This approach has low overhead, but the end user experiences a delay while the new connection is created.
  • PRECONNECT failover. In this approach, the application simultaneously connects to both a primary and a backup node. This offers faster failover, because a pre-spawned connection is ready to use. But the extra connection adds everyday overhead by duplicating connections.

Currently, TAF will fail over standard SQL SELECT statements that have been caught during a node crash in an in-flight transaction failure. In the current release of TAF, however, TAF must restart some types of transactions from the beginning of the transaction.

The following types of transactions do not automatically fail over and must be restarted by TAF:

  • Transactional statements. Transactions involving INSERT, UPDATE, or DELETEstatements are not supported by TAF.
  • ALTER SESSION statements. ALTER SESSION and SQL*Plus SETstatements do not fail over.
  • The following do not fail over and cannot be restarted:
  • Temporary objects. Transactions using temporary segments in the TEMP tablespace and global temporary tables do not fail over.
  • PL/SQL package states. PL/SQL package states are lost during failover.

Using Oracle RAC and TAF Together

The continuous availability features of Oracle RAC and TAF come together when these products cooperate in restarting failed transactions. Let's take a closer look at how this works.

Within each connected Oracle Net client, tnsnames.ora file parameters define the failover types and methods for that client. The parameters direct Oracle RAC and TAF on how to restart any transactions that may be in-flight during a hardware failure on the node.

It is important to note that TAF failover control is external to the Oracle RAC cluster, and each Oracle Net client may have unique failover types and methods, depending on processing requirements. The following is a client tnsnames.ora file entry for a node, including its current TAF failover parameters:

 
 

bubba.world =

(DESCRIPTION_LIST =

(FAILOVER = true)

(LOAD_BALANCE = true)

(DESCRIPTION =

(ADDRESS =

(PROTOCOL = TCP)

(HOST = redneck)(PORT = 1521))

(CONNECT_DATA =

(SERVICE_NAME = bubba)

(SERVER = dedicated)

(FAILOVER_MODE =

(BACKUP=cletus)

(TYPE=select)

(METHOD=preconnect)

(RETRIES=20)

(DELAY=3)

)

)

)

 
 

The failover_mode section of the tnsnames.ora file lists the parameters and their values:

BACKUP=cletus. This names the backup node that will take over failed connections when a node crashes. In this example, the primary server is bubba, and TAF will reconnect failed transactions to the cletus instance in case of server failure.

TYPE=select. This tells TAF to restart all in-flight transactions from the beginning of the transaction (and not to track cursor states within each transaction).

METHOD=preconnect. This directs TAF to create two connections at transaction startup time: one to the primary bubba database and a backup connection to the cletus database. In case of instance failure, the cletus database will be ready to resume the failed transaction.

RETRIES=20. This directs TAF to retry a failover connection up to 20 times.

DELAY=3. This tells TAF to wait three seconds between connection retries.

Remember, you must set these TAF parameters in every tnsnames.ora file on every Oracle Net client that needs transparent failover.

Putting It All Together

An Oracle Net client can be a single PC or a huge application server. In the architectures of giant Oracle RAC systems, each application server has a customized tnsnames.ora file that governs the failover method for all connections that are routed to that application server.

Watching TAF in Action

The transparency of TAF operation is a tremendous advantage to application users, but DBAs need to quickly see what has happened and where failover traffic is going, and they need to be able to get the status of failover transactions. To provide this capability, the Oracle data dictionary has several new columns in the V$SESSION view that give the current status of failover transactions.

The following query calls the new FAILOVER_TYPE, FAILOVER_METHOD, and FAILED_OVER columns of the V$SESSION view. Be sure to note that the query is restricted to nonsystem sessions, because Oracle data definition language (DDL) and data manipulation language (DML) are not recoverable with TAF.

 
 

select

username,

sid,

serial#,

failover_type,

failover_method,

failed_over

from

v$session

where

username not in ('SYS','SYSTEM',

'PERFSTAT')

and

failed_over = 'YES';

 
 

You can run this script against the backup node after an instance failure to see those transactions that have been reconnected with TAF. Remember, TAF will quickly redirect transactions, so you'll only see entries for a short period of time immediately after the failover.  A backup node can have a variety of concurrent failover transactions, because the tnsnames.ora file on each Oracle Net client specifies the backup node, the failover type, and the failover method.

Conclusion

Oracle RAC, TAF, and Cache Fusion work together to guarantee continuous availability and infinite scalability. To summarize, here's a short description of each component:

Oracle RAC. The clustering component of Oracle that allows the creation of multiple, independent Oracle instances, all sharing a single database.

Cache Fusion. The shared RAM component of Oracle RAC that provides fast interchange of Oracle data blocks between SGA regions.

TAF. The failover method implemented on the Oracle Net client to restart in-flight transactions when a node crashes.

Monday, 14 December 2009

Oracle Enterprise Linux 5

Specifications

Oracle Enterprise Linux 4

Oracle Enterprise Linux 5

Architectures

X86, X86-64, Itanium *

X86, X86-64, Itanium **

Versions

Update 4, Update 5, Update 6, Update 7, Update 8

General Availability (Release 1), Update 1, Update 2, Update 3, Update 4

Minimum Memory Requirements

256MB X86, X86-64
512MB IA64

512MB

Minimum Disk Space

800MB

1GB

Max Memory

64GB x86
1TB Intel64
256GB AMD64

16 GB x86
1TB Intel64
256GB AMD64

Max Number of CPUs

Unlimited

Unlimited

Kernel Base Version

2.6.9

2.6.18

Compiler

Gcc 3.4

Gcc 4.1

Libraries

Glibc 2.3.4

Glibc 2.5

Cluster Administration

OCFS2 available, GFS and Cluster Suite not in base OS

OCFS2 available, GFS and Cluster Suite included in base OS

Supported Filesystems

  

  

Ext3 Max File Size

2TB

2TB

Ext3 Max filesystem size

8TB

8TB/16TB (in 5.1)

OCFS2 Max File Size

16TB

16TB

OCFS2 Max filesystem size

16TB

16TB

GFS Max File Size

N/A

16TB/8EB

GFS Max filesystem size

N/A

16TB/8EB

 

  

  

   
   

* For the Itanium architecture, Oracle provides rpms for download from ULN starting with OEL4U6. Oracle provides ISOs for free download from Oracle E-Delivery starting with OEL4U8.
** For the Itanium architecture, starting with OEL5 Update 4, ISOs are available on Oracle E-Delivery and rpms are available on ULN

  

 
   
   
   
   
   
   
   
   
   
   
   
   

Friday, 11 December 2009

How to Move a Database to a Different Platform :::::::: Metalink Note No.


 

How to Move a Database to a Different Platform [ID 113178.1]

Migration of Oracle Database Instances Across OS Platforms [ID 733205.1]

How To Use RMAN CONVERT DATABASE on Source Host for Cross Platform Migration [ID 413586.1]

Cross-Platform Migration on Destination Host Using Rman Convert Database [ID 414878.1]

What Is The Best Practice If You Want To Migrate Oracle Database To 10g Release To A Different Operating System? [ID 433918.1]

How to Perform a Full Database Export Import during Upgrade, Migrate, Copy, or Move of a Database [ID 286775.1]

Compatibility Matrix for Export And Import Between Different Oracle Versions [ID 132904.1]

BATCH JOBS

=================================================================================================================================================

Rman Batch Job:

1.weekly.bat

2.hemora.bat

3.rman_Backup.bat


1.weekly.bat

v:

call v:\hemora.bat

call v:\rman_weeklyjob.bat

2.hemora.bat

PATH =C:\app\Administrator\product\11.1.0\db_1\BIN

3.rman_Backup.bat

REM +--------------------------------------------------------------------------+

REM | REMOVE OLD LOG AND RMAN COMMAND FILES. |

REM +--------------------------------------------------------------------------+

set TODAY=%date%

set TODAY=%TODAY:/=-%

set MyLogFile=V:\%ToDAY%_Daily_Backup.log

set CMDFILE=V:\Rman_backup.rcv

del /q %CMDFILE%

REM +--------------------------------------------------------------------------+

REM | WRITE RMAN COMMAND SCRIPT. |

REM +--------------------------------------------------------------------------+

echo backup database plus archivelog delete input; > %CMDFILE%

echo crosscheck backup of database; >> %CMDFILE%

echo crosscheck backup of controlfile; >> %CMDFILE%

echo crosscheck archivelog all; >> %CMDFILE%

echo delete noprompt force obsolete;>> %CMDFILE%

echo delete force noprompt expired backup of database; >> %CMDFILE%

echo delete force noprompt expired backup of controlfile; >> %CMDFILE%

echo delete force noprompt expired archivelog all; >> %CMDFILE%

echo exit; >> %CMDFILE%

REM +--------------------------------------------------------------------------+

REM | PERFORM RMAN BACKUP. |

REM +--------------------------------------------------------------------------+

rman target sys/xxx@oratest nocatalog cmdfile=%CMDFILE% msglog=%MyLogFile%



Hot Backup Batch Job:

REM ==========================================================================

REM Script# 1

REM This is the main backup script to run with Windows Scheduler / at command

REM ==========================================================================

call v:\hemora.bat

set dbconn=sys/xxxx@oratest as sysdba

set admdir=V:\admin\daily\

set logdir=V:\admin\daily\out\

set oradir1=D:\ORADATA\ORATEST\ (datafile location)

set oradir2=G:\ORADATA\ORATEST\ (undo,tem location)

set oradir3=V:\ArchiveLog\ORATEST\ (archivelog location)

set orabckdir=V:\Hot_Backup\ (hotbackup temporary storage)

REM set orabckdir1=V:\Hot_Backup\c\

REM set orabckdir2=V:\Hot_Backup\d\

REM set orabckdir3=V:\Hot_Backup\e\


REM

REM save previous copies of backup logs

REM

del %logdir%backup2.txt

ren %logdir%backup1.txt backup2.txt

ren %logdir%backup.txt backup1.txt


echo "ORATEST overnight.bat backup commenced ..." >>%logdir%backup.txt

date /t >>%logdir%backup.txt

time /t >>%logdir%backup.txt


REM

REM Run full export of the database

REM

REM echo "Exporting ORATEST" ... >> %logdir%backup.txt

REM d:\oracle\ora81\bin\exp.exe parfile=d:\oracle\admin\ORATEST\exp\ORATESTexp.par >> %logdir%backup.txt


REM

REM Compress the export file with winzip command line utility

REM May also put a line to remove the old dump files here

REM

REM c:\progra~1\winzip\wzzip.exe e:\oracle\oradata\ORATEST\export\ORATEST_full.zip

REM e:\oracle\oradata\ORATEST\export\ORATEST_full.dmp


REM

REM Append the database export log to backup.txt

REM

REM type d:\oracle\admin\ORATEST\exp\logs\ORATEST_full.log >> %logdir%backup.txt


REM echo "Finished export of ORATEST" >> %logdir%backup.txt

echo "Generating sql scripts for hot ORATEST backup ..." >> %logdir%backup.txt

sqlplus -s %dbconn% @%admdir%sql\backup.sql >> %logdir%backup.txt

echo "Putting ORATEST in backup mode ..." >> %logdir%backup.txt


REM

REM Put all tablespaces in backup mode

REM

sqlplus -s %dbconn% @%admdir%sql\temp\BEGIN_ORATEST_BACKUP.sql >> %logdir%backup.txt


REM

REM Save the database files' location in ORATEST_files.txt

REM

dir %oradir1% > %orabckdir%ORATEST_files.txt

dir %oradir2% >> %orabckdir%ORATEST_files.txt

REM dir %oradir3% >> %orabckdir%ORATEST_files.txt


REM

REM File listing from sqlplus

REM

sqlplus -s %dbconn% @%admdir%sql\dbfiles.sql >> %orabckdir%ORATEST_files.txt


REM

REM Copy Oracle files to backup directory on disk

REM

C:\app\Administrator\product\11.1.0\db_1\BIN\ocopy %oradir1%* %orabckdir% >> %logdir%backup.txt

C:\app\Administrator\product\11.1.0\db_1\BIN\ocopy %oradir2%* %orabckdir% >> %logdir%backup.txt

rem C:\app\Administrator\product\11.1.0\db_1\BIN\ocopy %oradir3%* %orabckdir3% >> %logdir%backup.txt


REM

REM backup filesystems

REM

REM D: drive is backed up last because it has the archived redo logs

REM


date /T >> %logdir%backup.txt

time /T >> %logdir%backup.txt

echo "Putting ORATEST in normal mode" >> %logdir%backup.txt

sqlplus -s %dbconn% @%admdir%sql\temp\END_ORATEST_BACKUP.sql >> %logdir%backup.txt


echo "Copying Archivelog Files ..." >>%logdir%backup.txt

ocopy %oradir3%* %orabckdir% >> %logdir%backup.txt

del /q %admdir%sql\temp\* >> %logdir%backup.txt

sqlplus -s %dbconn% @%admdir%sql\backupcontrolfile.sql >> %logdir%backup.txt

echo "SAMPLEHOST backup finished ..." >>%logdir%backup.txt

date /t >>%logdir%backup.txt

time /t >>%logdir%backup.txt


echo "ZIPPING backup TO D:\hotbackup_zip Location..." >>%logdir%backup.txt

date /t >>%logdir%backup.txt

time /t >>%logdir%backup.txt


set TODAY=%date%

set TODAY=%TODAY:/=-%

REM set NOW=%time:~0,2%%time:~3,2%%time:~6,2%

set ZIPFile=D:\hotbackup_zip\%ToDAY%_hotBackup.zip

zip -r -m -1 %ZIPFILE% V:\Hot_Backup\* >> %logdir%backup.txt

echo "ORATEST Hot backup Zipping finished ..." >>%logdir%backup.txt

date /t >>%logdir%backup.txt

time /t >>%logdir%backup.txt

backup.sql

-- ==========================================================================--

-- backup.sql

-- SQL script to generate scripts to start and end database backup--

-- ==========================================================================

set pagesize 0 echo off feedback off verify off

spool v:\admin\daily\sql\temp\BEGIN_ORATEST_BACKUP.sql

SELECT 'ALTER SYSTEM SWITCH LOGFILE;' FROM dual;

SELECT 'ALTER TABLESPACE ' || tablespace_name || ' BEGIN BACKUP;' FROM dba_tablespaces where contents != 'TEMPORARY'

order by tablespace_name ;

SELECT 'EXIT;'

FROM dual;

spool off


spool v:\admin\daily\sql\temp\END_ORATEST_BACKUP.sql

SELECT 'ALTER TABLESPACE ' || tablespace_name || ' END BACKUP;'

FROM dba_tablespaces where contents != 'TEMPORARY'

order by tablespace_name ;

SELECT 'ALTER SYSTEM SWITCH LOGFILE;'

FROM dual;

SELECT 'EXIT;'

FROM dual;

spool off

EXIT;


=================================================================================================================================================

EXPORT BATCH JOB


@echo off

REM +--------------------------------------------------------------------------+

REM | Hemesh M. Patel |

REM |--------------------------------------------------------------------------|

REM | Copyright (c) 1998-2009 Hemesh M Patel All rights reserved. |

REM |--------------------------------------------------------------------------|

REM | FILE : export_backup_online_full.bat |

REM | CLASS : WINDOWS Shell Scripts |

REM | PURPOSE : Used to perform a logical backup of an Oracle database |

REM | using the traditional export utility. By default, this |

REM | script performs a full and consistent backup of the |

REM | database using a dynamically created parameter file that |

REM | gets written to a temporary directory and run through |

REM | Oracle export using the "parfile" parameter. |

REM | |

REM | ------------- |

REM | IMPORTANT !!! |

REM | ------------- |

REM | Please note that this script makes use of the command |

REM | utility "forfiles.exe" to list and remove obsolete Oracle |

REM | export dump files and log files. Some Microsoft operating |

REM | system environments do not include this utility by default |

REM | (i.e. Windows XP). A copy of "forfiles.exe" can be |

REM | downloaded from: |

REM | |

REM | http://www.idevelopment.info/data/Supporting_Tools/forfiles.exe |

REM | |

REM | ------------------ |

REM | EMAIL CAPABILITIES |

REM | ------------------ |

REM | This script makes use of the BLAT command line utility to |

REM | send the resulting log file to administrators. For more |

REM | information on configuring BLAT to send email from scripts |

REM | in Windows, see the following article: |

REM | |

REM | http://www.idevelopment.info/data/Oracle/DBA_tips/Microsoft_Windows/WINDOWS_5.shtml

REM | |

REM | -------------------------------------------- |

REM | NEW DATA PUMP UTILITY IN ORACLE DATABASE 10g |

REM | -------------------------------------------- |

REM | Oracle Database 10g users (and higher) should consider |

REM | using the new Data Pump utility in place of the original |

REM | Oracle import/export. The original export utility was |

REM | deprecated in Oracle Database 10g Release 2, and is no |

REM | longer supported for general use as of Oracle Database 11g. |

REM | Going forward, Data Pump export (expdp) will be the sole |

REM | supported means of exporting data from the database. The |

REM | original import utility (imp) still ships with Oracle |

REM | Database 10g and Oracle Database 11g in order to support |

REM | import of legacy dump files. The original import utility |

REM | will be supported forever and will provide the means to |

REM | import dump files from earlier releases (release 5.0 and |

REM | later) that were created with the original export (exp). |

REM | Please note that the original export dump files and the new |

REM | Data Pump dump files are "not" compatible. You cannot read |

REM | an original Oracle export dump file with Data Pump and vice |

REM | versa. Neither client can read dump files created by the |

REM | other. |

REM | |

REM | ---------------------------- |

REM | LABEL SECURITY AND VPD USERS |

REM | ---------------------------- |

REM | When exporting data from an Oracle database that contains |

REM | tables protected by Fine-Grained Access Control (FGAC) |

REM | policies, it is possible to receive EXP-00079 and/or |

REM | EXP-00080 warnings. |

REM | |

REM | Note that Fine-Grained Access Control (FGAC) is a synonym |

REM | for Row-Level Security (RLS) and should not be confused |

REM | with FGA which stands for Fine-Grained Auditing! |

REM | |

REM | This warning is thrown by Oracle export when FGAC is |

REM | enabled on a SELECT statement and indicates that Oracle |

REM | export may not export the entire table because FGAC access |

REM | may rewrite the query. There are two methods used to |

REM | resolve this issue and ensure Oracle export is able to |

REM | access and backup all data: |

REM | |

REM | (1) Use the Direct Path clause of Oracle Export or |

REM | (2) Use a database login that has access to all rows |

REM | regardless of existing FGAC policies. |

REM | |

REM | It is highly recommended that the latter option be used |

REM | especially when exporting tables that contain objects and |

REM | LOBs. Rows in tables that contain objects and LOBs will be |

REM | exported using the Conventional Path method, even if Direct |

REM | Path was specified. If this table has FGAC policies |

REM | enabled, the export will then fail with EXP-00008, |

REM | ORA-00604, and ORA-28112 errors. The recommended method is |

REM | to run Oracle export while connected as a user who has |

REM | access to all rows regardless of existing FGAC policies. |

REM | Only the user SYS (all versions) or any user who has the |

REM | EXEMPT ACCESS POLICY privilege (Oracle9i and higher), can |

REM | select all rows. The recommended convention is to export |

REM | using the database user BACKUP_ADMIN which has been granted |

REM | the EXEMPT ACCESS POLICY privilege: |

REM | |

REM | SQL> GRANT exempt access policy TO backup_admin; |

REM | |

REM | Note that this section does not apply to the |

REM | Oracle Database 10g Data Pump Export utility (expdp). An |

REM | export with the new Oracle Database 10g Data Pump Export |

REM | utility will not give any warning message. |

REM | |

REM | PARAMETERS : DBA_USERNAME Database username EXP will use to login |

REM | to the database. This user must have |

REM | the DBA role. |

REM | DBA_PASSWORD Database password EXP will use to login |

REM | to the database. |

REM | TNS_ALIAS TNS connect string to the target |

REM | database. |

REM | NUM_DAYS_TO_KEEP Number of days worth of Oracle exports |

REM | to retain on the file system. |

REM | USAGE : |

REM | |

REM | export_backup_online_full.bat "DBA_USERNAME" "DBA_PASSWORD" "TNS_ALIAS" "NUM_DAYS_TO_KEEP"

REM | |

REM | NOTE : As with any code, ensure to test this script in a |

REM | development environment before attempting to run it in |

REM | production. |

REM +--------------------------------------------------------------------------+


REM +--------------------------------------------------------------------------+

REM | SCRIPT NAME VARIABLES |

REM +--------------------------------------------------------------------------+


set SCRIPT_NAME_NOEXT=export_backup_online_full

set SCRIPT_NAME_FULL=%SCRIPT_NAME_NOEXT%.bat

set SCRIPT_VERSION=3.8


REM +--------------------------------------------------------------------------+

REM | SET / VALIDATE ENVIRONMENT VARIABLES |

REM +--------------------------------------------------------------------------+


set ORA_EXP_DIR=v:\export\oratest


if (%ORA_EXP_DIR%)==() goto ENV_VARIABLES


REM +--------------------------------------------------------------------------+

REM | EMAIL VARIABLES |

REM +--------------------------------------------------------------------------+


set SMTP_SERVER=localhost

set SMTP_PORT=25

set SMTP_EMAIL_TO=hemesh.patel@volume.co.uk

set SMTP_EMAIL_FROM=dba@volume.co.uk


REM +--------------------------------------------------------------------------+

REM | SET START DATE AND TIME ENVIRONMENT VARIABLES |

REM +--------------------------------------------------------------------------+


set START_DATE=%DATE%

set START_TIME=%TIME%


REM +--------------------------------------------------------------------------+

REM | SHOW SIGNON BANNER |

REM +--------------------------------------------------------------------------+


echo.

echo %SCRIPT_NAME_FULL% - Version %SCRIPT_VERSION%

echo Copyright (c) 1998-2009 Hemesh M Patel All rights reserved.

echo.


REM +--------------------------------------------------------------------------+

REM | VALIDATE COMMAND-LINE PARAMETERS |

REM +--------------------------------------------------------------------------+


if (%1)==() goto USAGE

if (%2)==() goto USAGE

if (%3)==() goto USAGE

if (%4)==() goto USAGE


REM +--------------------------------------------------------------------------+

REM | SET DATE AND TIME ENVIRONMENT VARIABLES FOR FILES |

REM +--------------------------------------------------------------------------+


SETLOCAL


FOR /f "tokens=2-4 skip=1 delims=(-)" %%G IN ('echo.^|date') DO (

FOR /f "tokens=2 delims= " %%A IN ('date /t') DO (

SET v_first=%%G

SET v_second=%%H

SET v_third=%%I

SET v_all=%%A

)

)


SET %v_first%=%v_all:~0,2%

SET %v_second%=%v_all:~3,2%

SET %v_third%=%v_all:~6,4%


ENDLOCAL & SET v_year=%yy%& SET v_month=%mm%& SET v_day=%dd%


SET FILEDATE=%v_year%%v_month%%v_day%


SETLOCAL

FOR /f "tokens=*" %%G IN ('time /t') DO set v_time=%%G

SET v_time=%v_time:~0,2%%v_time:~3,2%%v_time:~6,2%

ENDLOCAL & SET v_time=%v_time%


SET v


SET FILETIME=%v_time%


REM +--------------------------------------------------------------------------+

REM | CUSTOM DIRECTORIES |

REM +--------------------------------------------------------------------------+


set CUSTOM_ORACLE_DIR=v:\export\oratest

set CUSTOM_ORACLE_BIN_DIR=%CUSTOM_ORACLE_DIR%\bin

set CUSTOM_ORACLE_LIB_DIR=%CUSTOM_ORACLE_DIR%\lib

set CUSTOM_ORACLE_LOG_DIR=%CUSTOM_ORACLE_DIR%\log

set CUSTOM_ORACLE_OUT_DIR=%CUSTOM_ORACLE_DIR%\out

set CUSTOM_ORACLE_SQL_DIR=%CUSTOM_ORACLE_DIR%\sql

set CUSTOM_ORACLE_TEMP_DIR=%CUSTOM_ORACLE_DIR%\temp


REM +--------------------------------------------------------------------------+

REM | DECLARE GLOBAL VARIABLES |

REM +--------------------------------------------------------------------------+


set DBA_USERNAME=%1%

set DBA_PASSWORD=%2%

set TNS_ALIAS=%3%

set NUM_DAYS_TO_KEEP=%4%


set ERRORS="NO"


SET LOGDIR=%CUSTOM_ORACLE_LOG_DIR%

SET LOGFILE=%LOGDIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_%FILEDATE%_%FILETIME%.log

SET LOGFILE_COPY=%LOGDIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%.log


set EXP_PARAMETER_FILE_NAME=%CUSTOM_ORACLE_TEMP_DIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%.parfile

set EXP_DUMP_FILE_NAME=%ORA_EXP_DIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_%FILEDATE%_%FILETIME%.dmp

set EXP_DUMP_LOG_FILE_NAME=%CUSTOM_ORACLE_TEMP_DIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_EXPLOG.log


REM +--------------------------------------------------------------------------+

REM | HOSTNAME VARIABLES |

REM +--------------------------------------------------------------------------+


set HOSTNAME=%COMPUTERNAME%


REM +--------------------------------------------------------------------------+

REM | ORACLE ENVIRONMENT VARIABLES |

REM +--------------------------------------------------------------------------+


set ORACLE_BASE=C:\app\Administrator

set ORACLE_HOME=%ORACLE_BASE%\product\11.1.0\db_1

set ORACLE_SID=%TNS_ALIAS%

set ORACLE_ADMIN_DIR=%ORACLE_BASE%\admin


REM +--------------------------------------------------------------------------+

REM | WRITE HEADER INFORMATION TO CONSOLE AND LOG FILE. |

REM +--------------------------------------------------------------------------+


echo ======================================================

echo - START TIME : %START_DATE% %START_TIME%

echo ======================================================


echo.

echo ===================================================================================

echo COMMON SCRIPT VARIABLES

echo ===================================================================================

echo Script Name : %SCRIPT_NAME_FULL%

echo Script Version : %SCRIPT_VERSION%

echo Begin Date : %START_DATE%

echo Begin Time : %START_TIME%

echo Host Name : %HOSTNAME%

echo Log File Name : %LOGFILE%

echo Log File Name (Copy) : %LOGFILE_COPY%

echo ===================================================================================

echo CUSTOM SCRIPT VARIABLES

echo ===================================================================================

echo DBA_USERNAME (P1) : %DBA_USERNAME%

echo DBA_PASSWORD (P2) : xxxxxxxxxxxxx

echo TNS_ALIAS (P3) : %TNS_ALIAS%

echo NUM_DAYS_TO_KEEP (P4) : %NUM_DAYS_TO_KEEP%

echo Oracle Export Parameter File Name : %EXP_PARAMETER_FILE_NAME%

echo Oracle Export Dump File Name : %EXP_DUMP_FILE_NAME%

echo Oracle Export Dump Log File Name : %EXP_DUMP_LOG_FILE_NAME%

echo.


echo ====================================================== > "%LOGFILE%"

echo - START TIME : %START_DATE% %START_TIME% >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo =================================================================================== >> "%LOGFILE%"

echo COMMON SCRIPT VARIABLES >> "%LOGFILE%"

echo =================================================================================== >> "%LOGFILE%"

echo Script Name : %SCRIPT_NAME_FULL% >> "%LOGFILE%"

echo Script Version : %SCRIPT_VERSION% >> "%LOGFILE%"

echo Begin Date : %START_DATE% >> "%LOGFILE%"

echo Begin Time : %START_TIME% >> "%LOGFILE%"

echo Host Name : %HOSTNAME% >> "%LOGFILE%"

echo Log File Name : %LOGFILE% >> "%LOGFILE%"

echo Log File Name (Copy) : %LOGFILE_COPY% >> "%LOGFILE%"

echo =================================================================================== >> "%LOGFILE%"

echo CUSTOM SCRIPT VARIABLES >> "%LOGFILE%"

echo =================================================================================== >> "%LOGFILE%"

echo DBA_USERNAME (P1) : %DBA_USERNAME% >> "%LOGFILE%"

echo DBA_PASSWORD (P2) : xxxxxxxxxxxxx >> "%LOGFILE%"

echo TNS_ALIAS (P3) : %TNS_ALIAS% >> "%LOGFILE%"

echo NUM_DAYS_TO_KEEP (P4) : %NUM_DAYS_TO_KEEP% >> "%LOGFILE%"

echo Oracle Export Parameter File Name : %EXP_PARAMETER_FILE_NAME% >> "%LOGFILE%"

echo Oracle Export Dump File Name : %EXP_DUMP_FILE_NAME% >> "%LOGFILE%"

echo Oracle Export Dump Log File Name : %EXP_DUMP_LOG_FILE_NAME% >> "%LOGFILE%"



echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - REMOVE TEMPORARY EXPORT LOG AND PARAMETER FILE. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


del /q %EXP_PARAMETER_FILE_NAME% >> "%LOGFILE%"

del /q %EXP_DUMP_LOG_FILE_NAME% >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo Done. >> "%LOGFILE%"



echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - WRITE EXPORT PARAMETER FILE. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


echo userid=%DBA_USERNAME%/%DBA_PASSWORD%@%TNS_ALIAS% > %EXP_PARAMETER_FILE_NAME%

echo buffer=50000000 >> %EXP_PARAMETER_FILE_NAME%

echo file=%EXP_DUMP_FILE_NAME% >> %EXP_PARAMETER_FILE_NAME%

echo compress=n >> %EXP_PARAMETER_FILE_NAME%

echo grants=y >> %EXP_PARAMETER_FILE_NAME%

echo indexes=y >> %EXP_PARAMETER_FILE_NAME%

echo direct=no >> %EXP_PARAMETER_FILE_NAME%

echo log=%EXP_DUMP_LOG_FILE_NAME% >> %EXP_PARAMETER_FILE_NAME%

echo rows=y >> %EXP_PARAMETER_FILE_NAME%

echo consistent=y >> %EXP_PARAMETER_FILE_NAME%

echo full=y >> %EXP_PARAMETER_FILE_NAME%

REM owner=(SCOTT) >> %EXP_PARAMETER_FILE_NAME%

REM echo tables=(EMP, DEPT) >> %EXP_PARAMETER_FILE_NAME%

echo triggers=y >> %EXP_PARAMETER_FILE_NAME%

echo statistics=none >> %EXP_PARAMETER_FILE_NAME%

echo constraints=y >> %EXP_PARAMETER_FILE_NAME%


echo. >> "%LOGFILE%"

echo Done. >> "%LOGFILE%"



echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - PERFORM EXPORT. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


%ORACLE_HOME%\bin\exp parfile=%EXP_PARAMETER_FILE_NAME%


echo. >> "%LOGFILE%"

echo Done. >> "%LOGFILE%"



echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - DISPLAY EXPORT LOG FILE. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


type %EXP_DUMP_LOG_FILE_NAME% >> "%LOGFILE%"

echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - SCAN LOG FILE FOR ERRORS >> "%LOGFILE%"

echo IGNORE 'EXP-00079: Data in table "[TABLE_NAME]" is protected. >> "%LOGFILE%"

echo - APPLY RETENTION POLICY FOR OBSOLETE EXPORT (DUMP) FILES. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

findstr /i "ORA- EXP-" "%LOGFILE%" | findstr /v "EXP-00079" >> "%LOGFILE%"

IF errorlevel 1 (set ERRORS="NO") ELSE (set ERRORS="YES")

IF %ERRORS%=="YES" (

echo. >> "%LOGFILE%"

echo SETTING ERRORS TO %ERRORS% >> "%LOGFILE%"

echo. >> "%LOGFILE%"

echo ----------------------------------------------- >> "%LOGFILE%"

echo Detected known exceptions in the export log >> "%LOGFILE%"

echo file. Retention policy will NOT be enforced. >> "%LOGFILE%"

echo ----------------------------------------------- >> "%LOGFILE%"

) ELSE (

echo. >> "%LOGFILE%"

echo SETTING ERRORS TO %ERRORS% >> "%LOGFILE%"

echo. >> "%LOGFILE%"

echo ----------------------------------------------- >> "%LOGFILE%"

echo Did not detect any known exceptions in the >> "%LOGFILE%"

echo export log file. Applying retention policy. >> "%LOGFILE%"

echo ----------------------------------------------- >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - REMOVE OBSOLETE LOG FILES. >> "%LOGFILE%"

echo %LOGDIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_*.log >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo List of log files in %LOGDIR% older than %NUM_DAYS_TO_KEEP% days... >> "%LOGFILE%"

forfiles /P %LOGDIR% /S /D -%NUM_DAYS_TO_KEEP% /M %SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_*.log /C "CMD /C Echo @FILE will be deleted!" >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo Deleting log files in %LOGDIR% older than %NUM_DAYS_TO_KEEP% days... >> "%LOGFILE%"

forfiles /P %LOGDIR% /S /D -%NUM_DAYS_TO_KEEP% /M %SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_*.log /C "CMD /C del /Q /F @FILE" >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - REMOVE OBSOLETE EXPORT DUMP FILES. >> "%LOGFILE%"

echo %ORA_EXP_DIR%\%SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_*.dmp >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo List of dump files in %ORA_EXP_DIR% older than %NUM_DAYS_TO_KEEP% days... >> "%LOGFILE%"

forfiles /P %ORA_EXP_DIR% /S /D -%NUM_DAYS_TO_KEEP% /M %SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_*.dmp /C "CMD /C Echo @FILE will be deleted!" >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo Deleting dump files in %ORA_EXP_DIR% older than %NUM_DAYS_TO_KEEP% days... >> "%LOGFILE%"

forfiles /P %ORA_EXP_DIR% /S /D -%NUM_DAYS_TO_KEEP% /M %SCRIPT_NAME_NOEXT%_%TNS_ALIAS%_*.dmp /C "CMD /C del /Q /F @FILE" >> "%LOGFILE%"

)



echo. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"

echo - REMOVE ANY TEMPORARY FILES. >> "%LOGFILE%"

echo ============================================================== >> "%LOGFILE%"


del /q %EXP_PARAMETER_FILE_NAME% >> "%LOGFILE%"

del /q %EXP_DUMP_LOG_FILE_NAME% >> "%LOGFILE%"


echo. >> "%LOGFILE%"

echo Done. >> "%LOGFILE%"



REM +--------------------------------------------------------------------------+

REM | SET END DATE AND TIME ENVIRONMENT VARIABLES |

REM +--------------------------------------------------------------------------+


set END_DATE=%DATE%

set END_TIME=%TIME%


echo.

echo ======================================================

echo - FINISH TIME : %END_DATE% %END_TIME%

echo ======================================================



echo. >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"

echo - FINISH TIME : %END_DATE% %END_TIME% >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"



echo. >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"

echo - SEND EMAIL TO ADMINISTRATORS >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"


IF %ERRORS%=="YES" (

set EMAIL_STATUS=[%HOSTNAME%] - FAILED: %SCRIPT_NAME_FULL%

) ELSE (

set EMAIL_STATUS=[%HOSTNAME%] - SUCCESSFUL: %SCRIPT_NAME_FULL%

)


blat "%LOGFILE%" -subject "%EMAIL_STATUS%" -to %SMTP_EMAIL_TO% -server %SMTP_SERVER% -f %SMTP_EMAIL_FROM%



echo. >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"

echo - EXITING SCRIPT >> "%LOGFILE%"

echo ====================================================== >> "%LOGFILE%"


echo Making copy of log file [%LOGFILE%] to [%LOGFILE_COPY%] >> "%LOGFILE%"

copy /Y /V %LOGFILE% %LOGFILE_COPY% >> "%LOGFILE%"



REM +--------------------------------------------------------------------------+

REM | END THIS SCRIPT |

REM +--------------------------------------------------------------------------+


goto END



REM +==========================================================================+

REM | *** END OF SCRIPT *** |

REM +==========================================================================+


REM +--------------------------------------------------------------------------+

REM | LABEL DECLARATION SECTION |

REM +--------------------------------------------------------------------------+


:USAGE

echo Usage: %SCRIPT_NAME_FULL% "DBA_USERNAME" "DBA_PASSWORD" "TNS_ALIAS" "NUM_DAYS_TO_KEEP"

echo.

echo DBA_USERNAME = Oracle DBA Username - (Requires DBA Role)

echo DBA_PASSWORD = Oracle DBA Password

echo TNS_ALIAS = Connect String to connect to the database (ex. ORCL)

echo NUM_DAYS_TO_KEEP = Number of days worth of Oracle exports to retain on the file system

goto END


:ENV_VARIABLES

echo ERROR: You must set the following environment variables before

echo running this script or manually set them within the script:

echo.

echo ORA_EXP_DIR = Directory used for export dump files

goto END


:END

@echo on

Build Your Own Oracle RAC Cluster on Oracle Enterprise Linux and iSCSI

Build Your Own Oracle RAC Cluster on Oracle Enterprise Linux and iSCSI

Grid Control components be automatically started and stopped upon host shutdown or reboot on Red Hat/Oracle Enterprise Linux

How can the Grid Control components be automatically started and stopped upon host shutdown or reboot on Red Hat/Oracle Enterprise Linux?


Applies to:

Enterprise Manager Grid Control - Version: 10.2.0.1 to 10.2.0.4
Linux x86

Goal

How can the Grid Control components be automatically started and stopped upon host shutdown or reboot on Red Hat/Oracle Enterprise Linux?

Solution

I. Automatically Starting Grid Control components on Red Hat/Oracle Enterprise Linux

Grid Control provides several scripts that allow for automatic starting of its components during
the boot process. The specific scripts for each component are located on its ORACLE_HOME. On a normal Grid Control installation the scripts controlling the automatic startup/shutdown are

$DB_HOME/install/unix/scripts/seedstup
$OMS_HOME/install/unix/scripts/agentstup
$AGENT_HOME/install/unix/scripts/agentstup

There is also a general startup script that will be run by the Linux boot up process. The script called gcstarup is located on
/etc/rc.d/init.d/gcstartup,
and to be called at startup two links are created to it
/etc/rc.d/rc3.d/S99gcstartup
/etc/rc.d/rc5.d/S99gcstartup


By default, this functionality should be activated after installation, however, sometimes there is some misconfiguration that prevents Grid Control components to start automatically on boot time. To check that the configuration is correct, follow the steps below.

1.- Database script.
1.1 If Grid Control has been installed with the new database option, the startup/shutdown script for the database should be located on the following location

$DB_HOME/install/unix/scripts/seedstup.

Check the following lines and ensure that the correct values are present

export ORACLE_HOME=<ORACLE_HOME_PATH>
user=<OS_user_that_owns_the_installation>
export ORACLE_SID=<SID>

1.2 If Grid Control was installed using an existing database, the startup script will not exist on the previous mentioned location. To construct the database startup script follow the below steps
1.2.1.- Create the directory scripts
$mkdir $ORACLE_HOME/install/unix/scripts
1.2.2.- Create the file seedstup
$touch $ORACLE_HOME/install/unix/scripts/seedstup
1.2.3.- Open the file seedstup and enter the following text. Replace the environment variables and the user with the appropriate values.

#!/bin/sh
#Script to start and stop the Listener and Database during shutdown and restart of the machine

function dbop
{
todo=$1
case $todo in

startup)
$ORACLE_HOME/bin/lsnrctl start
$ORACLE_HOME/bin/sqlplus '/as sysdba'<<- _START_DB
startup;
exit;
_START_DB
;;

shutdown)

$ORACLE_HOME/bin/lsnrctl stop;
$ORACLE_HOME/bin/sqlplus '/as sysdba'<<- _STOP_DB
shutdown immediate;
exit;
_STOP_DB
;;

*)
echo $"Usage: $0 {start|stop}";
exit 1;
esac

}

export ORACLE_HOME=<ORACLE_HOME_PATH>
user=<OS_user_that_owns_the_installation>
export ORACLE_SID=<SID>
SU=/bin/su

if [ $# -gt 1 ]; then
dbop $2
export -n ORACLE_HOME
export -n ORACLE_SID
exit
fi

case "$1" in
start)
$SU $user -c "$ORACLE_HOME/install/unix/scripts/seedstup $1 startup"
;;
stop)
$SU $user -c "$ORACLE_HOME/install/unix/scripts/seedstup $1 shutdown"
;;
*)
echo $"Usage: $0 {start|stop}";
exit 1;
esac

export -n ORACLE_HOME
export -n ORACLE_SID



$chmod +x seedstup
B.- Checking the oms and agent startup scripts
B.1 Open the file
$OMS_ORACLE_HOME/install/unix/scripts/omsstup
and check that the ORACLE_HOME and user are correctly set
B.2 Open the file

$AGENT_HOME/install/unix/scripts/agentstup
and check that the ORACLE_HOME and user are correctly set

C.- Configure the gcstartup script
Grid Control installation installs the gcstartup script and the appropriate links to it to process it on the preferred runlevel. The locations are
/etc/rc.d/init.d/gcstartup
/etc/rc.d/rc5.d/S99gcstartup
/etc//rc.d/rc3.d/S99gcstartup

The two files on the bottom should be hard links to the first script.
On each new installation or modification of the Grid Control components, lines are added to gcstartup which may cause malfunctioning of the script. For the script to work properly, edit the script following the steps below.

C.1. Please backup the three files mentioned above. Then edit the gcstartup script to contain only the
following text:

#!/bin/sh
#Source Function Library

if [ -f /etc/init.d/functions ]
then
. /etc/init.d/functions
else
if [ -f /etc/rc.d/init.d/functions ]
then
. /etc/rc.d/init.d/functions
fi
fi


if [ -f <DB_HOME>/install/unix/scripts/seedstup ]; then
. <DB_HOME>/install/unix/scripts/seedstup
fi


if [ -f <OMS_HOME>/install/unix/scripts/omsstup ]; then
. <OMS_HOME>/install/unix/scripts/omsstup
fi


if [ -f <AGENT_HOME>/install/unix/scripts/agentstup ]; then
. <AGENT_HOME>/install/unix/scripts/agentstup
fi


Replace <AGENT_HOME>, <DB_HOME> and <OMS_HOME> with the complete path to each home.

D.- Testing the script
Shutdown all Grid Control components
execute the command
/etc/rc.d/init.d/gcstartup start

All components should start in the correct order

II. Automatically Stopping Grid Control components

To stop the Grid Control Components automatically upon host shutdown or reboot, please follow the
next steps. It is assumed that you have already applied the above steps to ensure automatic
startup of the components.

1.- Open the gcstartup script, located on
/etc/rc.d/init.d/gcstartup

2.- Edit the script replacing its contents by the following text.

#!/bin/sh
#Source Function Library

if [ -f /etc/init.d/functions ]
then
. /etc/init.d/functions
else
if [ -f /etc/rc.d/init.d/functions ]
then
. /etc/rc.d/init.d/functions
fi
fi

case "$1" in
start)

if [ -f <DB_HOME>/install/unix/scripts/seedstup ]; then
. <DB_HOME>/install/unix/scripts/seedstup
fi


if [ -f <OMS_HOME>/install/unix/scripts/omsstup ]; then
. <OMS_HOME>/install/unix/scripts/omsstup
fi


if [ -f <AGENT_HOME>/install/unix/scripts/agentstup ]; then
. <AGENT_HOME>/install/unix/scripts/agentstup
fi

touch /var/lock/subsys/gcstartup
;;
stop)


if [ -f <OMS_HOME>/install/unix/scripts/omsstup ]; then
. <OMS_HOME>/install/unix/scripts/omsstup
fi


if [ -f <AGENT_HOME>/install/unix/scripts/agentstup ]; then
. <AGENT_HOME>/install/unix/scripts/agentstup
fi

if [ -f <DB_HOME>/install/unix/scripts/seedstup ]; then
. <DB_HOME>/install/unix/scripts/seedstup
fi
rm -f /var/lock/subsys/gcstartup

esac


Replace <AGENT_HOME>, <DB_HOME> and <OMS_HOME> with the complete path to each home.

This modification ensures that the same gcstartup script can be used to start and stop the components in the right order. Furthermore, in order to shutdown services, Red Hat Linux requires that each service creates a file under the /var/log/subsys/ directory to notify the system that the service is active. The above script
creates that file on startup and removes it when stopping the components.
Only the first time you shutdown or reboot it will be necessary to
create that file manually, using the following command
$touch /var/lock/subsys/gcstartup

4.- Create the following symbolic links to include the gcstartup script on the shutdown and reboot
process

$ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc0.d/K01gcstartup
$ln -s /etc/rc.d/init.d/gcstartup /etc/rc.d/rc6.d/K01gcstartup

# ln -s /etc/init.d/gcstartup /etc/rc5.d/S98gcstartup
# ln -s /etc/init.d/gcstartup /etc/rc3.d/S98gcstartup


The K on the symbolic link indicates it is a Kill script and the 01 indicates its priority on the
shutdown process.

5.- Testing the script
Execute the commands
/etc/rc.d/init.d/gcstartup start
/etc/rc.d/init.d/gcstartup stop

The components should start and stop automatically on the correct order.

References

BUG:5383799 - OMS,AGENT AND REPOSITORY DATABASE DO NOT AUTO START ON REBOOT OF MACHINE
NOTE:392426.1 - Problem: gcstartup does not start Agent and Management Server during server reboot