There are many methods to enable and disable Oracle by using SHELL scripts. In this example, we compile a simple script to call the three scripts that come with Oracle10g. Now let's start by simply editing the three scripts that come with Oracle. the directories of these three scripts are located in: /etc/oratab $ ORACLE_HOME/bin/dbstart $ ORACLE_HOME/bin/dbshut vi/etc/oratabqdyx:/opt/app/oracle/product/10/db: Y + ASM: /opt/app/oracle/product/10/db: Y sets the startup domain to "Y". The advantage is that when multiple instances exist in the system, we can perform operations selectively. Vi $ ORACLE_HOME/bin/dbstartORACLE_HOME_LISTNER = $ ORACLE_HOME find "ORACLE_HOME_LISTNER" and change his value to "$ ORACLE_HOME" vi $ ORACLE_HOME/bin/dbshut and add a line before the end of the file: by default, lsnrctl stopdbshut only closes the database set as "Y" in/etc/oratab, and does not close the listener. The preparation is complete. edit a simple script to call oratab, dbstart, and dbshut.
- #! /Bin/bash
- Case "$1" in
- Start)
- Echo "Starting Oracle Listener and Database ....."
- Echo "--------------------------------------------">/var/log/oracle. log
- Echo "'date + % T % a % d': Starting Oracle Listener and Database...">/var/log/oracle. log
- Echo "-------------------------------------------">/var/log/oracle. log
- Su-oracle-c dbstart>/var/log/oracle. log
- Echo "Done"
- Echo ""
- Echo "--------------------------------------------">/var/log/oracle. log
- ;;
- Stop)
- Echo "stoping Oracle Listener and Database ....."
- Echo "--------------------------------------------">/var/log/oracle. log
- Echo "'date + % T % a % d': Stoping Oracle Listener and Database...">/var/log/oracle. log
- Echo "-------------------------------------------">/var/log/oracle. log
- Su-oracle-c dbshut>/var/log/oracle. log
- Echo "Done"
- Echo ""
- Echo "--------------------------------------------">/var/log/oracle. log
- ;;
- *)
- Echo "Usage: oracle {start | stop }"
- ;;
- Esac
Name the above script oralce in the/etc/init. d/directory and add executable permissions. Run the script to test whether the database is opened or closed. It's almost over now. Please be patient !!! Next, we need to enable the Linux system to execute this script during startup and shutdown. The first step is to execute this script at startup. I run it under startup level 5 and create a soft link: ln-s/etc/rc. d/init. d/oracle/etc/rc. d/rc5.d/S99oracle if your system runs at startup Level 3, you can change rc5.d to rc3.d. What does S99Oracle mean, S indicates that a start parameter will be passed to the script at system startup, and 99 indicates that the script will be executed at last. If you are interested, you can go to this directory and check it out.