我做的是在AIX启动oracle的脚本,不知道linux下是否可用,不过你可以试试。首先创建一个启动的脚本startdb.sh
echo "begin to start oracle" 
lsnrctl start 
sqlplus /nolog <<EOF 
connect /as sysdba 
startup 
exit 
echo "oracle have been started"
然后使用如下命令进行调用
su - oracle "-c startdb.sh" 同样,停止时也可以先创建一个stopdb.sh的脚本,但要注意关闭时关闭数据库与关闭监听的顺序和启动时的正好相反
echo "begin to shutdown oracle" 
sqlplus /nolog <<EOF 
connect /as sysdba 
shutdown immediate
exit 
lsnrctl stop 
echo "oracle have been shutdown"
然后使用如下命令进行调用
su - oracle "-c stopdb.sh" 

解决方案 »

  1.   

    我上网抄了一个脚本并改成参数
    /etc/init.d/dbora
    #!/bin/sh
    # description: Oracle auto start-stop script.
    # chkconfig: - 20 80
    #
    # Set ORA_HOME to be equivalent to the $ORACLE_HOME
    # from which you wish to execute dbstart and dbshut;
    #
    # Set ORA_OWNER to the user id of the owner of the 
    # Oracle database in ORA_HOME.
    ORA_HOME=/home/oracle/product/10.2.0/db_1
    ORA_OWNER=oracle
    if [ ! -f $ORA_HOME/bin/dbstart ]
    then
        echo "Oracle startup: cannot start"
        exit
    fi
    case "$1" in
        'start')
            # Start the Oracle databases:
            # The following command assumes that the oracle login 
            # will not prompt the user for any values
            su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
            su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
            ;;
        'stop')
            # Stop the Oracle databases:
            # The following command assumes that the oracle login 
            # will not prompt the user for any values
            su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
            su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
            ;;
    esac
    Use chmod to set the privileges to 750:chmod 750 /etc/init.d/dbora
    Link the file into the appropriate run-level script directories:ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
    ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora在linux已经启动的情况下,我用S99dbora start能够启动oracle服务现我重新启动linux到dbora服务时,就死在那里
    经过查看/var/log/messages日志
    发现dbora那一行显示:
    dbora:do you want to choose a different one?[N]请教一下,这个如何查找原因,我自己深得应该不是脚本有问题。
    我看linux服务启动的时候后面都有[确定],而我的日志显示是N,
    难道是这个引起的? 
      

  2.   

    我自己发现问题了,在Fedora4下按照我的语法能够正常启动但是到RHEL4下就显示dbora:do you want to choose a different one?[N]
    这个错误了,真是奇怪,难道是需要license?