-
-
Save rmoff/42e2faa0c71805c58712 to your computer and use it in GitHub Desktop.
Oracle DB init.d script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# chkconfig: 345 90 10 | |
# description: Oracle auto start-stop script. | |
# | |
# Taken from http://www.oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux.php#oracle–11gr2-update | |
# | |
# Set ORA_OWNER to the user id of the owner of the | |
# Oracle database software. | |
# | |
# Install steps: | |
# 1. Create this file as /etc/init.d/dbora | |
# 2. chmod 750 /etc/init.d/dbora | |
# 3. chkconfig --add dbora | |
# 4. Create startup.sh and shutdown.sh in /home/oracle/scripts/ | |
# | |
ORA_OWNER=oracle | |
case "$1" in | |
'start') | |
# Start the Oracle databases: | |
# The following command assumes that the oracle login | |
# will not prompt the user for any values | |
su - $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" | |
touch /var/lock/subsys/dbora | |
;; | |
'stop') | |
# Stop the Oracle databases: | |
# The following command assumes that the oracle login | |
# will not prompt the user for any values | |
su - $ORA_OWNER -c "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" | |
rm -f /var/lock/subsys/dbora | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /home/oracle/scripts/shutdown.sh | |
# | |
# This script assumes that the following are set in your user profile and this is sourced before this script is run. If not, then put them in this script | |
# export TMPDIR=$TMP | |
# export TMP=/tmp | |
# export ORACLE_HOSTNAME=ol6-112.localdomain | |
# export ORACLE_UNQNAME=DB11G | |
# export ORACLE_BASE=/u01/app/oracle | |
# export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 | |
# export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH | |
# export ORACLE_SID=DB11G | |
# ORAENV_ASK=NO | |
# . oraenv | |
# ORAENV_ASK=YES | |
# Start Listener | |
lsnrctl start | |
# Start Database | |
sqlplus / as sysdba << EOF | |
STARTUP; | |
EXIT; | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /home/oracle/scripts/shutdown.sh | |
# | |
# This script assumes that the following are set in your user profile and this is sourced before this script is run. If not, then put them in this script | |
# export TMPDIR=$TMP | |
# export TMP=/tmp | |
# export ORACLE_HOSTNAME=ol6-112.localdomain | |
# export ORACLE_UNQNAME=DB11G | |
# export ORACLE_BASE=/u01/app/oracle | |
# export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 | |
# export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH | |
# export ORACLE_SID=DB11G | |
# ORAENV_ASK=NO | |
# . oraenv | |
# ORAENV_ASK=YES | |
# Stop Database | |
sqlplus / as sysdba << EOF | |
SHUTDOWN IMMEDIATE; | |
EXIT; | |
EOF | |
# Stop Listener | |
lsnrctl stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment