您好,登錄后才能下訂單哦!
設置開機(Linux)自動啟動Oracle關機自動關閉Oracle
1、切換到root用戶下,確認啟動文件和關閉文件是存在
[oracle@oracle3 bin]$ pwd
/u01/oracle/product/10.2.0/db_1/bin
[oracle@oracle3 bin]$ ls dbstart
dbstart --sqlplus執行startup的時候調用的腳本
[oracle@oracle3 bin]$ ls dbshut
dbshut --sqlplus執行shutdown的時候調用的腳本
2、修改oratab文件
[oracle@oracle3 etc]$ vim /etc/oratab
ORCL:/u01/oracle/product/10.2.0/db_1:Y --將N改為Y
3、測試啟動文件和關閉文件的正確性
/u01/oracle/product/10.2.0/db_1/bin
[oracle@oracle3 bin]$ export ORACLE_SID=ORCL
[oracle@oracle3 bin]$ dbshut
[oracle@oracle3 bin]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 5 16:23:12 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance. --數據庫是關閉的
注意: conn /as sysdba = conn sys/orcl as sysdba
SQL> conn sys/orcl as sysdba
Connected to an idle instance. --連接到一個空閑的例程表示數據庫沒有啟動
SQL> conn sys/orcl@ORCL as sysdba
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Warning: You are no longer connected to ORACLE. --因為數據庫關閉了,是無法用監聽器訪問的,僅僅可以以sysdba的身份連接而已。
不管進行什么操作,都必須連接一下,用sysdba的身份登錄校驗操作系統的密碼文件。
[oracle@oracle3 bin]$ dbstart --測試啟動文件是可用的
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
Processing Database instance "ORCL": log file /u01/oracle/product/10.2.0/db_1/startup.log
[oracle@oracle3 bin]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 5 16:30:35 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected. --
4、編寫一段shell腳本
[root@oracle3 ~]# cd /etc/rc.d/init.d
[root@oracle3 init.d]# touch start_shut
[root@oracle3 init.d]# vi start_shut
----------------------------------------------
#!/bin/sh
OPT_=$1
case "$OPT_" in
start)
/bin/echo "$0 : (start)"
#
# your service startup command goes here
#
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/lsnrctl start"
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/dbstart"
# NOTE:Must exit with zero unless error is server
chmod 1777 /tmp
chown sys:sys /tmp
exit 0
;;
stop)
/bin/echo "$ : (stop)"
#
# your service shutdown command goes here.
#
su - oralce -c "/u01/oracle/product/10.2.0/db_1/bin/dbshut"
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/lsnrctl stop"
#Note: Must exit with zero unless error is server
exit 0
;;
*) /bin/echo ''
/bin/echo "Usage: $0[start|stop]"
/bin/echo "Invalid argument ==>\"${OPT_}\""
/bin/echo ''
exit 0
;;
esac
----------------------------------------------------------------------------------
5、修改權限
[root@oracle3 init.d]# chmod 755 start_shut
6、將文件鏈接到啟動區域和關閉區域
[root@oracle3 init.d]# cd /etc/rc5.d
[root@oracle3 rc5.d]# ln -s /etc/rc.d/init.d/start_shut S99start_shut
[root@oracle3 rc5.d]# cd /etc/rc0.d
[root@oracle3 rc0.d]# ln -s /etc/rc.d/init.d/start_shut K01start_shut
7、測試:
init 6
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。