Linux/Centos 6.5 oracle11g 添加系统服务自启动脚本

1.#vim /etc/init.d/oracle     //内容如下

#!/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=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_USER=oracle
export ORACLE_SID=orcl
# see how we are called:
case $1 in
    start)
    su - "$ORACLE_USER"<     lsnrctl start
    sqlplus /nolog<     connect / as sysdba
    startup
EOS
    emctl start dbconsole
EOO
touch /var/lock/subsys/$scriptname
    ;;
    stop)
su - "$ORACLE_USER"<     lsnrctl stop
    sqlplus /nolog<     connect / as sysdba
    shutdown immediate
EOS
    emctl stop dbconsole
EOO
rm -f /var/lock/subsys/scriptname
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    ;;
esac

2.保存退出后执行下面命令

#chown root.root /etc/init.d/oracle

#chmod 755 /etc/init.d/oracle

#chkconfig --add oracle

3.启动:service oracle start 停止:service oracle  stop

4.配置开机自启动

#chkconfig oracle on

#vim /etc/rc.local

添加以下语句:

service oracle start

Linux/Centos 6.5 oracle11g 添加系统服务自启动脚本_第1张图片

5、reboot,测试oracle是否可以正常启动.

 

你可能感兴趣的:(数据库)