怎样在linux上配置oracle 11g 数据库开机自启动

如题所述

root用户登陆
编辑/etc/init.d/oracle文件,输入以下内容(修改自己的ORACLE_BASE)
#!/bin/bash
# For RedHat and cousins:
# chkconfig: 2345 40 40
# description:
# processname:
# For SuSE and cousins
### BEGIN INIT INFO
# Provides: probe
# Required-Start: $syslog $remote_fs
# Should-Start: sendmail
# Required-Stop: $syslog $remote_fs
# Should-Stop: sendmail
# Default-Start: 2 3 5
# Default-Stop:
# Short-Description:
# Description:
# X-UnitedLinux-Default-Enabled: yes
### END INIT INFO
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/oracle
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_USER=oracle
export ORACLE_SID=dbbha
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
EOO
touch /var/lock/subsys/$scriptname
;;
stop)
su - "$ORACLE_USER"<<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
EOO
rm -f /var/lock/subsys/scriptname
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac

设置oracle文件属性:
linux-udly:~ # chown root.root /etc/init.d/oracle
linux-udly:~ # chmod 755 /etc/init.d/oracle
linux-udly:~ #

配置oracle服务
linux-udly:~ # service oracle start (启动oracle服务)
linux-udly:~ # chkconfig oracle on (配置该服务系统重启后有效)
温馨提示:答案为网友推荐,仅供参考
相似回答