设置oracle10g在liunx下随机启动

1. 编辑/etc/oratab文件,将对应的sid那一行的N改为Y.
oratab格式: $ORACLE_SID:$ORACLE_HOME:<N|Y>
修改后的例子: orcl:/u01/app/oracle/10.2.0/db_1:Y

2. 在/etc/init.d/下建立一个文件oracle10g,用来调用oracle自带的启动和关闭脚本(dbstart dbshut).文件内容如下:
[root@db1 root]# more /etc/init.d/dbora10g
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.


ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=orauser

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
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
#
case $1 in
'start')
        $ORACLE_HOME/bin/dbstart $ORACLE_HOME
        ;;
'stop')
        $ORACLE_HOME/bin/dbshut $ORACLE_HOME
        ;;
*)
        echo "usage: $0 {start|stop}"
        exit
        ;;
esac
#
exit


3. 将oracle10g设置为可执行文件并测试
chmod ug+x dbora10g
dbora10g stop

4. 建立符号连接
ln -s /etc/init.d/dbora10g /etc/rc.d/rc5.d/K01dbora10g
ln -s /etc/init.d/dbora10g /etc/rc.d/rc5.d/S99dbora10g

ln -s /etc/init.d/dbora10g /etc/rc.d/rc3.d/K01dbora10g
ln -s /etc/init.d/dbora10g /etc/rc.d/rc3.d/S99dbora10g

5. 添加到linux的服务
chkconfig --add dbora10g
chkconfig --list dbora10g
chkconfig --level 35 dbora10g on 

 

6. 重新启动,测试oracle是否已随机启动
reboot


其它问题:
1.启动oracle所需的环境变量ORACLE_BASE ORACLE_HOME ORACLE_SID已经加入到oracle用户的主目录(/home/oracle)下的.bash_profile文件里了.
2.启动dbconsole的时候可能会遇到错误Failed to shutdown DBConsole Gracefully,解决方法是编辑/etc/hosts文件,将127.0.0.1和localhost对应起来.例如加入下面一行:127.0.0.1 machinename localhost.

你可能感兴趣的:(设置oracle10g在liunx下随机启动)