oracle linux 5 中隨系統自動啟動停止資料庫oracle 11g R2的指令碼

來源:互聯網
上載者:User
文章目錄
  • Automating Database Startup and Shutdown on Other Operating Systems

SQL> select * from v$version;</p><p>BANNER<br />--------------------------------------------------------------------------------<br />Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production<br />PL/SQL Release 11.2.0.1.0 - Production<br />CORE 11.2.0.1.0 Production<br />TNS for Linux: Version 11.2.0.1.0 - Production<br />NLSRTL Version 11.2.0.1.0 - Production</p><p>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<br />#<br />#<br />#<br /># chkconfig: 35 99 01<br /># description: This script starts your Oracle databases</p><p>### BEGIN INIT INFO<br /># Default-Start: 3 5<br /># Default-Stop: 0 1 2 4 6<br />### END INIT INFO</p><p># Change the value of ORACLE_HOME to specify the correct Oracle home<br /># directory for you installation</p><p>ORACLE_USER=oracle<br />ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1</p><p>case $1 in<br />'start')<br />        echo "$0: starting up"<br />        echo "Starting Oracle databases"<br />        su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"<br />        ;;<br />'stop')<br />        echo "$0: shutting down"<br />        echo "stopping Oracle databases"<br />        su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"<br />        ;;<br />*)<br />        echo "usage: $0 {start|stop}"<br />        exit<br />        ;;<br />esac<br />#<br />exit<br />

[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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.