Google search got this page: http://www.orafaq.com/forum/t/52084/0/
But paste the dbora file to my machine, there are some problems:
1. chkconfig --add dbora complaining “service dbora does not support chkconfig”
2. lsnrctl start/stop failed
After some investigation, I’ve solved the problems. The first one is to add the chkconfig comment(with the dbora and description lines), the second is to export the ORACLE_HOME(not ORA_HOME) and ORACLE_SID variables, and to remove the “-”s in “su” commands. Below is my version of dbora:
#!/bin/bash
# dbora Oracle auto start-stop script.
# chkconfig: 345 99 10
# description: Oracle database
# Set ORACLE_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 ORACLE_HOME.
# Set ORACLE_SID to the sid of your database.
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1/
ORACLE_SID=luol
ORA_OWNER=oracle
export ORACLE_HOME ORACLE_SID
if [ ! -f $ORACLE_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
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNER -c $ORACLE_HOME/bin/dbstart
RETVAL=$?
[ $RETVAL = 0 ] && 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 $ORACLE_HOME/bin/dbshut
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/dbora
;;
esac
To use it just copy it to your /etc/init.d/dbora file, change the relevant variables’ value, chmod, chkconfig --add dbora. You should also check to see if you need to edit you /etc/oratab file.
And everything would work fine as mine. Hopefully…
Note: If you’re in a locale other than English, when you copy & paste the file content from browser to your computer, you may get corrupted quote marks, if you have problem running the script, make sure the quote marks in your file is correct.
The following are my scripts, you can download it for use. The ‘doc’ extension is just used to prevent wordpress from blocking my upload, you can change the extension or delete it.
isqlplus startup script
oracle database startup script