Oracle 开机自启动启动
1 背景知识
本文主要介绍如何配置 Oracle 开机启动。
2 dbstart
文件配置
#oracle>
vi $ORACLE_HOME/bin/dbstart
#oracle>
ORACLE_HOME_LISTNER=/u01/app/oracle/product/11.2.0/db_1
3 /etc/oratab
文件配置
dbca
建库时都会自动创建/etc/oratab文件,将 N
修改为 Y
。
vi /etc/oratab
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
4 /etc/rc.d/rc.local
配置
编辑 /etc/rc.d/rc.local
启动文件,并添加监听启动命令和 dbstart
启动脚本。
#root>
vi /etc/rc.d/rc.local
#!/bin/bash
# 2. THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# 3. It is highly advisable to create own systemd services or udev rules
# 4. to run scripts during boot instead of using this file.
#
# 5. In contrast to previous versions due to parallel execution during boot
# 6. this script will NOT be run after all other services.
#
# 7. Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# 8. that this script will be executed during boot.
touch /var/lock/subsys/local
su - oracle -lc "/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"
su - oracle -lc /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
向 rc.local
文件中添加可执行权限。
#root>
chmod +x /etc/rc.local
5 验证
重启主机,查看数据库和监听是自启动, 查看数据库是否处于open状态
sqlplus / as sysdba
select status from v$instance