天天看点

centos7 oracle 开机自启动

oracle 开机自启动

[[email protected] ~]# su - oracle
Last login: Tue Mar  1 14:45:37 CST 2022 on tty1
[[email protected] ~]$ cd $ORACLE_HOME
[[email protected] 11.2.0]$ pwd
/data/app/oracle/product/11.2.0
[[email protected] bin]$ dbstart 
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: ./dbstart ORACLE_HOME
#说明目前不能通过dbstart脚本知己启动Oracle
[[email protected] bin]$ vi dbstart 
#编辑 dbstart,将ORACLE_HOME_LISTNER=$1修改成 ORACLE_HOME_LISTNER=$ORACLE_HOME 前提是$ORACLE_HOME环境设置正确,或者直接写绝对路径
[[email protected] bin]$ vi /etc/oratab 
#asp:/data/app/oracle/product/11.2.0:N 改为 asp:/data/app/oracle/product/11.2.0:Y
#最后的Y作用:是否允许dbstart来启动数据库
[[email protected] ~]# vi /etc/rc.d/rc.local 
#在rc.local文件后添加开机启动oracle脚本
su oracle -lc "/data/app/oracle/product/11.2.0/bin/lsnrctl start"
su oracle -lc /data/app/oracle/product/11.2.0/bin/dbstart
           

注意事项

重启后发现oracle并未启动,原因分析

[[email protected] ~]# ll /etc/rc.d/rc.local 
-rwxr-xr-x 1 root root 597 Mar  1 14:52 /etc/rc.d/rc.local
#默认该文件是没有执行权限的,如果没有执行权限则 chmod +x rc.local