数据库自动启动关闭
1、安装数据库后
一、 在标准的/etc/oratab文件中,添加下面的行(指出数据库名、ORACLE_HOME,以及数据库是否应该自动启动和关闭)
数据库名:$ORACLE_HOME:Y
二、
以root用户建立/etc/rc.d/init.d/oracle10g脚本文件,内容如下(环境变量设置根据实际情况进行修改):
#!/bin/bash
#
# chkconfig: 35 95 1
# description: init script. to start/stop oracle database 10g, TNS listener, EMS, isqlplus
#
#
#
# match these values to your environment:
export ORACLE_BASE=/usr/ora10g/
export ORACLE_HOME=$ORACLE_BASE/product/10.2
# export ORACLE_TERM=xterm
export PATH=$PATH:$ORACLE_HOME/bin
# export NLS_LANG='american_america.ZHS16GBK'
export ORACLE_SID=iccard
# export DISPLAY=localhost:0
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<lsnrctl start
sqlplus /nolog<connect / as sysdba
startup
EOS
emctl start dbconsole
isqlplusctl start
EOO
;;
stop)
su - "$ORACLE_USER"<lsnrctl stop
sqlplus /nolog<connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
isqlplusctl stop
EOO
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
二、 以root用户执行以下命令
chmod 755 /etc/rc.d/init.d/oracle10g
chkconfig --add oracle10g
三、 重启服务
service oracle10g stop
service oracle10g start
这样在开关机的时候oracle自动启动和停止。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14359/viewspace-263411/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14359/viewspace-263411/