oracle 开机自动启动

来源:互联网 发布:pdf编辑软件手机 编辑:程序博客网 时间:2024/05/17 10:39

一、使用root用户修改/etc/oratab 文件:
$ vi /etc/oratab
orcl:/u01/oracle:N (ORACLE_SID:ORACLE_HOME:N)
改为:
orcl:/u01/oracle:Y 也就是将最后的N改为Y

二、使用Oracle用户修改$ORACLE_HOME/bin/dbstart和dbstop文件:
ORACLE_HOME_LISTNER=$1
改为:
ORACLE_HOME_LISTNER=$ORACLE_HOME

三、创建服务
$su – root
# cd /etc/rc.d/init.d/
# vi oradb
在oradb中添加文本

#!/bin/bash# chkconfig: 345 99 10# description: Startup Script for Oracle Databasesexport ORACLE_BASE=/u01export ORACLE_HOME=/u01/oracleexport ORACLE_SID=orclexport PATH=$PATH:$ORACLE_HOME/binORA_OWNR="oracle"# if the executables do not exist -- display errorif [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]thenecho "Oracle startup: cannot start"exit 1fi# depending on parameter -- startup, shutdown, restart# of the instance and listener or usage displaycase "$1" instart)# Oracle listener and instance startup and oemecho -n "Starting Oracle: "# 启动listener and instancesu - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"touch /var/lock/Oracle# 启动oemsu - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"echo "OK";;stop)# Oracle listener and instance shutdown and oemecho -n "Shutdown Oracle: "# 关闭oemsu - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"# 关闭数据库和listenersu - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"rm -f /var/lock/Oracleecho "OK";;reload|restart)$0 stop$0 start;;*)echo "Usage: `basename $0` start|stop|restart|reload"exit 1esacexit 0

修改所属组和用户
#chown oracle.oinstall /etc/rc.d/init.d/oradb
修改访问权限
#chmod 775 /etc/rc.d/init.d/oradb
添加服务到自动启动中
#chkconfig –add oradb
查看数据库服务开机启动状态
#chkconfig –list oradb

四、# chkconfig: 345 99 10说明
指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的级别,这里是345)目录下生成的链接文件的序号(启动优先级别)S99oradbstart,10为在除前面指出的级别对应的/etc/rc.d/rcN.d(N为除345之外的级别)目录生成的链接文件的序号(服务停止的优先级别)

0 0
原创粉丝点击