Http://www.cnblogs.com/edwardcmh/archive/2012/05/11/2495671.html
Oracle 11g has to be started manually every time you install it | Stop Database (Dbstart | Dbshut), the Listener (LSNRCTL), the console (EMTCL).
Set up, if the listener does not start when the database is started manually (that is, start the listener automatically when the database is started, stop the listener when the database is stopped), you need to modify the Dbstart script file:
[Email protected] ~]$ Cd/u01/app/oracle/product/11.1.0/db_1/bin/[[email protected] ~]$ VI Dbstart
Locate the following code snippet:
# first argument is used to bring up Oracle Net listeneroracle_home_listner=$1 # # # need to modify the oracle_home_listner=$1 here to O racle_home_listner= $ORACLE _homeif [! $ORACLE _home_listner]; Then echo "Oracle_home_listner are not SET, unable to Auto-start ORACLE Net Listener" echo "Usage: $ oracle_home" E LSE log= $ORACLE _home_listner/listener.log
Similarly, modify the Dbshut:
[[Email protected] ~]$ VI dbshut# the this to bring down Oracle Net listeneroracle_home_listner=$1### need to be here Oracle_ho Me_listner=$1 modified to oracle_home_listner= $ORACLE _homeif [! $ORACLE _home_listner]; Then echo "Oracle_home_listner are not SET, unable to auto-stop ORACLE Net Listener" echo "Usage: $ oracle_home" El Se log= $ORACLE _home_listner/listener.log
After completing the configuration of the Linux startup script Oracle, the contents are as follows:
[[email protected] bin]$ Cd/etc/init.d/[[email protected] init.d]$ VI Oracle
#!/bin/sh# chkconfig:345 61# description:oracle 11g AutoRun services#/etc/init.d/oracle## run-level Startup script F Or the Oracle Instance, Listener, and# Web interfaceexport oracle_base=/u01/app/oracleexport oracle_home= $ORACLE _base/ Product/11.1.0/db_1export oracle_sid=orclexport path= $PATH: $ORACLE _home/binora_ownr= "ORACLE" # If the executables do Not exist--display Errorif [!-F $ORACLE _home/bin/dbstart-o!-d $ORACLE _home]then echo "ORACLE startup:cannot s Tart "Exit 1fi# depending on parameter-startup, shutdown, restart# of the instance and listener or usage Displaycas E "$" in start) # Oracle Listener and Instance startup su $ORA _OWNR-LC $ORACLE _home/bin/dbstart echo "Oracle Start succesful! Ok. ";; STOP) # Oracle Listener and instance shutdown su $ORA _ownr-lc $ORACLE _home/bin/dbshut echo "Oracle Stop SUCCE sful! Ok. ";; Reload|restart) $ stop $ start; *) echo $ "Usage: ' basename $ ' {start|stop|reload|reload}" Exit 1esacexit 0
Give the script executable permissions:
[Email protected] init.d]$ chmod 750/etc/init.d/oracle
To establish a link:
[Email protected] init.d]$ ln-s/etc/init.d/oracle/etc/rc1.d/k61oracle[[email protected] init.d]$ ln-s/etc/init.d/or Acle/etc/rc3.d/s61oracle
To enable the script and add to the service:
[[email protected] init.d]$ chkconfig--level 345 oracle On[[email protected] init.d]$ chkconfig--add Oracle
Attention:
Such scripts do not typically launch instances, and if you want the instance to start with the script, you need to modify the file/etc/oratab
If this file does not exist, run the script file to generate it.
[Email protected] init.d]# $ORACLE _home/root.sh
# This file was used by ORACLE utilities. It is created by root.sh# and updated by the Database Configuration Assistant when creating# a database.# a colon, ': ', is Used as the field terminator. A New Line terminates# the entry. Lines beginning with a pound sign, ' # ', is comments.## Entries is of the form:# $ORACLE _sid: $ORACLE _home:<n| y>:## the first and second fields is the system identifier and home# directory of the database respectively. The third filed indicates# to the Dbstart utility that the database should, "Y", or should not,# "N", being brought up at Sy Stem boot time.## multiple entries with the same $ORACLE _sid is not allowed.# #orcl:/u01/app/oracle/product/11.1.0/db_1:y
As can be seen, the instance ORCL is automatically started (identified as Y), as long as the configuration here, and then with the above script, you can start automatically.
Linux configuration Oracle 11g Auto-start