天天看点

linux as4单实例Oracle系统启动/关闭脚本

<b>单实例</b><b>Oracle</b><b>系统启动</b><b>/</b><b>关闭脚本</b>

1.         关于脚本的命名

脚本名称:oracle.sh 部署目录:/etc/rc.d/init.d 服务列表:redhat服务 操作用户:root

启动oracle命令:/etc/init.d/oracle start   关闭oracle命令:/etc/init.d/oracle stop

                service oracle start                         service oracle stop

2.         脚本内容

#!/bin/bash

#

# chkconfig: 2345 99 01

# de.ion: init . to start/stop oracle database 10g, TNS listener, EMS

# match these values to your environment:

export ORACLE_BASE=/opt/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_TERM=xterm

export PATH=$ORACLE_HOME/bin:$PATH:/usr/sbin:$HOME/bin

#export NLS_LANG='croatian_croatia.ee8iso8859p2'

export ORACLE_SID=oraDBServer1

export DISPLAY=localhost:0

export ORACLE_USER=oracle

# see how we are called:

case $1 in

        start)

        su - "$ORACLE_USER"&lt;&lt;EOO

        lsnrctl start

        sqlplus /nolog&lt;&lt;EOS

        connect / as sysdba

        startup

EOS

        emctl start dbconsole

EOO

        ;;

        stop)

        lsnrctl stop

        shutdown immediate

        emctl stop dbconsole

        *)

        echo "Usage: $0 {start|stop}"

esac

注意:

1)        其中两行注释,网上很多脚本因为少了这两行不能使服务自启动:

QUOTE:

#chkconfig: 2345 99 01

#de.ion: init . to start/stop oracle database 10g, TNS listener, EMS

其中chkconfig:2345 99 01 是指脚本将为运行级2、3、4、5启动oracle 10g服务,启动优先级为99,关闭优先级为01。

3.         脚本的权限和服务添加操作

1)        使用root用户登录,把文件copy到/etc/rc.d/init.d/目录下

2)        赋予执行权限

[root@localhost ~]#cd /etc/init.d

[root@localhost init.d]#chown oracle oracle

[root@localhost init.d]#chmod 755 oracle   

3)        建立符号链接

[root@localhost ~]# cd /etc/rc2.d

[root@localhost rc2.d]#ln -s /etc/rc.d/init.d/oracle S99oracle

[root@localhost init.d]# chkconfig --list oracle

[root@localhost init.d]# chkconfig --level 2345 oracle .

重启系统,就可以在启动的过程中看到 Starting oracle,因为我们设置的优先级为99,一般是最后启动。[OK]以后就可以了。因为要启动emctl,可能有点慢,等待的时间要稍微长一点。

注意:要修改/etc/oratab文件

     orcl:/opt/app/oracle/product/10.2.0/db_1:N (将N该为Y)

本文转自 pgmia 51CTO博客,原文链接:

http://blog.51cto.com/heyiyi/127440

继续阅读