您好,登錄后才能下訂單哦!
SPFILE儲存在服務端,它不能自行修改(從而克服了PFILE的一些安全性隱患),如果使用文本編輯器查看SPFILE會發現這是個二進制文件,需要使用SQL命令,由Oracle Server進行管理,使用SQL命令修改的值會永久的保存起來。Oracle的備份恢復工具RMAN可以備份SPFILE。
[oracle@localhost ~]$ sqlplus/nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 2710:40:15 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> create spfile frompfile;
File created.
[oracle@localhost dbs]$ ll
total 3 -rw-r--r--. 1 oracle oinstall 2851 Aug 27 10:41 initorcl.ora drwxr-xr-x. 3 oracle oinstall 4096 Aug 27 10:20 old -rw-r-----. 1 oracle oinstall 1536 Aug 27 10:42spfileorcl.ora
SQL> startup
ORACLE instance started. Total System Global Area 422670336 bytes Fixed Size 1336960 bytes Variable Size 318769536 bytes Database Buffers 96468992 bytes Redo Buffers 6094848 bytes Database mounted. Database opened.
=============查看SPFILE=============
由于SPFILE是個二進制文件,故不能使用文本編輯器查看,因此在Linux的命令行中使用strings命令來查看這個文件:
[oracle@localhost dbs]$strings spfileorcl.ora | more
orcl.__db_cache_size=96468992 orcl.__java_pool_size=4194304 orcl.__large_pool_size=4194304 orcl.__oracle_base='/oracle'#ORACLE_BASE set fromenvironment orcl.__pga_aggregate_target=146800640 orcl.__sga_target=276824064 orcl.__shared_io_pool_size=0 orcl.__shared_pool_size=159383552 orcl.__streams_pool_size=4194304 *.audit_file_dest='/oracle/admin/orcl/adump' *.audit_trail='db' *.compatible='11.2.0.0.0' *.control_files='/oracle/oradata/orcl/control01.ctl','/oracle/flash_recove ry_area/o rcl/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='orcl' *.db_recovery_file_dest='/oracle/flash_recovery_area' *.db_recovery_file_dest_size=4039114752 *.diagnostic_dest='/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.memory_target=421527552 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1'
SPFILE不能使用文本編輯器手動修改,必須使用SQL命令來修改,其格式為:
ALTER system set parameter=value <comment=’text’><deferred> <scope=memory|spfile|both> <sid=’sid|*’>
<comment=’text’>表示給某個參數加注釋,便于以后查看
<deferred>表示等下次啟動實例再生效
手動修改了PFILE后,通常不能馬上生效,必須等下次啟動Instance才能生效;而SPFILE是Oracle內置的二進制文件,通過指定<SCOPE>,就能夠明確現在修改的參數值是作用于內存中讓其馬上生效,還是將其保存到磁盤上的SPFILE文件上,亦或是二者同時修改,默認情況下是二者同時修改,既作用于內存中立刻生效,也保存到磁盤文件上。
通常情況下一個實例(Instance)對應一個數據庫,但在RAC(大規模的集群數據庫)環境中,通常是多個實例對應一個數據庫,因此就需要指定<SID>的值來區分具體的實例。
使用strings命令查看SPFILE,會發現很多文件前面都有一個*,它表示這個參數適用于所有的Instance;而沒有帶*號的,就需要指定SID,如orcl.__db_cache_size=96468992中,orcl就是SID。
/*==========修改SPFILE實例演示============*/
[oracle@localhost dbs]$strings spfileorcl.ora | less
orcl.__db_cache_size=96468992 orcl.__java_pool_size=4194304 … *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.memory_target=421527552
/*=== 現在來修改SPFILE的值 ===*/
SQL> show parameter fast_
NAME TYPE VALUE ------------------------------------ ----------------------------------------- fast_start_io_target integer 0 fast_start_mttr_target integer 0 fast_start_parallel_rollback string LOW
SQL> alter system setfast_start_mttr_target=250;
-- 沒有加任何scope,則該值會保存到內存和磁盤文件上 System altered.
SQL> show parameter fast_
NAME TYPE VALUE ------------------------------------ ----------------------------------------- fast_start_io_target integer 0 fast_start_mttr_target integer 250 fast_start_parallel_rollback string LOW
[oracle@localhost dbs]$strings spfileorcl.ora | more
orcl.__db_cache_size=96468992 orcl.__java_pool_size=4194304 … *.fast_start_mttr_target=250 *.memory_target=421527552
/*===========再來看加了scope的情況=============*/
SQL> alter system setfast_start_mttr_target=260 scope=memory;
System altered.
SQL> show parameter fast_
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ fast_start_io_target integer 0 fast_start_mttr_target integer 260 -- 內存中已經修改為260了 fast_start_parallel_rollback string LOW
[oracle@localhost dbs]$strings spfileorcl.ora | more
orcl.__db_cache_size=96468992 orcl.__java_pool_size=4194304 *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.fast_start_mttr_target=250 # 磁盤上的值仍然是250 *.memory_target=421527552
/*=================修改SPFILE時加注解==================*/
SQL> alter system set fast_start_mttr_target=260comment='hello Mickey!';
System altered.
SQL> desc v$parameter;
Name Null? Type ------------------------------------------------- ---------------------------- NUM NUMBER NAME VARCHAR2(80) TYPE NUMBER VALUE VARCHAR2(4000) DISPLAY_VALUE VARCHAR2(4000) ISDEFAULT VARCHAR2(9) ISSES_MODIFIABLE VARCHAR2(5) ISSYS_MODIFIABLE VARCHAR2(9) ISINSTANCE_MODIFIABLE VARCHAR2(5) ISMODIFIED VARCHAR2(10) ISADJUSTED VARCHAR2(5) ISDEPRECATED VARCHAR2(5) ISBASIC VARCHAR2(5) DESCRIPTION VARCHAR2(255) UPDATE_COMMENT VARCHAR2(255) HASH NUMBER
SQL> select name, value,update_comment
2 from v$parameter 3 where name = 'fast_start_mttr_target'; NAME VALUE UPDATE_COMMENT -------------------------------- --------------- ------------------------ fast_start_mttr_target 260 hello Mickey!
[oracle@localhost dbs]$strings spfileorcl.ora | more
orcl.__db_cache_size=96468992 orcl.__java_pool_size=4194304 *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.fast_start_mttr_target=260#hello Mickey! # 已經加上注解了 *.memory_target=421527552
有些參數必須延遲生效,這就需要在修改時加上deferred選項,在參數表v$parameter中ISINSTANCE_MODIFIABLE項中如果標注為deferred,就需要延遲生效
SQL> col name format a20
SQL> col issys_modifiableformat a20
SQL> select name,issys_modifiable
2 from v$parameter 3 where issys_modifiable = 'DEFERRED'; NAME ISSYS_MODIFIABLE ------------------------------ -------------------- backup_tape_io_slaves DEFERRED recyclebin DEFERRED audit_file_dest DEFERRED object_cache_optimal_size DEFERRED object_cache_max_size_percent DEFERRED sort_area_size DEFERRED sort_area_retained_size DEFERRED olap_page_pool_size DEFERRED 8 rows selected.
更多ALERT 的使用細節,可以查看聯機文檔reference中有關ALTER SYSTEM的相關章節。
如果不想要修改后的值,可以使用reset命令來恢復為缺省值
SQL> show parameter undo
NAME TYPE VALUE ------------------------------------ ----------------------------------------- undo_management string AUTO undo_retention integer 900 undo_tablespace string UNDOTBS1
SQL> alter system setundo_retention=800;
System altered.
SQL> show parameter undo
NAME TYPE VALUE ------------------------------------ ------------------------------------- undo_management string AUTO undo_retention integer 800 undo_tablespace string UNDOTBS1
SQL> alter system resetundo_retention sid='*';
System altered.
更多關于reset的細節,可以查詢聯機文檔reference。
可以用spfile來創建pfile:
SQL> create pfile fromspfile;
File created.
[oracle@localhost dbs]$ ll
total 36 -rw-r-----. 1 oracle oinstall 1544 Aug 27 10:47 hc_orcl.dat -rw-r--r--. 1 oracle oinstall 2851 Aug 27 13:36 init.ora -rw-r--r--. 1 oracle oinstall 904 Aug 27 13:34 initorcl.ora # 根據spfile創建出來的pfile文件 -rw-r-----. 1 oracle oinstall 24 Aug 27 10:45 lkORCL drwxr-xr-x. 3 oracle oinstall 4096 Aug 27 10:20 old -rw-r-----. 1 oracle oinstall 1536 Aug 27 10:45 orapworcl drwx------. 2 oracle oinstall 4096 Aug 27 10:47 peshm_orcl_0 drwx------. 2 oracle oinstall 4096 Aug 27 09:31 peshm_ORCL_0 -rw-r-----. 1 oracle oinstall 2560 Aug 27 13:27spfileorcl.ora
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。