본문 바로가기

DB/Oracle

부팅시 oracle 자동실행 하기


부팅시 oracle 자동실행 하기

두가시 세팅법이 있다

첫번째는 /etc/rc.local에 등록을 하여 바로 실행하는 방법과
두번째는 스크립트를 통해 서비스 등록을 하는 방법이다.


1. rc.local 에 추가하기.

먼저 /etc/oratab 에

orcl:/home/oracle/11gR2:N

이런식으로 되어 있다.
맨 끝의 N을  Y로 변경한다.

orcl:/home/oracle/11gR2:Y

그리고 vim /etc/rc.local 에 다음을 추가한다.

su  - oracle -c  /home/oracle/11gR2/bin/dbstart

su  - oracle -c  /home/oracle/11gR2/bin/'lsnrctl start'

su  - oracle -c  /home/oracle/11gR2/bin/'emctl start dbconsole'

경로는 오라클 홈에 있는 bin파일들을 실행하는 것이다.

2. 스크립트 추가하기.

두가지 스크립트가 있는데 oracle 과 oraemctl 이다.

스크립트는 다음과 같으며 서비스에 등록을한다.

===============================================================================

vim /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="/opt/oracle/111"

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

====================================================================================

vim /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 

==================================================================================

이렇게 스크립트 파일을 생성하고

chmod 750 /etc/init.d/oracle
chkconfig --add oracle --level 0356 

chmod 750 /etc/init.d/oraemctl
chkconfig --add oraemctl --level 0356 

파일 권한변경과 서비스 등록을 한다.

이렇게 하면 부팅시 자동으로 서비스가 올라간다.






참조 사이트:
http://ivan.kartik.sk/oracle/install_ora11gR1_elinux.html

http://www.oracle.com/technology/tech/php/htdocs/inst_php_apache_linux.html
http://ivan.kartik.sk/oracle/

'DB > Oracle' 카테고리의 다른 글

DEGREE의 의미 및 결정  (0) 2016.02.04
오라클 HINT  (0) 2016.02.04
SHARED POOL SIZE의 계산  (0) 2016.02.04
ORA-23515: materialized views and/or their indices exist in the tablespace  (0) 2016.02.04
oracle trace 파일 삭제 스크립트  (0) 2016.02.04