Oracle启动脚本,开机自启动设置

#!/bin/sh
# chkconfig: 35 80 10
# description: Oracle auto start-stop script.

#
# 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=/oracle/11.2.0
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi
case "$1" in
‘start‘)
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"

# Start the Listener:
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;

‘stop‘)
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;

‘stop‘)
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle

# Stop the Oracle Database:
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;

‘restart‘)
$0 stop
$0 start
;;
esac

将以上内容添加到/etc/init.d/oracle中并添加可执行权限,chkconfig --add oracle添加到服务启动列表,chkconfig oracle on设置成开机启动

时间: 2024-10-29 19:11:07

Oracle启动脚本,开机自启动设置的相关文章

mac设置shell脚本开机自启动

最近需要做分布式架构的网站,目前一直在调试阶段,每次开机的时候都要启动一大堆工具,比如zookeeper.activemq.redis.nginx等等,不厌其烦. 在网上搜了下mac如何设置shell脚本开机自启动,记录一下,方便自己也方便大家. 1.首先写一个sh脚本,比如: 1 cd ~/Documents 2 mkdir haha 代码很简单,进入Documents文件夹,建立haha目录,保存为run.sh 2.修改run.sh权限 sudo chmod 777 run.sh 3.右键点

linux下数据库实例开机自启动设置

linux下数据库实例开机自启动设置 1.修改/oratab [[email protected] ~]# vi/etc/oratab     --把N改为Y,如下提示 # This file is used by ORACLEutilities.  It is created by root.sh # and updated by the Database ConfigurationAssistant when creating # a database. # A colon, ':', is

linux下数据库实例监听开机自启动设置

linux下数据库实例监听开机自启动设置 2016/5/16 zhanky 脚本介绍 在开始之前,我们先介绍一下几个会用到的脚本. oratab oratab文件是在创建数据库实例时建立的,在安装时使用root用户执行root.sh脚本后得到.(如果忘记也可以直接手动创建.) 在$ORACLE_HOME/bin目录下的$ORACLE_HOME/bin/dbstart和$ORACLE_HOME/bin/dbshut需要调用/etc/oratab文件,如果不存在,dbstart和dbshut将失败,

ARM-Linux开机自启动设置-ok6410开发板

hdu 1163 Eddy's digital Roots Problem Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two

nginx启动脚本编写及设置开机自启动

环境:Centos 6.8 如果机器是Centos 7的,此脚本和设置开机自启动方法不适用. 首先确保nginx配置文件中:有pid目录 pid        logs/nginx.pid; 1.1 编写nginx启动脚本 [[email protected] ~]# cd /server/scripts [[email protected] scripts]# vim nginx.sh  #!/bin/bash [ -f /etc/init.d/functions ] && . /etc

Linux下oracle开机自启动设置

今天在虚拟机安装完oracle数据库重启系统后想进入数据库却发现如下错误: 出现ORA-01034和ORA-27101的原因是多方面的:主要是oracle当前的服务不可用,shared memory realm does not exist,是因为oracle没有启动或没有正常启动.那么如何在Linux启动时自动启动Oracle监听和实例呢? 首先尝试使用oracle启动数据库的命令dbstart,可是发现又报错如下错误: ORACLE_HOME_LISTNER is not SET, unab

安卓设置脚本开机自启动

手机想要开机自启一个脚本,百度之 Android默认的启动脚本有init.rc init.xxx.rc init.xxx.sh 因为init.rc是属于内存文件系统中的文件,每次开机从ram中释放加载进内存,意味着修改替换重启后还是之前的那个,所以无法通过直接修改来init.rc来启动此.sh脚本. 而将x.sh脚本放在/system/etc/init.d下,重启后发现没有自动运行.然后想到将脚本语句写在init.xxx.sh中,因为太长所以在我选择在install-recovery.sh末加入

Centos7如何设置脚本开机自启动?

1. 在需要设置为开机启动的脚本中加入必须的chkconfig启动脚本规范,如下: #!/bin/bash # chkconfig: 2345 80 12 # description: auto start shell script 2. 使用chkconfig将脚本加入自动启动列表 # mv your.sh /etc/rc.d/init.d # chkconfig /etc/rc.d/init.d/your.sh 原文地址:https://www.cnblogs.com/dakewei/p/1

配置Oracle数据库的开机自启动

每当数据库服务器重启后,都要重新启动数据库的监听和实例,特别是在服务器断电重启.例行维护性的场景下.能否像Windows服务器一样,让实例和监听随着服务的启动而启动呢?答案当然是肯定的,我们可以利用Oracle提供的dbstart文件设置Oracle数据库开机自启动.设置方法如下: (1).首先确保已经配置好ORACLE_HOME等环境变量,类似于如下内容: vi .bash_profile ORACLE_BASE=/u01/app/oracle ORACLE_HOME=$ORACLE_BASE

oracle11g在linux系统下开机自启动设置

oracle服务器一般来说最好是手动启动,这样碰到问题的话,可以现场解决,但是也担心有时候机器故障,自动重启后,为了快速恢复应用,需要自动开机启动oracle,而且发现在不同的os下,启动的设置都不太一样 1,centos操作系统下,可以这样设置 直接在rc.local里面添加 [[email protected] ~]# vim /etc/rc.local touch /var/lock/subsys/local su - oracle < lsnrctl start sqlplus / as