oracle11g在linux中自動執行

1.確認/etc/oratab檔案,如下圖:


2.在/home/oracle下增加scripts的目錄(#mkdir scripts),用VI增加2個檔案
3.# su – oracle
4. #vi /home/oracle/scripts/ora_start.sh

#!/bin/bash

# script to start the Oracle database, listener and dbconsole


. ~/.bash_profile


# start the listener and the database

$ORACLE_HOME/bin/dbstart $ORACLE_HOME


# start the Enterprise Manager db console

$ORACLE_HOME/bin/emctl start dbconsole


exit 0

5.#vi /home/oracle/scripts/ora_stop.sh

#!/bin/bash


# script to stop the Oracle database, listener and dbconsole


. ~/.bash_profile


# stop the Enterprise Manager db console

$ORACLE_HOME/bin/emctl stop dbconsole


# stop the listener and the database

$ORACLE_HOME/bin/dbshut $ORACLE_HOME


exit 0


6.#chmod u+x ora_start.sh ora_stop.sh
7.用root權限進入\etc\init.d
8.增加檔案 # vi /etc/init.d/oracle

#!/bin/bash

# chkconfig: 345 99 10

# description: Oracle auto start-stop script.


# Set ORA_OWNER to the user id of the owner of the

# Oracle database in ORA_HOME.


ORA_OWNER=oracle

RETVAL=0


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 "/home/oracle/scripts/ora_start.sh"

        touch /var/lock/subsys/oracle

        ;;

    '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 "/home/oracle/scripts/ora_stop.sh"

        rm -f /var/lock/subsys/oracle

        ;;

    *)

        echo $"Usage: $0 {start|stop}"

        RETVAL=1

esac

exit $RETVAL

9. 增加權限#chmod 750 /etc/init.d/oracle


10. 增加service #chkconfig --add oracle
11.測試service是否可成功stop
       #service oracle stop
12.測試service是否可成功start
   #service oracle start

如果在測試時出現"拒絕權限不符的操作"訊息時,建議把檔的權限改成777,例如:chmod 777 /etc/init.d/oracle
其他檔案也比照處理.

安裝完ORACLE,要由別台電腦連入LINUX主機的資料庫,記得把FIREWALL的"1521"PORT打開.



留言

這個網誌中的熱門文章

java 數字轉字串 字串轉數字

MS sqlServer資料庫移轉至MySQL-->利用MySQL WorkBench

sql server 15023 error [SQL SERVER問題: 使用者、組或角色 '*****' 在當前資料庫中已存在]