利用Linux服务自动启动Oracle

来源:互联网 发布:东莞淘宝培训 编辑:程序博客网 时间:2024/06/06 06:54

利用Linux服务自动启动Oracle
1.修改/etc/oratab
编辑/etc/oratab文件,将orcl:/opt/oracle/product/10.2.0/db_1:N改为orcl:/opt/oracle/product/10.2.0/db_1:Y
2.添加Linux服务
cd /etc/rc.d/init.d
touch oracle
chmod a+x oracle
打开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

执行下列命令添加到Linux服务中:
chkconfig --add oracle
chkconfig --list oracle

重新启动服务器。

原创粉丝点击