CentOS7.6设置Oracle12cRelease2开机启动

简介

本文介绍如何在CentOS7.6上设置Oracle Database 12c Release 2开机启动

软件版本备注
本地操作系统Win10ip:192.168.1.1
虚拟机操作系统CentOS Linux release 7.6.1810 (Core)ip:192.168.1.14
内存2.8G
swap 2G
OracleOracle Database 12c Release 2linux版本

开机启动

root账号登入虚拟机

编辑oratab文件
vim /etc/oratab

修改最后一位位Y
修改前截图在这里插入图片描述
修改后截图
在这里插入图片描述

创建dbora文件

	[root@localhost ~]# vim /etc/init.d/dbora

内容如下:

#! /bin/sh
# 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 ORACLE_HOME.

ORA_HOME=/home/oracle/app/oracle/product/12.2.0/dbhome_1/
ORA_OWNER=oracle

case "$1" in
'start') 
    # Start the Oracle databases:
    # The following command assumes that the oracle login
    # will not prompt the user for any values
    # Remove "&" if you don't want startup as a background process.
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
    touch /var/lock/subsys/dbora
    ;;

'stop')
    # Stop the Oracle databases:
    # The following command assumes that the oracle login
    # will not prompt the user for any values
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" &
    rm -f /var/lock/subsys/dbora
    ;;
esac

修改执行权限

# 将所有者文件改为oracle用户
chown oracle /etc/init.d/dbora
# oracle账号和root组具备执行权限
chmod 750 /etc/init.d/dbora

开机启动

ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora

手动启停

  1. 编辑oratab文件
    参照开机启动配置

  2. 启动脚本

dbstart $ORACLE_HOME
dbshut $ORACLE_HOME
  1. 简便方式
# 使用别名的方式
vim .bashrc
# 添加以下内容,注意不要使用dbstart,dbshut
alias startdb='dbstart $ORACLE_HOME'
alias shutdb='dbshut $ORACLE_HOME'
# 使别名生效
source .bashrc

参考

官方管理文档: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/unxar/stopping-and-starting-oracle-software.html#GUID-A4864665-F68E-4C53-8411-606CF2DED443

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值