linux服务器下oracle开机自启动设置

1、首先切换到oracle用户

[oracle@oracletest ~]$ cd /u01/app/oracle/product/11.2.0/db_1/bin/       —–标红字体部分数据库可能不一样,有的是dbhome_1,以自己实际配置目录为准

[oracle@oracletest bin]$ vi dbstart 

logmsg="logger -puser.alert -s "

trap 'exit' 1 2 3

# for script tracing
case $oracle_trace in
  t) set -x ;;
esac

# set path if path not set (if called from /etc/rc)
save_path=/bin:/usr/bin:/etc:${path} ; export path
save_llp=$ld_library_path

# first argument is used to bring up oracle net listener
oracle_home_listner=$oracle_home     ############此处原来是$1,改成$oracle_home
if [ ! $oracle_home_listner ] ; then
  echo "oracle_home_listner is not set, unable to auto-start oracle net listener"
  echo "usage: $0 oracle_home"
else
  log=$oracle_home_listner/listener.log

2、用root用户编辑oratab和rc.local

[root@oracletest ~]# vi /etc/oratab

# 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.
#
#
oadb:/u01/app/oracle/product/11.2.0/db_1:y  ###此处原来是n,改为y

 

[root@oracletest ~]# vi /etc/rc.d/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
#####在空白处添加下面两行,其中标红字体部分数据库可能不一样,有的是dbhome_1,以自己实际配置目录为准
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  

经过上面两步操作,数据库服务器重启后,数据库也会自动启动。

以上均为实际操作示例,最终参考如下链接,致谢

https://blog.csdn.net/kepa520/article/details/78968180

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐