要让oracle随linux启动而启动,需要设置以下五个地方:
1、修改/etc/oratab
# 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.
#
orcl11g:/u01/app/oracle/product/11.2.0/db_1:Y
2、修改dbstart
/u01/app/oracle/product/11.2.0/db_1/bin/dbstart
将
# ORACLE_HOME_LISTNER=$1
改为
ORACLE_HOME_LISTNER=$ORACLE_HOME
3、修改dbshut
/u01/app/oracle/product/11.2.0/db_1/bin/dbshut
将
# ORACLE_HOME_LISTNER=$1
改为
ORACLE_HOME_LISTNER=$ORACLE_HOME4、创建/etc/init.d/oradb
#!/bin/bash # chkconfig: 2345 90 10 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=orcl11gexport PATH=$PATH:$ORACLE_HOME/bin ORCL_OWN="oracle" # if the executables do not exist -- display error if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] then echo "Oracle startup: cannot start" exit 1 fi # depending on parameter -- start, stop, restart # of the instance and listener or usage display case "$1" in start) # Oracle listener and instance startup echo -n "Starting Oracle: " su - $ORCL_OWN -c "$ORACLE_HOME/bin/dbstart" touch /var/lock/subsys/oradb # su - $ORCL_OWN -c "$ORACLE_HOME/bin/emctl start dbconsole" echo "OK" ;; stop) # Oracle listener and instance shutdown echo -n "Shutdown Oracle: " # su - $ORCL_OWN -c "$ORACLE_HOME/bin/emctl stop dbconsole" su - $ORCL_OWN -c "$ORACLE_HOME/bin/dbshut" rm -f /var/lock/subsys/oradb echo "OK" ;; reload|restart) $0 stop $0 start ;; *) echo "Usage: 'basename $0' start|stop|restart|reload" exit 1 esac exit 0
需要修改的有:
a.ORACLE_BASE
b.ORACLE_SID
c.ORCL_OWN
5、授权+加入服务
chmod 755 /etc/rc.d/init.d/oradb
chkconfig --add oradb