ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 自动启动ORACLE Script Service

自动启动ORACLE Script Service

原创 Linux操作系统 作者:muxinqing 时间:2015-05-08 12:47:08 0 删除 编辑
All just to do better
一切只为了做的更好



SCRIPT NAME:oracle

#!/bin/bash
# chkconfig: 345 99 10
# description: script for the Oracle Instance, Listener
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/app/oracle/product/11.2.0/db_1
ORA_OWNER=oracle
oracle_run=$(ps -ef|grep ora_dbw0_oracle11|grep -v grep|wc -l)
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
#echo  "Starting Oracle Listeners: "
echo  -n "Starting Oracle Database ....."
su - oracle -c "$ORA_HOME/bin/lsnrctl start" >> /var/log/oracle.log
echo -n  "....."
sleep 1
echo "....."
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"  >> /var/log/oracle.log  && echo  "(Succeed)" || echo  "(Failure)"
date +"! %T %a %D : Finished." >> /var/log/oracle
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
#echo -n "Stoping Oracle Listeners: "
echo -n  "Stoping Oracle Database ....."
su - oracle -c "$ORA_HOME/bin/lsnrctl stop" >> /var/log/oracle.log
echo -n  "....."
sleep 1
echo "....."
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >> /var/log/oracle.log  && echo  "(Succeed)" || echo  "(Failure)"
date +"! %T %a %D : Finished." >> /var/log/oracle
;;
'restart')

echo  -n "Starting Oracle Database ....."
$0 stop >> /var/log/oracle.log  && echo  "(Succeed)" || echo  "(Failure)"


echo -n  "Stoping Oracle Database ....."
$0 start >> /var/log/oracle.log  && echo  "(Succeed)" || echo  "(Failure)"
;;
'status')
 if [ $oracle_run -eq 1 ]
oracle_status=$(su - $ORA_OWNER -c "$ORA_HOME/bin/sqlplus -silent / as sysdba" << mxq
set pagesize 0 feedback off verify off heading off echo off numwidth 4
select 'ORACLE STATUS: '||decode(status,'OPEN',' open runing','MOUNTED','oracle is mount runing','STARTED','oracle is nomount runing','oracle is stoping'),'ROLE: '||instance_role from v\$instance;
exit
mxq
)
echo $oracle_status
else
echo "oracle is stoping"
 fi
;;
esac




2、文件修改成Y
etc/init.d/oracle
crds3db:/app/oracle/product/11.2.0/db_1:Y
3、添加服务
chkconfig --add oracle  #添加服务
chkconfig --level 345 oracle on  #345级别都激活服务
chkconfig --list oracle #查看服务
--chkconfig --del oracle  #删除服务

4、启动服务
添加服务服务后,不会立即启动服务,如果需要立即启动服务,需要执行
service oracle start #启动服务
service oracle stop #停止服务
service oracle restart #重启服务

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29065182/viewspace-1629523/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-01-14

  • 博文量
    143
  • 访问量
    1248172