BlueXIII's Blog

热爱技术,持续学习

0%

CentOS7下Oracle11g自启配置

编辑init.d脚本

vi /etc/init.d/dbora

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
#! /bin/sh -x
#
# chkconfig: 2345 80 05
# description: start and stop Oracle Database Enterprise Edition on Oracle Linux 5 and 6
#

# In /etc/oratab, change the autostart field from N to Y for any
# databases that you want autostarted.
#
# Create this file as /etc/init.d/dbora and execute:
# chmod 750 /etc/init.d/dbora
# chkconfig --add dbora
# chkconfig dbora on

# Note: Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
# ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
ORACLE_HOME=/app/oracle/product/11.2.0

#
# Note: Change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH

case $1 in
'start')
echo -n $"Starting Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
'stop')
echo -n $"Shutting down Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
;;
'restart')
echo -n $"Shutting down Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
sleep 5
echo -n $"Starting Oracle: "
su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
*)
echo "usage: $0 {start|stop|restart}"
exit
;;
esac

exit

赋权及加入自启

1
2
3
chmod 750 /etc/init.d/dbora
sudo chkconfig --add oracledb
chkconfig dbora on

编辑oratab

vi /etc/oratab

1
orcl:/app/oracle/product/11.2.0:Y

N改为Y

服务启停

1
2
service dbora start
service dbora stop