Home > Database > Mysql Tutorial > body text

CentOS 6.4下让Oracle开机启动

WBOY
Release: 2016-06-07 16:45:14
Original
837 people have browsed it

目标:在CentOS 6.4下让Oracle开机启动,方案:首先添加 启动,关闭,重启Oracle的服务和实例的服务;然后把这个服务添加到系统服

目标:在CentOS 6.4下让Oracle开机启动

方案:首先添加 启动,关闭,重启Oracle的服务和实例的服务;然后把这个服务添加到系统服务的运行级别。

设置CentOS下开机自动启动Oracle 

步骤:

1,新增service

执行命令:

# vi /etc/rc.d/init.d/oracle

Oracle文件的内容为:

#! /bin/bash
# chkconfig: 234 61 61
# description: Oracle 11g AutoRun Service
# /etc/rc.d/init.d/oracle
 
case "$1" in
    start)
        # starts oracle listener and instance
        echo "Starting Oracle Database:"
        su - oracle -lc "lsnrctl start"
        su - oracle -lc dbstartup
        ;;
    stop)
        # shutdown oracle listner and instance
        echo "Shuting down Oracle Database:"
        su - oracle -lc "lsnrctl stop"
        su - oracle -lc dbshutdown
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
    echo "Usage: {start|stop|reload|restart}"
    exit 1
esac
exit 0

注意:脚本中添加至少两行注释行(第3步中),,第一行告诉chkconfig该服务的运行级别;第二行添加关于服务的简要说明。

以上脚本中涉及到的两个脚本:dbstart和dbshut

2,编辑dbstartup和dbshutdown
执行命令
$ vi $ORACLE_HOME/bin/dbstartup
内容为:
#dbstartup
#/opt/oracle/102/bin
sqlplus / as sysdba startup
exit
EOF
vi$ORACLE_HOME/bin/dbshutdown
内容为:
#dbshutdown
#/home/oracle/102/bin
sqlplus / as sysdba shutdown immediate
exit
EOF

3,检查启动脚本是否正确

# cd /etc/rc.d/init.d
# ./oracle start
# ./oracle stop
 
4,把建立好的oracle服务添加到系统级别
执行如下命令:
# chmod 750 /etc/rc.d/init.d/oracle
# chkconfig --level 234 oracle on
# chkconfig --add oracle

本文永久更新链接地址:

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!