1. Modify the Oracle system configuration file etcoratabetcoratab in the format of SID: ORACLE_HOME: AUTO to set the AUTO domain to Y (uppercase). Only in this way can dbstar
1. Modify the Oracle configuration file/etc/oratab in the format of SID: ORACLE_HOME: AUTO to set the AUTO domain to Y (uppercase ).
1. Modify the Oracle system configuration file/etc/oratab
/Etc/oratab format: SID: ORACLE_HOME: AUTO
Set the AUTO domain to Y (uppercase). Only in this way can dbstart and dbshut of oracle be used. Mine is:
Ora9i:/home/oracle/ora/products/9.2.0: Y
2. Compile a service script:
As follows:
#! /Bin/bash
#
################# FUNCTION #############
#
# AutoStart Oracle and listener
# AutoStop Oracle and listener
#
#####################################
#
# Created by ZhouYS 2003-11-26
#
Case "$1" in
Start)
Echo "Starting Oracle Databases ..."
Echo "-----------------------------------------------">/var/log/oracle
Date "% T % a % D: Starting Oracle Databasee as part of system up.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-oracle-c "dbstart">/var/log/oracle
Echo "Done ."
Echo "Starting Oracle Listeners ..."
Echo "-----------------------------------------------">/var/log/oracle
Date "% T % a % D: Starting Oracle Listeners as part of system up.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-oracle-c "lsnrctl start">/var/log/oracle
Echo "Done ."
Echo ""
Echo "-----------------------------------------------">/var/log/oracle
Date "% T % a % D: Finished.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Touch/var/lock/subsys/oracle
;;
Stop)
Echo "Stoping Oracle Listeners ..."
Echo "-----------------------------------------------">/var/log/oracle
Date "% T % a % D: Stoping Oracle Listener as part of system down.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-oracle-c "lsnrctl stop">/var/log/oracle
Echo "Done ."
Rm-f/var/lock/subsys/oracle
Echo "Stoping Oracle Databases ..."
Echo "-----------------------------------------------">/var/log/oracle
Date "% T % a % D: Stoping Oracle Databases as part of system down.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-oracle-c "dbshut">/var/log/oracle
Echo "Done ."
Echo ""
Echo "-----------------------------------------------">/var/log/oracle
Date "% T % a % D: Finished.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
;;
Restart)
$0 stop
$0 start
;;
*)
Echo "Usage: oracle {start | stop | restart }"
Exit 1
Esac
Name the script oracle and save it under/etc/rc. d/init. d.
Change file attributes: chmod 755 oracle
Note: In windows, the file cannot run normally due to DOS characters when editing this file. You are advised to use gedit or vi to edit it.
3. Establish a service connection:
When the system starts the database, we need the following link:
--------------------------------------------------------------------------------
$ Ln-s ../init. d/oracle/etc/rc. d/rc2.d/S99oracle
$ Ln-s ../init. d/oracle/etc/rc. d/rc3.d/S99oracle
$ Ln-s ../init. d/oracle/etc/rc. d/rc5.d/S99oracle # rc4.d unused
--------------------------------------------------------------------------------
To stop the database at restart, we need the following link:
--------------------------------------------------------------------------------
$ Ln-s ../init. d/oracle/etc/rc. d/rc0.d/K01oracle # Stop
$ Ln-s ../init. d/oracle/etc/rc. d/rc6.d/K01oracle # restart