oracle linux 5 中随系统自动启动停止数据库oracle 11g R2的脚本

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE  11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> 

[root@ora11g init.d]# uname -r
2.6.32-200.13.1.el5uek
[root@ora11g init.d]# pwd
/etc/init.d
[root@ora11g init.d]# vim dbora

#!/bin/bash
#
#
#
# chkconfig: 35 99 01
# description: This script starts your Oracle databases

### BEGIN INIT INFO
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
### END INIT INFO

# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for you installation

ORACLE_USER=oracle
ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1

case $1 in
'start')
        echo "$0: starting up"
        echo "Starting Oracle databases"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
        ;;
'stop')
        echo "$0: shutting down"
        echo "stopping Oracle databases"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
        ;;
*)
        echo "usage: $0 {start|stop}" 
        exit
        ;;
esac
#
exit

[root@ora11g init.d]# chgrp dba dbora
[root@ora11g init.d]# chmod 750 dbora
[root@ora11g init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/K01dbora
[root@ora11g init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
[root@ora11g init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/K01dbora
[root@ora11g init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora


[root@ora11g init.d]# ls ../rc*.d/*db*
ls: ../rc*.d/*db*: No such file or directory
[root@ora11g init.d]# chkconfig --add dbora
[root@ora11g init.d]# ls ../rc*.d/*db*
../rc0.d/K01dbora  ../rc2.d/K01dbora  ../rc4.d/K01dbora  ../rc6.d/K01dbora
../rc1.d/K01dbora  ../rc3.d/S99dbora  ../rc5.d/S99dbora


[oracle@ora11g bin]$ /etc/init.d/dbora start
/etc/init.d/dbora: starting up
Starting Oracle databases
Processing Database instance "ora11g": log file /u01/oracle/product/11.2.0/dbhome_1/startup.log
[oracle@ora11g bin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-MAR-2012 23:02:47

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                26-MAR-2012 23:02:24
Uptime                    0 days 0 hr. 0 min. 22 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g.example.com)(PORT=1521)))
Services Summary...
Service "ora11g" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
Service "ora11g.service" has 1 instance(s).
  Instance "ora11g", status UNKNOWN, has 1 handler(s) for this service...
Service "ora11gXDB" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@ora11g bin]$ /etc/init.d/dbora stop
/etc/init.d/dbora: shutting down
stopping Oracle databases
Processing Database instance "ora11g": log file /u01/oracle/product/11.2.0/dbhome_1/shutdown.log
[oracle@ora11g bin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-MAR-2012 23:03:02

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g.example.com)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
[oracle@ora11g bin]$



REF:

Automating Database Startup and Shutdown on Other Operating Systems

http://docs.oracle.com/html/B10812_06/chapter2.htm#CHDBGJAC

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值