SHELL script to enable and disable Oracle

Source: Internet
Author: User

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.

  1. #! /Bin/bash
  2. Case "$1" in
  3. Start)
  4. Echo "Starting Oracle Listener and Database ....."
  5. Echo "--------------------------------------------">/var/log/oracle. log
  6. Echo "'date + % T % a % d': Starting Oracle Listener and Database...">/var/log/oracle. log
  7. Echo "-------------------------------------------">/var/log/oracle. log
  8. Su-oracle-c dbstart>/var/log/oracle. log
  9. Echo "Done"
  10. Echo ""
  11. Echo "--------------------------------------------">/var/log/oracle. log
  12. ;;
  13. Stop)
  14. Echo "stoping Oracle Listener and Database ....."
  15. Echo "--------------------------------------------">/var/log/oracle. log
  16. Echo "'date + % T % a % d': Stoping Oracle Listener and Database...">/var/log/oracle. log
  17. Echo "-------------------------------------------">/var/log/oracle. log
  18. Su-oracle-c dbshut>/var/log/oracle. log
  19. Echo "Done"
  20. Echo ""
  21. Echo "--------------------------------------------">/var/log/oracle. log
  22. ;;
  23. *)
  24. Echo "Usage: oracle {start | stop }"
  25. ;;
  26. 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.
  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.