centos5でのoracle 自動起動メモ

忘れそうなのでメモ
1) /etc/oratab
2) /etc/init.d/dbora スクリプト

[hirasawa@cent5-i386-oracle115 ~]$ 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:/opt/oracle/app/product/11.2.0/dbhome_1:Y
[hirasawa@cent5-i386-oracle115 ~]$ cat /etc/init.d/dbora 
#! /bin/bash
#
# dbora       Startup Script Oracle Database 11g
#
# chkconfig: 345 99 10
# description: Oracle Database 11g
# Source function library.
. /etc/rc.d/init.d/functions

# Oracle Database 11g
ORACLE_BASE=/opt/oracle/app
ORACLE_HOME=${ORACLE_BASE}/product/11.2.0/dbhome_1
ORACLE_OWNER=oracle
# Path
DB_START="${ORACLE_HOME}/bin/dbstart ${ORACLE_HOME}"
EM_START="${ORACLE_HOME}/bin/emctl start dbconsole"
DB_STOP="${ORACLE_HOME}/bin/dbshut ${ORACLE_HOME}"
EM_STOP="${ORACLE_HOME}/bin/emctl stop dbconsole"
prog=dbora
RETVAL=0
case "$1" in
   start)
      su - ${ORACLE_OWNER} -c "${DB_START}"
      su - ${ORACLE_OWNER} -c "${EM_START}"
      ;;
   stop)
      su - ${ORACLE_OWNER} -c "${EM_STOP}"
      su - ${ORACLE_OWNER} -c "${DB_STOP}"
      ;;
   restart|reload)
      $0 stop
      $0 start
      ;;
   *)
      echo $"Usage: ${prog} {start|stop|restart|reload}"
      exit 1
esac

exit $RETVAL
[hirasawa@cent5-i386-oracle115 ~]$ 

おこられたので、つぎのように追加してみる

[root@cent5-64b-40 init.d]# /etc/init.d/dbora start
Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name. 

[root@cent5-64b-40 init.d]# vi /etc/init.d/dbora 

[root@cent5-64b-40 init.d]# cat /etc/init.d/dbora | grep UNQNAME
ORACLE_UNQNAME=orcl
[root@cent5-64b-40 init.d]# 


つぎのようにユーザを追加する。

SQL> create user hirasawa
  2  identified by xxxxx
  3  default tablespace users
  4  temporary tablespace temp
  5  quota unlimited on users;

User created.



SQL> grant connect,resource to hirasawa;

Grant succeeded.


ユーザ追加できたらつぎのようにして確認してみる

[oracle@cent5-64b-40 ~]$ sqlplus hirasawa/xxxxxxxx@orcl

SQL*Plus: Release 11.2.0.1.0 Production on Thu Oct 6 20:59:25 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning and Real Application Testing options


SQL> select table_name from user_tables;

no rows selected

SQL> 

こちらの環境変数はわたしのこのみ

define_editor=vi
set echo off
set linesize 10000
set pagesize 0
set trimspool on
set feedback off
set colsep ','