linux7(centos7)设置oracle11开机自启动

在linux7下安装了oracle,每次重启之后都要重新启动数据库很麻烦,所以设置为开机自启动。

1、修改oracle自启动配置文件oratab,修改N为Y,允许oracle数据库在系统启动时启动

1

[root@test-1 ~]# vi /etc/oratab

 如下所示,将最后一行的N修改为Y 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

# 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:/syn/oracle/product/11.2.0:Y

2、修改oracle的dbstart文件

将ORACLE_HOME_LISTNER=$1
修改为ORACLE_HOME_LISTNER=$ORACLE_HOME

1

[root@test-1 bin]# vi /syn/oracle/product/11.2.0/bin/dbstart

  如下所示:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

# usage: dbstart $ORACLE_HOME

#

# whose third field is a "Y".  If the third field is set to "Y" and

# there is no ORACLE_SID for an entry (the first field is a *),

# then this script will ignore that entry.

#

# This script requires that ASM ORACLE_SID's start with a +, and

# that non-ASM instance ORACLE_SID's do not start with a +.

#

# If ASM instances are to be started with this script, it cannot

# be used inside an rc*.d directory, and should be invoked from

# rc.local only. Otherwise, the CSS service may not be available

# yet, and this script will block init from completing the boot

# cycle.

#

# If you want dbstart to auto-start a single-instance database that uses

# an ASM server that is auto-started by CRS (this is the default behavior

# for an ASM cluster), you must change the database's ORATAB entry to use

# a third field of "W" and the ASM's ORATAB entry to use a third field of "N".

# These values specify that dbstart auto-starts the database only after

# the ASM instance is up and running.

#

# Note:

# Use ORACLE_TRACE=T for tracing this script.

#

# The progress log for each instance bringup plus Error and Warning message[s]

# are logged in file $ORACLE_HOME/startup.log. The error messages related to

# instance bringup are also logged to syslog (system log module).

# The Listener log is located at $ORACLE_HOME_LISTNER/listener.log

#

# On all UNIX platforms except SOLARIS

# ORATAB=/etc/oratab

#

# To configure, update ORATAB with Instances that need to be started up

#    Entries are of the form:

#    $ORACLE_SID:$ORACLE_HOME:<N|Y|W>:

#    An example entry:

#    main:/usr/lib/oracle/emagent_10g:Y

#

# Overall algorithm:

# 1) Bring up all ASM instances with 'Y' entry in status field in oratab entry

# 2) Bring up all Database instances with 'Y' entry in status field in

#    oratab entry

# 3) If there are Database instances with 'W' entry in status field

#      wait for all of them to be started

#    fi

# 4) Bring up all Database instances with 'W' entry in status field in

#    oratab entry

#

#####################################

 

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

if [ ! $ORACLE_HOME_LISTNER ] ; then

 

3、将dbstart加入开机自启动,修改/etc/rc.d/rc.local文件

1

[root@test-1 ~]# vi /etc/rc.d/rc.local

  在最后添加 su - oracle -lc /syn/oracle/product/11.2.0/bin/dbstart,并保存。(按oracle实际路径填写)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

 

touch /var/lock/subsys/local

 

su - oracle -lc /syn/oracle/product/11.2.0/bin/dbstart

4、给/etc/rc.d/rd.local文件添加可执行权限(centos7中为了安全默认取消了该文件的可执行权限)

1

[root@xydykt-1 ~]# chmod u+x /etc/rc.d/rc.local

5、重启服务器后,oracle数据库及监听均已成功启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值