100% found this document useful (1 vote)
450 views3 pages

Oracle DB Startup and Shutdown Automation

This document describes how to automate the startup and shutdown of an Oracle database on a Linux server. The key steps are: 1. Modify the /etc/oratab file to set the database to start automatically. 2. Create a script called dbstart in $ORACLE_HOME/bin to start the database. 3. Create an init script called dbora in /etc/init.d to start and stop the database as a service using the dbstart and dbshut scripts.

Uploaded by

FrancesHsieh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
450 views3 pages

Oracle DB Startup and Shutdown Automation

This document describes how to automate the startup and shutdown of an Oracle database on a Linux server. The key steps are: 1. Modify the /etc/oratab file to set the database to start automatically. 2. Create a script called dbstart in $ORACLE_HOME/bin to start the database. 3. Create an init script called dbora in /etc/init.d to start and stop the database as a service using the dbstart and dbshut scripts.

Uploaded by

FrancesHsieh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Environment Setup
  • Script Details
  • Testing Scripts

Automating Oracle Database Startup and Shutdown on Linux

oracle

VM

[root@localhost /]# su - oracle

[oracle@localhost /]# echo $ORACLE_BASE

Check environment variable

-- /oracle
[oracle@localhost /]# echo $ORACLE_HOME
-- /oracle/db10g
[oracle@localhost /]# echo $ORACLE_SID
-- oracle sid

root

root

root

oracle

/etc/oratab

[root@localhost /]# vi /etc/oratab

Modify $ORACLE_SID:$ORACLE_HOME:Y|N in /etc/oratab

# oracle sid:/oracle/db10g:N

Change value from N to Y for the scripts to start or shut down the database

oracle sid:/oracle/db10g:Y

VM

[root@localhost /]# echo $PATH

Check if $ORACLE_HOME/bin exists in path

[root@localhost /]# PATH=$PATH:/oracle/db10g/bin

Add $ORACLE_HOME/bin to the path if it is not found

$ORACLE_HOME/bin/dbstart

[root@localhost /]# vi /oracle/db10g/bin/dbstart

ORACLE_HOME_LISTNER=$ORACLE_HOME

Modify the value of ORACLE_HOME_LISTNER in $ORACLE_HOME/bin/dbstart

[root@localhost /]# su - oracle

[oracle@localhost /]# dbstart

Test the database startup and shutdown scripts

[oracle@localhost /]# dbshut

root

/etc/init.d/dbora

[root@localhost /]# cd /etc/init.d

[root@localhost init.d]# vi dbora

Create a file dbora in /etc/init.d

#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#

# Set ORA_HOME to be equivalent to the $ORACLE_HOME


# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

ORA_HOME=/oracle/db10g
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi

case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
# Remove "&" if you don't want startup as a background process.
# su $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
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 "$ORA_HOME/bin/dbshut $ORA_HOME"


su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
rm -f /var/lock/subsys/dbora
;;
esac

root

root

root

/etc/init.d/dbora
Change privileges and permissions of /etc/init.d/oracle

[root@localhost init.d]# chgrp dba dbora


[root@localhost init.d]# chmod 755 dbora

[root@localhost /]# chkconfig --add dbora

Registers the service at run-levels 3,4, and 5 as well as to auto start

[root@localhost /]# chkconfig --level 345 dbora on

Display whether a service is on or off for each run-level

[root@localhost /]# chkconfig --list | grep oracle

[root@localhost /]# service dbora start

[root@localhost /]# service dbora stop

Test the startup and shutdown services

Automating Oracle Database Startup and Shutdown on Linux 
 
執行 
身分 
目的 
執行命令 
oracle 
檢查VM 伺服器資料庫環境變數 
 
Check environment v
# Set ORA_HOME to be equivalent to the $ORACLE_HOME 
# from which you wish to execute dbstart and dbshut; 
# 
# Set ORA_OWNER
# su $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"         
        su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HO

You might also like