>데이터 베이스 >MySQL 튜토리얼 >Oracle 入门之service脚本管理启动,关闭,重启

Oracle 入门之service脚本管理启动,关闭,重启

WBOY
WBOY원래의
2016-06-07 16:58:02984검색

每次启动关闭Oracle,都要敲一大串的命令,特别在学习或者测试环境,敲多了难免感觉烦,因而就写了个servcie脚本,利用redhat的s

每次启动关闭Oracle,都要敲一大串的命令,特别在学习或者测试环境,敲多了难免感觉烦,因而就写了个servcie脚本,利用RedHat的service命令简单的启动,,关闭,重启Oracle数据库,同时开启或者关闭em和lsnrctl,下面附上shell脚本和测试结果

[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 - oracleemctl start dbconsole
lsnrctl start
sqlplus /nologconn /as sysdba
startup
exit
EOD
exit
EOF
}

stop() {
su - oracleemctl stop dbconsole
lsnrctl stop
sqlplus /nologconn /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...

linux

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.