日期:2014-05-16  浏览次数:20379 次

Ubuntu9.10下关于oracle自启动的配置方法

#cp /etc/oratab /etc/oratab.bak.0? 备份
#vim /etc/oratab

ORCL:/opt/oracle/product/10.2.0/db_1:Y
主要是黑体的部分

配置/etc/init.d/oracle-10g启动脚本
#touch /etc/init.d/oracle-10g
#vim /etc/init.d/oracle-10g
内容如下:

#!/bin/bash
# chkconfig: 345 99 10
# description: Startup Script for Oracle Databases
# /etc/rc.d/init.d/dbstart

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=ORCL
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oinstall"
# 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 -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/Oracle
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl start"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl stop"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
rm -f /var/lock/Oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0

保存退出。

设置权限,放到启动脚本中去
#chmod 755 /etc/init.d/oracledb
#update-rc.d oracledb defaults 99


注意:要把里面的对应目录和SID修改成你自己对应的配置。

添加自启动
#chkconfig --add oracle-10g

#chkconfig --edit oracle-1g
内容如下
oracle-10g on


<