Linux下oracle自啟動設定的方法介紹

來源:互聯網
上載者:User


涉及的檔案有:
/etc/oratab
$ORACLE_HOME/bin下的兩個指令碼,dbstart和dbshut

編輯設定檔:

vim /etc/oratab

將:

orcl:/u01/oracle/product/10.2.0/db_1:N

改為:

orcl:/u01/oracle/product/10.2.0/db_1:Y

隨後最簡單的方法,在/etc/rc.local中加入:

su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/dbstart"
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/lsnrctl start"

在/var/log/boot.log裡可以看到兩個命令的執行結果。
在/u01/oracle/product/10.2.0/db_1/startup.log裡可以看到dbstart的執行日誌。

當然也可以做一個啟動指令碼,把指令碼加到系統服務中:

做一個啟動指令碼 /etc/init.d/oracle,如下所示:
#!/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=/oracle/product/10.2.0/
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/dbstart
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
;;
'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/lsnrctl stop"
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;
'restart')
$0 stop
$0 start
;;
esac

賦予執行許可權
chmod 750 /etc/init.d/oracle
作成以下連結:
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
執行以下命令:
chkconfig --level 345 oracle on


11xe版自啟動方法。

oracle 11xe版沒有提供啟動指令碼,大概是因為精簡的原因,只能自己寫了:

vim /home/oracle.sh

加入:

#!/bin/bash
su - oracle -c "
sqlplus / as sysdba <<EOF
startup;
exit;
EOF
"

設定許可權:

chmod 755 /home/oracle.sh

設定啟動:

vim /etc/rc.local

加入:

/home/oracle.sh

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.