Oracle 10 在 Linux 下设置系统启动时自动启动

编辑/etc/oratab文件,将orcl:/opt/oracle/product/10.2.0/db_1:N改为orcl:/opt/oracle/product/10.2.0/db_1:Y


/etc/rc.d/init.d目录下配置oracle服务文件,执行下列命令:


touch oracle //创建文件


chmod a+x oracle //设置可执行权限


添加以下内容:


#!/bin/bash


#description:starts the oracle database deamons



ORA_HOME="/opt/oracle/product/10.2.0/db_1"


ORA_OWNER="oracle"



case $1 in


'start')


echo -n "***Starting Oracle***"


su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"


su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"


;;



'stop')


echo -n "***Stopping Oracle***"


su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"


su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"


;;



'restart')


echo -n "***Restarting Oracle***"


$0 stop


$0 start


;;



'isqlstart')


echo "***Starting Oracle iSQL PLus***"


su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl start"


echo "*** Note:You can access service at url:http://$(hostname):5560/isqlplus"


;;



'isqlstop')


echo "***Stopping Oracle iSQL Plus***"


su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl stop"


;;



'emstart')


echo "***Starting Oracle Enterprise Manager 10g Database control***"


su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"


echo "Note:You can access service as url:http://$(hostname):1158/em"


;;



'emstop')


echo "***Stopping Oracle Enterprise Manager 10g Database control***"


su - $ORA_OWNER -c "ORA_HOME/bin/emctl stop dbconsole"


;;



'*')


echo "Usage:$0 {start|stop|isqlstart|isqlstop|emstart|emstop}"


exit 1



esac


exit 0



执行下列命令测试:


/etc/rc.d/init.d/oracle start


/etc/rc.d/init.d/oracle stop


测试成功后,执行下列命令添加到系统服务中:


chkconfig –add oracle


chkconfig –list oracle


重新启动服务器。


请使用浏览器的分享功能分享到微信等