20070329 oracle db init script for red hat - plembo/onemoretech GitHub Wiki

title: Oracle DB Init Script for Red Hat link: https://onemoretech.wordpress.com/2007/03/29/oracle-db-init-script-for-red-hat/ author: lembobro description: post_id: 730 created: 2007/03/29 14:20:00 created_gmt: 2007/03/29 14:20:00 comment_status: open post_name: oracle-db-init-script-for-red-hat status: publish post_type: post

Oracle DB Init Script for Red Hat

Here it is, taken from my old personal web site:

`

#!/bin/bash
# chkconfig: 35 95 1
# description: init script to start/stop oracle database 10g, TNS listener
#
#
# match these values to your environment:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/db1
export OH=$ORACLE_HOME
export JAVA_HOME=$OH/jdk
export PATH=$OH/bin:$JAVA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export ORACLE_SID=db1
export ORACLE_USER=oracle
# see how we are called:
case $1 in
    start)
    echo "Starting Oracle database ..."
    su - "$ORACLE_USER" <<EOO
    lsnrctl start
    sqlplus /nolog <<EOS
    connect / as sysdba
    startup
EOS
    emctl start dbconsole
EOO
    ;;
	
   stop)
    echo "Stopping Oracle database ..."
    su - "$ORACLE_USER" <<EOO
    emctl stop dbconsole
    sqlplus /nolog <<EOS
    connect / as sysdba
    shutdown immediate
EOS
    lsnrctl stop
EOO
    ;;
	
    *)
    echo "Usage: $0 {start|stop}"
    ;;
esac

`

This, of course, goes in /etc/init.d, and should be named something appropriate, like “oracle”.

Remember to use /sbin/chkconfig --add [script name, e.g. oracle] as root to register this script, and then /sbin/chkconfig [script name] on to enable it.

Copyright 2004-2019 Phil Lembo