suse linux oracle自動啓動

1.修改/etc/oratab文件,後面的dbstart和dbshut依據這個文件啓動數據庫

soadb:/u01/oracle/product/11.2.0/dbhome_1:Y

2.創建數據庫初始化文件:

#cp $ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora.* $ORACLE_HOME/dbs/init$ORACLE_SID.ora

cp /u01/oracle/admin/soadb/pfile/init.ora.116201214406 /u01/oracle/product/11.2.0/dbhome_1/dbs/initsoadb.ora

3.接下來在/etc/init.d下建立系統自動啓動和關機前自動關閉Oracle的腳本文件,分別如下:

vi start_oracle.sh(開機後啓動oracle數據庫腳本):

#!/bin/bash

#this script is used to start the oracle

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/dbstart"

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"

chmod a+x /etc/init.d/start_oracle.sh

vi stop_oracle.sh(關機前停止oracle數據庫腳本):

#!/bin/bash

#this script is used to stop the oracle

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/lsnrctl stop"

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/dbshut"

chmod a+x /etc/init.d/stop_oracle.sh

4.創建隨系統啓動和關閉的鏈接:

在/etc/rc2.d下加入自動啓動鏈接,命令如下:

ln -s /etc/init.d/start_oracle.sh  /etc/rc.d/rc2.d/S16start_oracle

ln -s /etc/init.d/start_oracle.sh  /etc/rc.d/rc3.d/S16start_oracle

ln -s /etc/init.d/start_oracle.sh  /etc/rc.d/rc5.d/S16start_oracle

在/etc/rc0.d下加入自動關閉鏈接,命令如下:

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc2.d/K01stop_oracle

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc3.d/K01stop_oracle

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc5.d/K01stop_oracle

接着cp這兩個鏈接在/etc/rc.d/rcN.d(N=3,5)下各一份

設置完畢,可以重啓看看效果了。

linux:~ # reboot

test@linux:~> ps -ef | grep ora

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章