CentOS 6下 Oracle11gR2 設置開機自啟動


[1] 更改/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:/usr/oracle/app/product/11.2.0/dbhome_1:Y

[2] oracle用戶profile文件中增加SID環境變量

[root@oracledb oracle]#  vi /usr/oracle/.bash_profile

# 在文件末尾添加

export ORACLE_SID=orcl

[3] 創建啟動Oracle的Init腳本

   [root@oracledb oracle]# vi /etc/rc.d/init.d/oracle

# this is an example
#!/bin/bash

# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle

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

LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/usr/oracle/app/product/11.2.0/dbhome_1
ORACLE_USER=oracle

case "$1" in
'start')
   if [ -f $LOCKFILE ]; then
      echo $0 already running.
      exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $LOCKFILE
   ;;
'stop')
   if [ ! -f $LOCKFILE ]; then
      echo $0 already stopping.
      exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $LOCKFILE
   ;;
'restart')
   $0 stop
   $0 start
   ;;
'status')
   if [ -f $LOCKFILE ]; then
      echo $0 started.
      else
      echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac

exit 0

[4] 更改啟動腳本權限

[root@oracledb oracle]#  chmod 755 /etc/rc.d/init.d/oracle

[5] 啟動oracle數據庫

[root@oracledb oracle]# service oracle start

[6] 關閉oracle數據庫

[root@oracledb oracle]# service oracle stop

[7] 設置oracle為開機自啟動

[root@oracledb oracle]# chkconfig oracle on
[root@oracledb oracle]# chkconfig --list oracle
oracle             0:關閉    1:關閉    2:啟用    3:啟用    4:啟用    5:啟用    6:關閉
[root@oracledb oracle]#

[8]重啟電腦測試

原文地址:

CentOS Oracle11gR2 設置開機自啟動


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM