oracle的環境配置-設定開機(Linux)自動啟動Oracle關機自動關閉Oracle

來源:互聯網
上載者:User

標籤:oracle


設定開機(Linux)自動啟動Oracle關機自動關閉Oracle

1、切換到root使用者下,確認開機檔案和關閉檔案是存在
[[email protected] bin]$ pwd
/u01/oracle/product/10.2.0/db_1/bin
[[email protected] bin]$ ls dbstart
dbstart                              --sqlplus執行startup的時候調用的指令碼
[[email protected] bin]$ ls dbshut
dbshut                               --sqlplus執行shutdown的時候調用的指令碼


2、修改oratab檔案

[[email protected] 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

[[email protected] bin]$ export ORACLE_SID=ORCL

[[email protected] bin]$ dbshut

[[email protected] 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/[email protected] 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的身份登入校正作業系統的密碼檔案。

[[email protected] 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
[[email protected] 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指令碼

[[email protected] ~]# cd /etc/rc.d/init.d
[[email protected] init.d]# touch start_shut
[[email protected] 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、修改許可權

[[email protected] init.d]# chmod 755 start_shut

6、將檔案連結到啟動地區和關閉地區

[[email protected] init.d]# cd /etc/rc5.d
[[email protected] rc5.d]# ln -s /etc/rc.d/init.d/start_shut S99start_shut
[[email protected] rc5.d]# cd /etc/rc0.d
[[email protected] rc0.d]# ln -s /etc/rc.d/init.d/start_shut K01start_shut

7、測試:

init 6

oracle的環境配置-設定開機(Linux)自動啟動Oracle關機自動關閉Oracle

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.