리눅스 환경에서 부팅시 오라클 자동실행

2017. 6. 27. 14:54DB/오라클

1. /etc/oratab 파일 수정.


[root@server1 bin]# cat /etc/oratab

#

# This file is used by ORACLE utilities.  It is created by root.sh

# and updated by the Database Configuration Assistant when creating

# a database.


# 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:/oracle/product/11g:Y                               ---> N을 Y로 변경



2. 스크립트 2개 생성 및 서비스 등록.

▶ /etc/init.d/oracle 생성.

#!/bin/bash

#
# oracle Init file for starting and stopping
# Oracle Database. Script is valid for 10g and 11g versions.
#
# chkconfig: 35 80 30
# description: Oracle Database startup script

# Source function library.

. /etc/rc.d/init.d/functions

ORACLE_OWNER="oracle"                                                     ---> 자신의 환경에 맞게 수정
ORACLE_HOME="/oracle/product/11g"                                    
---> 자신의 환경에 맞게 수정

case "$1" in
start)
echo -n $"Starting Oracle DB:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
echo "OK"
;;
stop)
echo -n $"Stopping Oracle DB:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
echo "OK"
;;
*)
echo $"Usage: $0 {start|stop}"
esac



▶ /etc/init.d/oraemctl 생성.


#!/bin/bash

#
# oraemctl Starting and stopping Oracle Enterprise Manager Database Control.
# Script is valid for 10g and 11g versions.
#
# chkconfig: 35 80 30
# description: Enterprise Manager DB Control startup script

# Source function library.

. /etc/rc.d/init.d/functions

ORACLE_OWNER="oracle"                                                     ---> 자신의 환경에 맞게 수정
ORACLE_HOME="/opt/oracle/111"
                                          ---> 자신의 환경에 맞게 수정

case "$1" in
start)
echo -n $"Starting Oracle EM DB Console:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
echo -n $"Stopping Oracle EM DB Console:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
;;
*)
echo $"Usage: $0 {start|stop}"
esac 


3. 생성한 스크립트 권한 변경.

 [root@server1 bin]# chmod 750 /etc/init.d/oracle

 [root@server1 bin]# chmod 750 /etc/init.d/oraemctl


4. 서비스 등록

 [root@server1 bin]# chkconfig --add oracle --level 345

 [root@server1 bin]# chkconfig --add oraemctl --level 345


5. 확인 

  - 재부팅하여 확인

'DB > 오라클' 카테고리의 다른 글

리눅스 오라클 11gR2 삭제  (0) 2017.06.05
[오라클] 기본 명령어 1  (1) 2016.06.22
오라클 11gR2 설치 가이드  (0) 2016.03.09