Oracle开机自启动

时间:2022-05-22 15:05:52

linux下启动oracle

su - oracle #用oracle用户登陆
sqlplus /nolog
conn /as sysdba
startup
exit
lsnrctl start
exit

linux下关闭oracle

su - oracle #用oracle用户登陆
sqlplus /nolog
conn /as sysdba
shutdown immediate
exit
lsnrctl stop
exit

oracle加入开机启动

1.编辑: vi /etc/oratab,把最后一行的N改为Y

# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance. # A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
#orcl:/u01/app/oracle:N
orcl:/u01/app/oracle:Y #这里把"N"改为"Y"

2.修改 /etc/rc.local,在最后添加两句

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff. touch /var/lock/subsys/local # 添加下面两条
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'