spfile & pfile 差異:

Oracle Database 自從 9i 以後的版本,就開始支援 spfile ,spfile & pfile 差異處如下:

  • pfile  :client 端參數文件,是一個文字檔,不能動態修改,可用 notepad 或 vi 來編輯,DBA 通常是指這個 init.ora 文件;修改之後需要重啟資料庫才會生效。
  • spfile:服務器端參數文件(Server Parameter File),這是一個二進位的檔案,編輯 SPFILE 檔案會破壞它,您將無法啟動您的數據庫,要更改參數值,需用指令:"ALTER SYSTEM SET" 來變更; 有了spfile,資料庫的參數可以線上動態修改,部分參數修改之後無需重啟資料庫就可以直接生效。。

 

可以用下列指令,得知您的資料庫是用那一種模式起動的。

 SQL> SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type"
       FROM sys.v_$parameter WHERE name = 'spfile';

 

另一種查詢的方式,是查 view: V$SPPARAMETER,如:SHOW PARAMETERS pfile | spfile ; 若值為 null ,則是使用 pfile (init.ora) 啟動資料庫。

show parameters 各位 view 的意思:

V$PARAMETER view - display the currently in effect parameter values
V$PARAMETER2 view - display the currently in effect parameter values, but "List Values" are shown in multiple rows
V$SPPARAMETER view - display the current contents of the server parameter file.

 

spfile 的優點:

  • 1. 可以用 RMAN 備份 spfile ( spfile 是 Server Parameter File ), RMAN 無法備份 pfile ( client 端參數文件 )
  • 2. 滅少人為修改參數造成的錯誤,spfile 是儲存在資料庫系統裡,用 "ALTER SYSTEM SET" 來變更時,系統會先作檢查。
  • 3. 只有一個 spfile 參數檔,很容易找到與維護。

 

從 spfile 獲取 pfile:

Create pfile='d:pfileSID.ora' from spfile;
SQL> Create pfile='C:\oraclexe\app\oracle\admin\XE\pfile\pfileSID.ora' from spfile;


從pfile獲取spfile:

Create spfile from pfile='Your_pfile_location'
Create spfile='spfile_location' from pfile='Your_pfile_location'

動態修改參數:
alter system set parameter=Value scope=spfile | both | memory ( Startup nomount 的時候需要讀去 spfile 或 pfile 或 兩者共存,系統以 spfile 優先 )

SQL> ALTER SYSTEM SET open_cursors=300 SCOPE=SPFILE;

SQL> ALTER SYSTEM SET timed_statistics=TRUE
    COMMENT='Changed by Frank on 1 June 2003'
    SCOPE=BOTH
     SID='*';

The SCOPE parameter can be set to SPFILE, MEMORY or BOTH:

  • - MEMORY: Set for the current instance only. This is the default behaviour if a PFILE was used at STARTUP.
  • - SPFILE: update the SPFILE, the parameter will take effect with next database startup
  • - BOTH: affect the current instance and persist to the SPFILE. This is the default behaviour if an SPFILE was used at STARTUP.
  • The COMMENT parameter (optional) specifies a user remark.

 

強制用 pfile 啟動:

SQL>startup pfile='Your_Pfile.ora'
SQL>startup spfile='/data/oracle/product/10.2.0/db_1/dbs/dbs/spfile_orcl.ora' force

 

參數檔案 spfile 的備份:

RMAN (Oracle's Recovery Manager) 可以備份 SPFILE ,但參數 "CONFIGURE CONTROLFILE AUTOBACKUP" 要設定為 ON (the default is OFF). PFILEs 則無法由 RMAN 備份.如下範例設定:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

由 RMAN 回存 SPFILE:

RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;

 

參考:

http://orafaq.com/node/5

http://weicheng331.blogspot.tw/2009/05/oracle-spfile-pfile.html

arrow
arrow
    文章標籤
    oracle pfile spfile RMAN
    全站熱搜

    MIS 發表在 痞客邦 留言(0) 人氣()