AIX下Oracle数据库自动重启设置


一个关于Oracle数据库的有趣问题:

中远公司在没加磁盘阵列前建了一个oracle实例zycw,加磁盘阵列后新建了一个实例zync。

为了节省系统资源本打算平时只启实例yznc,需要时才启动zycw。可每次系统重启后系统会自动重启实例zycw,rc.d下没有找到任何自动重启数据库的脚本,ORACL_HOME/network/admin下也没有listener.ora文件(系统自启动时listener服务时是读取何处的参数文件还未搞清楚)。

后来才找到系统通过在inittab文件中加入一行startdb:2345678:wait:/etc/rc.startdb调用/etc/rc.startdb启动oracle的。下面详细介绍一下Oracle的这种自启动方式:

1、 编辑修改 /etc/oratab文件将要启动的实例后面的字符改成Y。 文本样例:
#
# 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.
##
*:/home/oracle:N
# *:/u2/oracle/product/9.2.0.2.0:N
zycw:/u2/oracle/product/9.2.0.2.0:N
*:/u2/oracle/product/9.2.0.2.0:N
zync:/u2/oracle/product/9.2.0.2.0:Y
#
2、 配置启动文件: 在/etc下建立文件rc.startdb,脚本如下:(这里是直接调用oracle系统自带的启动脚本,也可自己编写启动脚本)
su - oracle "-c /u2/oracle/product/9.2.0.2.0/bin/dbstart"
3、 下面要把启动信息放到/etc/inittab中,加入一行 startdb:2345678:wait:/etc/rc.startdb ,文本样例:
: @(#)49 1.28.2.9 src/bos/etc/inittab/inittab, cmdoper, bos520 8/23/00 19:50:13
: IBM_PROLOG_BEGIN_TAG
: This is an automatically generated prolog.
:
: bos520 src/bos/etc/inittab/inittab 1.28.2.9
:
: Licensed Materials - Property of IBM
:
: (C) COPYRIGHT International Business Machines Corp. 1989,1993
: All Rights Reserved
:
: US Government Users Restricted Rights - Use, duplication or
: disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
:
: IBM_PROLOG_END_TAG
:
: COMPONENT_NAME: CMDOPER
:
: ORIGINS: 3, 27
:
: (C) COPYRIGHT International Business Machines Corp. 1989, 1993
: All Rights Reserved
: Licensed Materials - Property of IBM
:
: US Government Users Restricted Rights - Use, duplication or
: disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
:
: Note - initdefault and sysinit should be the first and second entry.
:
init:2:initdefault:
brc::sysinit:/sbin/rc.boot 3 >/dev/console 2>&1 # Phase 3 of system boot
powerfail::powerfail:/etc/rc.powerfail 2>&1 | alog -tboot > /dev/console # Power Failure Detection
mkatmpvc:2:once:/usr/sbin/mkatmpvc >/dev/console 2>&1
atmsvcd:2:once:/usr/sbin/atmsvcd >/dev/console 2>&1
load64bit:2:wait:/etc/methods/cfg64 >/dev/console 2>&1 # Enable 64-bit execs
tunables:23456789:wait:/usr/sbin/tunrestore -R > /dev/console 2>&1 # Set tunables
rc:23456789:wait:/etc/rc 2>&1 | alog -tboot > /dev/console # Multi-User checks
fbcheck:23456789:wait:/usr/sbin/fbcheck 2>&1 | alog -tboot > /dev/console # run /etc/firstboot
srcmstr:23456789:respawn:/usr/sbin/srcmstr # System Resource Controller
rctcpip:23456789:wait:/etc/rc.tcpip > /dev/console 2>&1 # Start TCP/IP daemons
sniinst:2:wait:/var/adm/sni/sniprei > /dev/console 2>&1
rcnfs:23456789:wait:/etc/rc.nfs > /dev/console 2>&1 # Start NFS Daemons
cron:23456789:respawn:/usr/sbin/cron
piobe:2:wait:/usr/lib/lpd/pio/etc/pioinit >/dev/null 2>&1 # pb cleanup
qdaemon:23456789:wait:/usr/bin/startsrc -sqdaemon
writesrv:23456789:wait:/usr/bin/startsrc -swritesrv
uprintfd:23456789:respawn:/usr/sbin/uprintfd
shdaemon:2:off:/usr/sbin/shdaemon >/dev/console 2>&1 # High availability daemon
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
l7:7:wait:/etc/rc.d/rc 7
l8:8:wait:/etc/rc.d/rc 8
l9:9:wait:/etc/rc.d/rc 9
naudio::boot:/usr/sbin/naudio > /dev/null
logsymp:2:once:/usr/lib/ras/logsymptom # for system dumps
diagd:2:once:/usr/lpp/diagnostics/bin/diagd >/dev/console 2>&1
ctrmc:2:once:/usr/bin/startsrc -s ctrmc > /dev/console 2>&1
dt:2:wait:/etc/rc.dt
cons:0123456789:respawn:/usr/sbin/getty /dev/console
ha_star:h2:once:/etc/rc.ha_star >/dev/console 2>&1
ntbl_reset:2:once:/usr/bin/ntbl_reset_datafiles
rcml:2:once:/usr/sni/aix52/rc.ml > /dev/console 2>&1
tty0:2:off:/usr/sbin/getty /dev/tty0
tty1:2:off:/usr/sbin/getty /dev/tty1
tty2:2:off:/usr/sbin/getty /dev/tty2
startdb:2345678:wait:/etc/rc.startdb

AIX下oracle数据库重启设置的资料文档:
Automating Database Startup for AIX (Optional)

Oracle Corporation recommends that you configure your system to automatically
start Oracle databases when your system starts up, and to shut down Oracle
databases when your system shuts down. Automatic database startup and
shutdown protects against improper shutdown of the database.
Automating Database Startup
Perform the following tasks to set up the dbstart and dbshut scripts so that they
are called at system startup. This process must be completed for every new
database that you want to configure for automated startup:
1. Edit the /etc/oratab file.
Configuration Tasks to Perform as the root User
Database entries in the oratab file appears in the following format:
ORACLE_SID:ORACLE_HOME:{Y|N}
In the preceding command, Y or N specifies whether you want the dbstart
and dbshut scripts to start up and shut down the database.
For Oracle Real Application Clusters installation, this entry appears in the
following format:
DB_NAME:ORACLE_HOME:{Y|N}
In the preceding command, DB_NAME is the cluster database name. Y or N
specifies whether you want the dbstart and dbshut scripts to start up and
shut down the database.
2. For each database that you want to start up, find the ORACLE_SID entry
identified by the sid in the first field. Change the last field for each to Y.
3. Add the dbstart script to the /etc/inittab file:
# mkitab "oradb:2:wait:/bin/su oradb -c|/$ORACLE_HOMES/bin/dbstart"
In the preceding command, oradb is the identifier of the oracle user for
which you want to start the database.

相关内容