Automating Database Startup and Shutdown(开机启动和关闭oracle)
2008-04-22 18:10
621 查看
參考:http://download.oracle.com/docs/pdf/B10812_02.pdf
Use the dbstart and dbshut scripts to automate database startup and shutdown.
Perform the following tasks to set up these scripts so that they are called at system
startup and shutdown. Perform these steps for every new database that you want to
configure for automated startup and shutdown:
1. Log in as the root user.
2. Edit the oratab file for your platform:
■ Solaris:
/var/opt/oracle/oratab
Note: The procedure described in this section applies to
single-instance databases only.
See Also: For more information about system startup and
shutdown procedures, see the init command in your UNIX
system documentation.
Automating Startup and Shutdown
Starting and Stopping Oracle Software 2-11
■ Other operating systems:
/etc/oratab
Database entries in the oratab file appear in the following format:
SID:ORACLE_HOME:{Y|N}
In this example, Y or N specifies whether you want the scripts to start up or
shut down the database. For each database that you want to start up and shut
down, find the instance identifier (SID) for that database, identified by the SID
in the first field, and change the last field for each to Y.
3. Change directory to one of the following directories, depending on your
platform:
4. Create a file called dbora with the following contents. Change the value
specified for the ORACLE_HOME environment variable to an Oracle home
directory for your installation, and change the value of the ORACLE
environment variable to the username of the owner of the database installed in
the Oracle home directory (typically oracle):
#! /bin/sh -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for you installation
ORACLE_HOME=/u01/app/oracle/product/10.1.0/db_1
#
# change the value of ORACLE to the login name of the
# oracle owner at your site
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
Platform Initialization File Directory
AIX /etc
Linux and Solaris /etc/init.d
HP-UX and Tru64 UNIX /sbin/init.d
Automating Startup and Shutdown
2-12 Administrator’s Reference
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! "$2" = "ORA_DB" ] ; then
if [ "$PLATFORM" = "HP-UX" ] ; then
remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
exit
fi
fi
#
LOG=$ORACLE_HOME/startup.log
touch $LOG
chmod a+r $LOG
#
case $1 in
'start')
echo "$0: starting up" >> $LOG
date >> $LOG
# Start Oracle Net
if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then
echo "starting Oracle Net Listener"
$ORACLE_HOME/bin/lsnrctl start >> $LOG 2>&1 &
fi
echo "Starting Oracle databases"
$ORACLE_HOME/bin/dbstart >> $LOG 2>&1 &
;;
'stop')
echo "$0: shutting down" >> $LOG
date >> $LOG
# Stop Oracle Net
if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then
echo "stopping Oracle Net Listener"
$ORACLE_HOME/bin/lsnrctl stop >> $LOG 2>&1 &
fi
echo "stopping Oracle databases"
$ORACLE_HOME/bin/dbshut >> $LOG 2>&1 &
;;
Automating Startup and Shutdown
Starting and Stopping Oracle Software 2-13
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit
5. Change the group of the dbora file to the OSDBA group (typically dba) and set
the permissions to 750:
# chgrp dba dbora
# chmod 750 dbora
6. Create symbolic links to the dbora script in the appropriate run-level script
directories, as follows:
Note: This script works only if a password has not been set for the
Oracle Net listener. If a password has been set for the listener, this
script cannot stop the listener. Also, if the listener name is not the
default name LISTENER, you must specify the listener name in the
stop and start commands:
$ORACLE_HOME/bin/lsnrctl {start|stop} listener_name
Platform Symbolic Links Commands
AIX # ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
# ln -s /etc/dbora /etc/rc.d/rc2.d/K01dbora
HP-UX # ln -s /sbin/init.d/dbora /sbin/rc3.d/S990dbora
# ln -s /sbin/init.d/dbora /sbin/rc3.d/K001dbora
Linux # ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
Solaris # ln -s /etc/init.d/dbora /etc/rc3.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
Tru64 UNIX # ln -s /sbin/init.d/dbora /sbin/rc3.d/S99dbora
# ln -s /sbin/init.d/dbora /sbin/rc3.d/K01dbora
Use the dbstart and dbshut scripts to automate database startup and shutdown.
Perform the following tasks to set up these scripts so that they are called at system
startup and shutdown. Perform these steps for every new database that you want to
configure for automated startup and shutdown:
1. Log in as the root user.
2. Edit the oratab file for your platform:
■ Solaris:
/var/opt/oracle/oratab
Note: The procedure described in this section applies to
single-instance databases only.
See Also: For more information about system startup and
shutdown procedures, see the init command in your UNIX
system documentation.
Automating Startup and Shutdown
Starting and Stopping Oracle Software 2-11
■ Other operating systems:
/etc/oratab
Database entries in the oratab file appear in the following format:
SID:ORACLE_HOME:{Y|N}
In this example, Y or N specifies whether you want the scripts to start up or
shut down the database. For each database that you want to start up and shut
down, find the instance identifier (SID) for that database, identified by the SID
in the first field, and change the last field for each to Y.
3. Change directory to one of the following directories, depending on your
platform:
4. Create a file called dbora with the following contents. Change the value
specified for the ORACLE_HOME environment variable to an Oracle home
directory for your installation, and change the value of the ORACLE
environment variable to the username of the owner of the database installed in
the Oracle home directory (typically oracle):
#! /bin/sh -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for you installation
ORACLE_HOME=/u01/app/oracle/product/10.1.0/db_1
#
# change the value of ORACLE to the login name of the
# oracle owner at your site
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
Platform Initialization File Directory
AIX /etc
Linux and Solaris /etc/init.d
HP-UX and Tru64 UNIX /sbin/init.d
Automating Startup and Shutdown
2-12 Administrator’s Reference
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! "$2" = "ORA_DB" ] ; then
if [ "$PLATFORM" = "HP-UX" ] ; then
remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
exit
fi
fi
#
LOG=$ORACLE_HOME/startup.log
touch $LOG
chmod a+r $LOG
#
case $1 in
'start')
echo "$0: starting up" >> $LOG
date >> $LOG
# Start Oracle Net
if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then
echo "starting Oracle Net Listener"
$ORACLE_HOME/bin/lsnrctl start >> $LOG 2>&1 &
fi
echo "Starting Oracle databases"
$ORACLE_HOME/bin/dbstart >> $LOG 2>&1 &
;;
'stop')
echo "$0: shutting down" >> $LOG
date >> $LOG
# Stop Oracle Net
if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then
echo "stopping Oracle Net Listener"
$ORACLE_HOME/bin/lsnrctl stop >> $LOG 2>&1 &
fi
echo "stopping Oracle databases"
$ORACLE_HOME/bin/dbshut >> $LOG 2>&1 &
;;
Automating Startup and Shutdown
Starting and Stopping Oracle Software 2-13
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit
5. Change the group of the dbora file to the OSDBA group (typically dba) and set
the permissions to 750:
# chgrp dba dbora
# chmod 750 dbora
6. Create symbolic links to the dbora script in the appropriate run-level script
directories, as follows:
Note: This script works only if a password has not been set for the
Oracle Net listener. If a password has been set for the listener, this
script cannot stop the listener. Also, if the listener name is not the
default name LISTENER, you must specify the listener name in the
stop and start commands:
$ORACLE_HOME/bin/lsnrctl {start|stop} listener_name
Platform Symbolic Links Commands
AIX # ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
# ln -s /etc/dbora /etc/rc.d/rc2.d/K01dbora
HP-UX # ln -s /sbin/init.d/dbora /sbin/rc3.d/S990dbora
# ln -s /sbin/init.d/dbora /sbin/rc3.d/K001dbora
Linux # ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
Solaris # ln -s /etc/init.d/dbora /etc/rc3.d/K01dbora
# ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
Tru64 UNIX # ln -s /sbin/init.d/dbora /sbin/rc3.d/S99dbora
# ln -s /sbin/init.d/dbora /sbin/rc3.d/K01dbora
相关文章推荐
- oracle 启动(startup)和关闭(shutdown)实例(instance),加载和卸载数据库(database),以及服务(service)
- Oracle Startup / Shutdown启动和关闭过程详解(概念)
- Automating Database Startup and Shutdown on Linux
- DBA_Oracle Startup / Shutdown启动和关闭过程详解(概念)(对数据库进行各种维护操作)
- oracle服务启动(startup),关闭(shutdown)几种方式,及参数详解
- Automating Database Startup and Shutdown
- DBA_Oracle Startup / Shutdown启动和关闭过程详解(概念)(对数据库进行各种维护操作)
- Oracle Database Startup and Shutdown Procedure
- DBA_Oracle Startup / Shutdown启动和关闭过程详解(概念)(对数据库进行各种维护操作)
- oracle for linux 开机启动及停机关闭脚本
- Master Note: Overview of Database Startup and Shutdown (Doc ID 1505155.1)
- oracle的环境配置-设置开机(Linux)自动启动Oracle关机自动关闭Oracle
- 开机自动启动(关闭)oracle服务
- 关闭启动命令shutdown\startup参数解析
- 做个像tocmat那样,写一个startup.bat启动一个java应用,再写一个shutdown.bat来关闭该应用
- Linux 开机启动Oracle 关机关闭oracle
- How to Automate Startup/Shutdown of Oracle Database on Linux [ID 222813.1]
- oracle 关闭/启动数据库_oracle数据库关闭/启动
- linux oracle 启动 关闭 服务 及监听