- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help with Oracle 9i startup/shutdown script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2005 08:05 AM
тАО12-27-2005 08:05 AM
Help with Oracle 9i startup/shutdown script
While the commands to startup/shutdown Oracle 9i work from the command line/shell, when the commands are put in a Korn shell script, the script prompts for a password.
Does anyone have Oracle 9i startup/shutdown script advice/examples that I could view?
Please help!
Regards, Cara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2005 01:58 PM
тАО12-27-2005 01:58 PM
Re: Help with Oracle 9i startup/shutdown script
Check your path and all the environment variables are defined and exported. Usually if you can run manually but not through cron it goes back to environment initialisation.
Cron does not run profile therefore it's up to you to initialise the variables in the script.
TO shutdown the database before the cold backup you can invoke the $ORACLE_HOME/bin/dbshut and to start the database fater the backup invoke $ORACLE_HOME/bin/dbstart.
IA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2005 03:38 PM
тАО12-27-2005 03:38 PM
Re: Help with Oracle 9i startup/shutdown script
for more guidance on the scripts and environment settings that you might require, please see also:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=983721
hope this helps too!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2005 06:48 PM
тАО12-27-2005 06:48 PM
Re: Help with Oracle 9i startup/shutdown script
please ensure your environment is the same from the command line and within the script.
Also, are you running the script as oracle or root? If you run it as root, please make sure you use "su - oracle". The minus sign ensures your login goes through the same scripts as if you had logged in directly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2005 07:45 PM
тАО12-27-2005 07:45 PM
Re: Help with Oracle 9i startup/shutdown script
if you want to start/stop all the databases you have at the startup/shutdown of the server you have to use:
$ORACLE_HOME/bin/dbstart
$ORACLE_HOME/bin/dbshut
in etc/rc* files.
Instead if you want to start/stop a single database in a script for your use, let me know and I adapt the standard oracle script for you.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2005 09:02 PM
тАО12-27-2005 09:02 PM
Re: Help with Oracle 9i startup/shutdown script
BACKUP OFFLINE: (with user oracle)
SHUTDOWN:
. /home/oracle/conf/profile_$instance
sqlplus /nolog <
shutdown immediate
exit;
EOF
exit 0
STARTUP:
. /home/oracle/conf/profile_$instance
sqlplus /nolog <
startup pfile=
/oracle1/$instance/init$instance.ora
exit;
EOF
exit 0
BACKUP ONLINE:
Put all tablespaces in mode "begin backup":
alter tablespace $NAME_TABLESPACE begin backup;
When you ended your backup:
alter tablespace $NAME_TABLESPACE end backup;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 01:42 AM
тАО12-28-2005 01:42 AM
Re: Help with Oracle 9i startup/shutdown script
Oracle provide a role 'sysoper' for startup/shutdown instances purpose.
You can create a user and grant sysoper to this user. Then you can put the username/password in the scripts. The role do not has other system privilege and don't need to worry if you hard-code the password in your script.
If the server has many users and only you (Oracle DBA) can connect by using "connect / as sysdba" instead of "connect username/password as sysdba", you can protect the scripts on OS level.
The following is a sample. 'startup_dev2.sh'
. /home/oracle/chg817.sh
LOGDIR=/u01/app/oracle/admin/dbascript/log
ORACLE_SID=dev2
LOGS=$LOGDIR/startup_"$ORACLE_SID".log
export LOGDIR ORACLE_SID LOGS
date >> $LOGS
echo "Starting up dev2 ..."
sqlplus /nolog >> $LOGS << EOF
whenever sqlerror exit 1
connect dboper/dev2_dboper AS SYSOPER;
show user;
startup;
EOF
export ERROR_FLAG=$?
if [ $ERROR_FLAG != "0" ]
then
echo "The dev2 can not be started up !"
echo "The dev2 can not be started up !" >> $LOGS
else
echo "The dev2 has been started up !"
echo "The dev2 has been started up !" >> $LOGS
fi
date >> $LOGS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 01:53 AM
тАО12-28-2005 01:53 AM
Re: Help with Oracle 9i startup/shutdown script
Thank you to all who posted. I will review with the DBA & then respond more & assign points.
Regards, Cara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2005 03:38 AM
тАО12-29-2005 03:38 AM
Re: Help with Oracle 9i startup/shutdown script
1. You don't want to have the prompt for a password when you run shell scripts.
2. Shutdown/start instance need to connect first.
3. Connect to database need a username/password.
4. shell script is a plain text file.
So, if you don't want to put password on scrips, and don't want to see the prompt, the only one way is to put 'connect / as sysdba' in your scripts. But the OS users (they may be operators/sysadmin/dba) who need to run the scripts must belong to OracleDBA group. This setting has more potential problems if the os user login to system he/she can connect to database directly as sysdba without protection. I don't think your DBA would like it.
However, the user who connected AS SYSOPER can only Perform STARTUP and SHUTDOWN, it will not hurt the database. I believe you have method to protect the scripts.
Best Regards
Xiaogang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2006 10:12 PM
тАО01-12-2006 10:12 PM
Re: Help with Oracle 9i startup/shutdown script
It should ONLY be executed as part of the system boot procedure.
-------------#### Script Begins
$Header: dbstart.sh.pp 09-dec-99.09:51:46 mdenney Exp $ dbstart.sh.pp Copyr (c) 1991 Oracle
#
###################################
#
# usage: dbstart
#
# This script is used to start ORACLE from /etc/rc(.local).
# It should ONLY be executed as part of the system boot procedure.
#
#####################################
ORATAB=/etc/oratab
trap 'exit' 1 2 3
case $ORACLE_TRACE in
T) set -x ;;
esac
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/etc
export PATH ;;
esac
#
# Loop for every entry in oratab file and and try to start
# that ORACLE
#
cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
# Proceed only if third field is 'Y'.
if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] ; then
ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
if [ "$ORACLE_SID" = '*' ] ; then
ORACLE_SID=""
fi
# Called programs use same database ID
export ORACLE_SID
ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
# Called scripts use same home directory
export ORACLE_HOME
# Put $ORACLE_HOME/bin into PATH and export.
PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc ; export PATH
# add for bug # 652997
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib ; export LD_LIBRARY_PATH
PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
# Figure out if this is a V5, V6, or V7 database. Do we really need V5?
if [ -f $ORACLE_HOME/bin/sqldba ] ; then
VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
/SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
print V[1]}'`
else
if test -f $ORACLE_HOME/bin/svrmgrl; then
VERSION=`$ORACLE_HOME/bin/svrmgrl command=exit | awk '
/Edition Release/ {substr($5,1,3) ;
print substr($5,1,3)}'`
else
VERSION="8.2"
fi
fi
STATUS=1
if [ "$VERSION" = "8.1" ]
then
pmon=`ps -ef | egrep pmon_$ORACLE_SID | grep -v grep`
if [ "$pmon" != "" ];
then
STATUS="-1"
echo "Database \"${ORACLE_SID}\" already started."
fi
else
if test -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.dbf -o \
-f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.ora
then
STATUS="-1"
else
STATUS=1
fi
fi
case $STATUS in
1) if [ -f $PFILE ] ; then
case $VERSION in
6) sqldba command=startup
;;
7) sqldba <
startup
EOF
;;
7.3) svrmgrl <
startup
EOF
;;
8.0) svrmgrl <
startup
EOF
;;
8.1) sqlplus /nolog <
startup
EOF
;;
esac
if test $? -eq 0 ; then
echo ""
echo "Database \"${ORACLE_SID}\" warm started."
else
echo ""
echo "Database \"${ORACLE_SID}\" NOT started."
fi
else
echo ""
echo "Can't find init file for Database \"${ORACLE_SID}\"."
echo "Database \"${ORACLE_SID}\" NOT started."
fi
;;
-1) echo ""
echo "Database \"${ORACLE_SID}\" possibly left running when system went down (system crash?)."
echo "Notify Database Administrator."
case $VERSION in
6) sqldba "command=shutdown abort"
;;
7) sqldba <
shutdown abort
EOF
;;
7.3) svrmgrl <
shutdown abort
EOF
;;
8.0) svrmgrl <
shutdown abort
EOF
;;
8.1) sqlplus /nolog <
shutdown abort
EOF
;;
esac
if test $? -eq 0 ; then
if [ -f $PFILE ] ; then
case $VERSION in
6) sqldba command=startup
;;
7) sqldba <
startup
EOF
;;
7.3) svrmgrl <
startup
EOF
;;
8.0) svrmgrl <
startup
EOF
;;
8.1) sqlplus /nolog <
startup
EOF
;;
esac
if test $? -eq 0 ; then
echo ""
echo "Database \"${ORACLE_SID}\" warm started."
else
echo ""
echo "Database \"${ORACLE_SID}\" NOT started."
fi
else
echo ""
echo "Can't find init file for Database \"${ORACLE_SID}\"."
echo "Database \"${ORACLE_SID}\" NOT started."
fi
else
echo "Database \"${ORACLE_SID}\" NOT started."
fi
;;
esac
fi
;;
esac
done
---------------------------## Script Ends
Regards,
Simon