思路 /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"



