---
title: "oracle随系统启动"
author: "phoenix007"
date: "2008-12-03T23:49:24Z"
tags: ["C", "C#", "C++", "Oracle", "脚本"]
slug: "oracle"
draft: false
lastmod: "2008-12-03T23:49:52Z"
id: 286307
url: "https://phoenix007.iteye.com/blog/286307"
---

from: http://space.itpub.net/15116811/viewspace-490562

1、编辑 /etc/oratab，把所有的 instance 的重启动标志设置成 'Y'，如:  
RHEL5:/u01/app/oracle/product/10.2.0/db\_1:Y  
2、做一个启动脚本 /etc/init.d/dbora ，如下所示:

#!/bin/sh  
\# description: Oracle auto start-stop script.  
\# chkconfig: - 20 80  
\#  
\# Set ORA\_HOME to be equivalent to the $ORACLE\_HOME  
\# from which you wish to execute dbstart and dbshut;  
\#  
\# Set ORA\_OWNER to the user id of the owner of the  
\# Oracle database in ORA\_HOME.  
ORA\_HOME=/u01/app/oracle/product/10.2.0/db\_1  
ORA\_OWNER=oracle  
if \[ ! -f $ORA\_HOME/bin/dbstart ]  
then  
echo "Oracle startup: cannot start"  
exit  
fi  
case "$1" in  
'start')

\# Start the Oracle databases:  
\# The following command assumes that the oracle login  
\# will not prompt the user for any values  
su - $ORA\_OWNER -c $ORA\_HOME/bin/dbstart  
su - $ORA\_OWNER -c "$ORA\_HOME/bin/lsnrctl start"  
;;  
'stop')  
\# Stop the Oracle databases:  
\# The following command assumes that the oracle login  
\# will not prompt the user for any values  
su - $ORA\_OWNER -c "$ORA\_HOME/bin/lsnrctl stop"  
su - $ORA\_OWNER -c $ORA\_HOME/bin/dbshut  
;;  
'restart')  
$0 stop  
$0 start  
;;  
esac

3、赋予执行权限  
chmod 750 /etc/init.d/dbora  
作成以下链接:  
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora  
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora  
执行以下命令:  
chkconfig --level 345 dbora on