CentOS 5
Sponsored Link

自動起動設定2011/06/25

 
自動起動スクリプトを作成しておきます。
[1] 以下のファイルにSIDごとの起動設定が記述されているので、 N(=No)をY(=Yes)に変更します。
[root@db01 ~]#
vi /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.
#
#
db01:/usr/oracle/app/product/11.2.0/dbhome_1:Y   # 変更

[root@db01 ~]#
vi /usr/oracle/.bash_profile
# 最終行にSIDを追記

export ORACLE_SID=db01

[2] 起動スクリプトを作成してOracleを起動します。 (ここではシステムを一旦再起動し、Oracleが停止した状態を前提としています。)
[root@db01 ~]#
vi /etc/rc.d/init.d/oracle
# 一例ですのでご自由に改変ください。

#!/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

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

[root@db01 ~]#
/etc/rc.d/init.d/oracle start

Starting Oracle Database:
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-MAR-2011 22:40:02

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /usr/oracle/app/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /usr/oracle/app/diag/tnslsnr/db01/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01.srv.world)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db01.srv.world)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias     LISTENER
Version     TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date     30-MAR-2011 22:40:02
Uptime     0 days 0 hr. 0 min. 0 sec
Trace Level     off
Security     ON: Local OS Authentication
SNMP     OFF
Listener Parameter File     /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File     /usr/oracle/app/diag/tnslsnr/db01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01.srv.world)(PORT=1521)))
The listener supports no services
The command completed successfully
Processing Database instance "db01": log file /usr/oracle/app/product/11.2.0/dbhome_1/startup.log
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://db01.srv.world:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control .......... started.
------------------------------------
Logs are generated in directory /usr/oracle/app/product/11.2.0/dbhome_1/db01.srv.world_db01/sysman/log
[root@db01 ~]#
chkconfig --add oracle

[root@db01 ~]#
chkconfig oracle on
関連コンテンツ