一、启动数据库:
1、修改Oracle系统配置文件/etc/oratab内容,将最后一行中最后一个字符的N改为Y
root用户登录修改
#vi /etc/oratab
由如下:
orcl:/oracle/app/product:N
改为如下并保存退出
orcl:/oracle/app/product:Y
2、redhat修改/etc/rc.d/rc.local文件,添加如下内容
#vi /etc/rc.d/rc.local
su -c "dbstart" - oracle
3、切换到oracle用户登录修改$ORACLE_HOME/bin/dbstart,找到ORACLE_HOME_LISTNER=,将值改为ORACLE_HOME的路径,或环境变量。
#su - oracle
$vi $ORACLE_HOME/bin/dbstart
# First argument is used to bring up Oracle Net Listener
#ORACLE_HOME_LISTNER=$1 ----修改$1为$ORACLE_HOME
ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
二、关闭数据库:
1、切换到oracle用户登录修改$ORACLE_HOME/bin/dbshut,找到ORACLE_HOME_LISTNER=,将值改为ORACLE_HOME的路径,或环境变量。
#su - oracle
$vi $ORACLE_HOME/bin/dbshut
# The this to bring down Oracle Net Listener
#ORACLE_HOME_LISTNER=$1 ----修改$1为$ORACLE_HOME
ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
2、新建脚本rc.local.dbshut
[root@APILINUX ~]# cat /etc/rc.d/rc.local.dbshut
#!/bin/bash
# chkconfig: - 00 00
# description: Do custom commands before shutdown or reboot
### BEGIN INIT INFO
# Provides: custom-halt
# Required-Start:
# Required-Stop:
# Default-Start: 0 6
# Default-Stop:
# Short-Description: Custom halt commands
# Description: Do custom commands before shutdown or reboot
### END INIT INFO
export ORACLE_BASE=/oracle/app
export ORACLE_HOME=$ORACLE_BASE/product/
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
su - oracle -lc "$ORACLE_HOME/bin/dbshut /dev/null 2>&1"
exit
3、让它运行在0和6运行级别runlevel:
# chmod 755 /etc/rc.d/rc.local.dbshut
# ln -s /etc/rc.d/rc.local.dbshut /etc/rc.local.dbshut
# ln -s /etc/rc.d/rc.local.dbshut /etc/init.d/local-dbshut
# chkconfig --add local-dbshut
# chkconfig --level 06 local-dbshut on
# chkconfig --list local-dbshut
local-dbshut 0:on 1:off 2:off 3:off 4:off 5:off 6:on
三、测试检查
1、使用reboot、init 0方式看数据库是否停止和启动
2、检查$ORACLE_HOME下的startup.log,shtdown.log,listener.log日志文件
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/532823/viewspace-2080371/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/532823/viewspace-2080371/