linux 开机自启动 oracle

思路 /etc/rc.d/rc.local 中修改,添加oracle 启动命令【虚拟机中存在部分不生效的问题】

1、/etc/rc.d/下,创建 start_oracle.sh 文件 修改权限700

#!/bin/bash

###LOGING
LOG=/home/oracle/oracle_start_log/`date "+%Y%m%d-%H%M%S"`_log_z.txt  ## 日志存放地址

###Start listener
lsnrctl status  >> $LOG 2>&1
nolis_num=`grep -i "no listener" $LOG |wc -l`
if [ $nolis_num -ne 0 ];then
  lsnrctl start  >> $LOG 2>&1
fi

###database status
sqlplus / as sysdba >> $LOG 2>&1 << eeooff
 select status from v\$instance;
 exit
eeooff

###if database not open then database start
db_status=`grep -A 3 STATUS $LOG |grep "OPEN" |wc -l`
if [ $db_status -ne 1 ];then
sqlplus / as sysdba >> $LOG 2>&1 << eeooff
 startup force;
 exit
eeooff
fi

2、/etc/rc.d/rc.local添加命令

su - oracle -lc "/bin/bash /home/oracle/start_oracle.sh"

一下是第二种方法

1、修改文件 /etc/oratab 注意文件需要有执行权限

orcl:/data/app/oracle/product/12.2.0/dbhome_1:Y

实例名:安装路径:Y(自动启动的意思)

2、修改文件 /etc/rc.d/rc.local  注意文件需要有执行权限

su oracle -lc "/data/app/oracle/product/12.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc "/data/app/oracle/product/12.2.0/dbhome_1/bin/dbstart"
 

补充:https://www.cnblogs.com/standcloud/articles/2712901.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山人在山上

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值