oracle服务开机启动,Linux下建立Oracle服务及其开机自启动

操作环境:CentOS 6.7 + Oracle 11gR2

手工启动Oracle实例:

启动数据库:

sqlplus / as sysdba

startup

手动启动监听:

lsnrctl start

Oracle在$ORACLE_HOME/bin下提供了对数据库进行操作的脚本:

$ORACLE_HOME=/opt/oracle/app/product/11.2.0/dbhome_1

启动数据库实例(含监听):

/opt/oracle/app/product/11.2.0/dbhome_1/bin/dbstart /opt/oracle/app/product/11.2.0/dbhome_1

关闭数据库实例(含监听):

/opt/oracle/app/product/11.2.0/dbhome_1/bin/dbshut /opt/oracle/app/product/11.2.0/dbhome_1

oralce用户创建: vi /etc/oratabvi /etc/oratab

orcl:/opt/oracle/app/product/11.2.0/dbhome_1:Y

启动脚本:vi /etc/init.d/oracle#!/bin/sh

#chkconfig: 2345 20 80

#description: Oracle dbstart / dbshut

#以上两行为chkconfig所需

ORA_HOME=/opt/oracle/app/product/11.2.0/dbhome_1

ORA_OWNER=oracle

LOGFILE=/opt/oracle/app/logs/oracle.log

echo "#################################" >> ${LOGFILE}

date +"### %T %a %D: Run Oracle" >> ${LOGFILE}

if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then

echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}

echo "#################################" >> ${LOGFILE}

exit

fi

start(){

echo "###Startup Database..."

su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"

echo "###Done."

echo "###Run database control..."

su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"

echo "###Done."

}

stop(){

echo "###Stop database control..."

su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"

echo "###Done."

echo "###Shutdown Database..."

su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"

echo "###Done."

}

case "$1" in

'start')

start >> ${LOGFILE}

;;

'stop')

stop >> ${LOGFILE}

;;

'restart')

stop >> ${LOGFILE}

start >> ${LOGFILE}

;;

esac

date +"### %T %a %D: Finished." >> ${LOGFILE}

echo "#################################" >> ${LOGFILE}

echo ""

将/etc/init.d/oracle置为可执行文件:

chmod a+x /etc/init.d/oracle

启动oracle(包括数据库实例、监听器、EM)

/etc/init.d/oracle start

关闭oracle

/etc/init.d/oracle stop

重启oracle

/etc/init.d/oracle restart

建立链接:

ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle

ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle

将 oracle 添加到 chkconfig中:

chkconfig --add oracle

修改oracle服务的开机启动级别:

chkconfig --level 35 oracle on

启动Oracle:

service oracle start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值