Oracle 11gR2 create init script

  1. 设置oracle用户变量。
    [oracle@db01 ~]$ vi /etc/oratab
    # end line: change
    db01:/oracle/app/product/11.2.0/db_1:Y
    [oracle@db01 ~]$ vi ~/.bash_profile
    # add follows to the end
    export ORACLE_SID=db01
    
  2. 以root身份创建init文件。
    [root@db01 ~]# vi /etc/rc.d/init.d/oracle
    # it's an example, edit it you like.
    #!/bin/bash
    
    # oracle: Start/Stop Oracle Database 11g R2
    #
    # chkconfig: 345 90 10
    # description: The Oracle Database is an Object-Relational Database Management System.
    #
    # processname: oracle
    
    . /etc/rc.d/init.d/functions
    
    LOCKFILE=/var/lock/subsys/oracle
    ORACLE_HOME=/oracle/app/product/11.2.0/db_1
    ORACLE_USER=oracle
    
    case "$1" in
    'start')
        if [ -f $LOCKFILE ]; then
            echo $0 already running.
            exit 1
        fi
        echo -n $"Starting Oracle Database:"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
        touch $LOCKFILE
        ;;
    'stop')
        if [ ! -f $LOCKFILE ]; then
            echo $0 already stopping.
            exit 1
        fi
        echo -n $"Stopping Oracle Database:"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
        su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
        rm -f $LOCKFILE
        ;;
    'restart')
        $0 stop
        $0 start
        ;;
    'status')
        if [ -f $LOCKFILE ]; then
            echo $0 started.
        else
            echo $0 stopped.
        fi
        ;;
    *)
        echo "Usage: $0 [start|stop|status]"
        exit 1
    esac
    
    exit 0
    
    [root@db01 ~]# chmod 755 /etc/rc.d/init.d/oracle
    [root@db01 ~]# chkconfig --add oracle
    [root@db01 ~]# chkconfig oracle on

转载于:https://www.cnblogs.com/MagicLetters/p/4382879.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值