Oracle entry-level service script management starts, closes, and restarts

Source: Internet
Author: User
Every time you start and shut down Oracle, you have to knock a bunch of commands. Especially in the learning or testing environment, it is annoying to knock too much, so I wrote a servcie script to use the redhat s

Every time you start and shut down Oracle, you have to knock a bunch of commands. Especially in the learning or testing environment, it is annoying to knock too much, so I wrote a servcie script to use the redhat s

Every time you start and shut down Oracle, you have to think about a bunch of commands. Especially in the learning or testing environment, it is hard to get bored when you knock too much, so you have written a servcie script, use the RedHat service command to start, close, and restart the Oracle database, and enable or disable em and lsnrctl. The shell script and test result are attached below.

[Root @ jsb-ylw-5024 ~] # Cat/etc/init. d/oracle
#! /Bin/sh
# Chkconfig: 35 85 15
# Description: oracle
# Function: start... stop and restart the oracle instance on 11g R2 64bit
# Author: lw. yang
# Version: V.1.0

ORACLE_PID = 'ps-ef | grep ora | grep-E 'smon | pmon | ckpt' | wc-l'
Export ORACLE_BASE =/u01
Export ORACLE_HOME =/u01/oracle
Export ORACLE_SID = yang
Export PATH = $ ORACLE_HOME:/bin: $ PATH

# Source function library.
./Etc/rc. d/init. d/functions

Start (){
Su-oracle < Emctl start dbconsole
Lsnrctl start
Sqlplus/nolog < Conn/as sysdba
Startup
Exit
EOD
Exit
EOF
}

Stop (){
Su-oracle < Emctl stop dbconsole
Lsnrctl stop
Sqlplus/nolog < Conn/as sysdba
Shutdown immediate
Exit
EOD
Exit
EOF
}

Case "$1" in
Start)
Start
Touch/var/lock/subsys/oracle
;;

Stop)
Stop
;;

Status)
If ["$ ORACLE_PID" = "3"]; then
Echo "Oracle instance is running ..."
Else echo "Oracle instance is not running ..."
Fi
;;

Restart)
Stop
Start
;;


*)
Echo $ "Usage: $0 {start | stop | restart | status }"
Exit 1

Esac


[Root @ jsb-ylw-5024 ~] # Chmod + x/etc/init. d/oracle
[Root @ jsb-ylw-5024 ~] # Chkconfig -- add oracle
[Root @ jsb-ylw-5024 ~] # Service oracle status
Oracle instance is not running...

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.