Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7115923
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: Oracle

2014-06-16 11:03:20





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





每次启动关闭,都要敲一大串的命令,特别在学习或者测试环境,敲多了难免感觉烦,因而就写了个servcie脚本,利用的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 - 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...

linux



[root@jsb-ylw-5024 ~]# service start
……………………………………输出省略………………………………………
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 15 09:20:55 2010

Copyright (c) 1982, 2009, Oracle. All rights reserved.

SQL> Connected to an idle instance.
SQL> ORACLE instance started.

Total System Global Area 1620115456 bytes
Fixed Size                  2213816 bytes
Variable Size            1040189512 bytes
Database Buffers          570425344 bytes
Redo Buffers                7286784 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


[root@jsb-ylw-5024 ~]# service oracle status
Oracle instance is running...

[root@jsb-ylw-5024 ~]# service oracle stop
……………………………………输出省略………………………………………
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 15 09:23:40 2010

Copyright (c) 1982, 2009, Oracle. All rights reserved.

SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options



阅读(448) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~