文章目錄
- 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