Linux中在Oracle安装完毕以后,如果重新启动Linux ,Oracle是不会自动启动的,你可以通过手动调用dbstart命令来进行启动,不过这样似乎也很繁琐.我们可以通过配置Oracle的自动启动脚本,然后利用Linux的Service来启动Oracle服务器.
首先在/etc/init.d/目录下配置Oracle的服务文件.
1.touch oracle10g
2.chmod a+x oracle10g
然后编辑此oracle10g文件.内容如下.
[root@oracle10g ~]# more /etc/init.d/oracle10g
# !/bin/bash
# whoami
# root
# chkconfig: 345 51 49
# /etc/init.d/oracle10g
# description: starts the oracle dabase deamons
#
ORA_HOME=/oracle/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
case "$1" in
start)
echo -n "Starting oracle10g: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" &
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
touch /var/lock/subsys/oracle10g
echo
;;
stop)
echo -n "shutting down oracle10g: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" &
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
rm -f /var/lock/subsys/oracle10g
echo
;;
restart)
echo -n "restarting oracle10g: "
$0 stop
$0 start
echo
;;
*)
echo "Usage: `basename $0` start|stop|restart"
exit 1
esac
exit 0
[root@oracle10g ~]#cp oracle10g /etc/init.d/