自动启动ORACLE Script Service

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博客 ” ,链接:http://blog.itpub.net/29065182/viewspace-1629523/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29065182/viewspace-1629523/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值