oracle資料庫的啟動和關閉

來源:互聯網
上載者:User

      對於一個DBA來說,啟動和關閉oracle資料庫是常規的、基礎的操作,有時候Linux管理員或者程式員也需要在開發資料庫中進行一些基本的DBA操作,所以對於非DBA人員來說瞭解一些基礎的資料庫管理活動是很重要的。

      本文將討論oracle資料庫的啟動和關閉過程。

 

怎樣啟動oracle資料庫

1.用oracle使用者登陸系統

典型的oracle安裝使用oracle作為使用者名稱,dba作為組。在Linux中,輸入su命令轉換到oracle使用者。如下:

 

$ su - oracle

 

2.用sysdba角色串連到oracle

確保已經正確的設定了ORACLE_SID和ORACLE_HOME變數,如下所示:

 

$ env | grep ORA
ORACLE_SID=DEVDB
ORACLE_HOME=/u01/app/oracle/product/10.2.0

 

使用'/ as sysdba'或者任意具有DBA許可權的使用者串連到oracle

 

$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Jan 18 11:11:28 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning and Data Mining options
SQL>

 

3.啟動oracle資料庫

預設的SPFILE檔案位於$ORACLE_HOME/dbs目錄下,如果你沒用指定PFILE參數,oracle在啟動過程中會使用SPFILE。

oracle在$ORACLE_HOME/dbs目錄下以如下指定的順序尋找參數檔案,如果存在,將會使用最先找到的一個。

  1. spfile$ORACLE_SID.ora
  2. spfile.ora
  3. init$ORACLE_SID.ora

在SQL命令提示字元下輸入"STARTUP"命令啟動oracle資料庫,如下所示:

 

SQL> startup
ORACLE instance started.

Total System Global Area  812529152 bytes
Fixed Size                  2264280 bytes
Variable Size             960781800 bytes
Database Buffers           54654432 bytes
Redo Buffers                3498640 bytes
Database mounted.
Database opened.
SQL>

 

如果你想在oracle啟動時指定PFILE,把它作為參數傳遞給startup命令:

SQL> STARTUP PFILE=/u01/app/oracle/product/10.2.0/dbs/init.ora

 

怎樣關閉oracle資料庫

可以使用如下三種方法關閉oracle資料庫:

  1. Normal Shutdown
  2. Shutdown Immediate
  3. Shutdown Abort

1.正常關閉

正常關閉時,在oracle資料庫關閉之前,oracle將等待所有的活動使用者從當前會話中中斷連線,使用該方法在正常條件下關閉資料庫。

 

SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

 

2.Shutdown Immediate

當使用Shutdown Immediate時,在oracle資料庫關閉之前,oracle將復原所有的活動事務並且斷開所有的活動使用者。當你沒有充足的時間通知使用者log-off時使用這種方法關閉資料庫。

 

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

 

3.Shutdown Abort

當使用Shutdown abort時,在oracle資料庫關閉之前,所有的使用者會話被立即中斷,所有未提交的事務被復原。只在用"shutdown"和"shutdown immediate"無效時,並且情況緊急的條件下使用該方法。

 

$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Jan 18 11:11:33 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to an idle instance.

SQL> shutdown abort
ORACLE instance shut down.
SQL>

 

 

聯繫我們

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