Oracle 參數(shù)文件 |
發(fā)布時(shí)間: 2012/9/16 15:20:33 |
-->Oracle 參數(shù)文件 --======================== /* 參數(shù)文件(10g中的參數(shù)文件) 主要用來(lái)記錄數(shù)據(jù)庫(kù)的配置文件,在數(shù)據(jù)庫(kù)啟動(dòng)時(shí),Oracle讀取參數(shù)文件,并根據(jù)參數(shù)文件中的參數(shù)設(shè)置來(lái)配置數(shù)據(jù)庫(kù)。 如內(nèi)存池的分配,允許打開(kāi)的進(jìn)程數(shù)和會(huì)話(huà)數(shù)等。
兩類(lèi)參數(shù)文件: pfile:文本文件的參數(shù)文件,可以使用vi,vim等編輯器修改,文件名通常為init<sid>.ora spfile:二進(jìn)制的參數(shù)文件,不能直接修改,只能存放在Oracle服務(wù)器端,可以使用EM或指令來(lái)修改 (alter system|session set parameter_name = values <>), 文件名通常為spfile<sid>.ora,支持RMAN備份。
優(yōu)先級(jí)別: Oracle 啟動(dòng)讀取參數(shù)文件的順序,如果個(gè)文件都不存在,則Oracle會(huì)報(bào)錯(cuò) spfile<sid>.ora --> spfile.ora -->init<sid>.ora
參數(shù)文件的路徑:*/ spfle:$Oracle_HOME/dbs/spfile$ORACLE_SID.ora pfile(9i):$ORALCE_HOME/dbs/init$ORALCE_SID.ora /*10g以后一般不用init<sid>.ora*/ pfile(10g):$ORALCE_BASE/admin/$Oracle_SID/pfile /*僅當(dāng)數(shù)據(jù)庫(kù)初始化時(shí)使用*/ pfile:$Oracle_HOME/dbs/init.ora /*默認(rèn)*/ /* 參數(shù)文件之間的轉(zhuǎn)化 spfile 轉(zhuǎn)化為pfile pfile 轉(zhuǎn)換為spfile 從spfile來(lái)生成pfile create pfile from spfile ,執(zhí)行完畢后,pfile 將保存為$Oracle_HOME/dbs/init$ORACLE_SID.ora 也可以指定pfile 的路徑:create pfile = '<dir>' from spfile;
由pfile 生成spfile create spfile from pfile create spfile from pfile = '<dir>' create spfile = '<dir>' from pfile
11g中的新指令,從memeory中生成 create spfile = '<dir>' from memeory */ /* 演示:*/
spfile --> pfile SQL> create pfile from spfile;
File created.
SQL> ho ls -al /u01/app/Oracle/10g/dbs/ total 56 drwxr-x--- 2 Oracle oinstall 4096 Apr 8 13:49 . drwxr-x--- 55 Oracle oinstall 4096 Apr 7 09:48 .. -rw-r----- 1 Oracle oinstall 1544 Apr 6 12:06 hc_orcl.dat -rw-r----- 1 Oracle oinstall 8385 Sep 11 1998 init.ora -rw-r----- 1 Oracle oinstall 12920 May 3 2001 initdw.ora -rw------- 1 Oracle oinstall 1155 Apr 8 13:49 initorcl.ora -rw-r----- 1 Oracle oinstall 24 Apr 6 12:06 lkORCL -rw-r----- 1 Oracle oinstall 1536 Apr 7 15:50 orapworcl -rw-r----- 1 Oracle oinstall 3584 Apr 8 11:15 spfileorcl.ora
SQL> ho cat /u01/app/Oracle/10g/dbs/initorcl.ora orcl.__db_cache_size=251658240 orcl.__java_pool_size=4194304 orcl.__large_pool_size=4194304 orcl.__shared_pool_size=142606336 orcl.__streams_pool_size=0 *.audit_file_dest='/u01/app/Oracle/admin/orcl/adump' *.background_dump_dest='/u01/app/Oracle/admin/orcl/bdump' *.compatible='10.2.0.1.0' *.control_files='/u01/app/Oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl', '/u01/app/oracle/oradata/orcl/control03.ctl' *.core_dump_dest='/u01/app/Oracle/admin/orcl/cdump' *.db_block_size=8192 *.db_create_file_dest='/u01/app/Oracle/oradata/orcl' *.db_create_online_log_dest_1='/u01/app/Oracle/disk1' *.db_create_online_log_dest_2='/u01/app/Oracle/disk2' *.db_domain='' *.db_file_multiblock_read_count=16 *.db_name='orcl' *.db_recovery_file_dest='/u01/app/Oracle/flash_recovery_area' *.db_recovery_file_dest_size=2147483648 *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.job_queue_processes=10 *.open_cursors=300 *.pga_aggregate_target=135266304 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=406847488 *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1' *.user_dump_dest='/u01/app/Oracle/admin/orcl/udump'
pfile --> spfile SQL> create spfile from pfile; /*使用該命令的時(shí)候不能轉(zhuǎn)換,如下報(bào)錯(cuò),因?yàn)楫?dāng)前的spfile正在使用*/ create spfile from pfile * ERROR at line 1: ORA-32002: cannot create SPFILE already being used by the instance
SQL> create spfile = '/u01/app/Oracle/spfileorcl.ora' from pfile;
File created.
SQL> ho cat /u01/app/Oracle/spfileorcl.ora; a*orcl.__db_cache_size=251658240 orcl.__java_pool_size=4194304 orcl.__large_pool_size=4194304 orcl.__shared_pool_size=142606336 orcl.__streams_pool_size=0 *.audit_file_dest='/u01/app/Oracle/admin/orcl/adump' *.background_dump_dest='/u01/app/Oracle/admin/orcl/bdump' *.compatible='10.2.0.1.0' *.control_files='/u01/app/Oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl' *.core_dump_dest='/u01/app/Oracle/admin/orcl/cdump' *.db_block_size=8192 *.db_create_file_dest='/u01/app/Oracle/oradata/orcl' *.db_create_online_log_dest_1='/u01/app/Oracle/disk1' *.db_create_online_log_dest_2='/u01/app/Oracle/disk2' *.db_domain='' *.db_file_multiblock_read_count=16 *.db_name='orcl' *.db_recovery_file_dest='/u01/app/Oracle/flash_recovery_area' *.db_recovery_file_dest_size=2147483648 *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.job_queue_processes=10 *.open_cursors=300 *.pga_aggregate_target=135266304 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=406847488 *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1' *.user_dump_dest='/u01/app/Oracle/admin/orcl/udump' /* 轉(zhuǎn)換后的使用: 假定修改了initorcl.ora中的參數(shù),但Oracle啟動(dòng)是先讀取spfile ,故可以在啟動(dòng)的時(shí)候指定用initorcl.ora來(lái) 初始化參數(shù),啟動(dòng)完畢后,可以創(chuàng)建spfile,則下一次啟動(dòng)就可以使用新的spfile.
假定我們對(duì)initorcl.ora作如下修改:*/ open_cursors=600 processes=250 /* 則關(guān)閉數(shù)據(jù)庫(kù)后指定以initorcl.ora參數(shù)來(lái)啟動(dòng)數(shù)據(jù)庫(kù)*/ SQL> startup pfile = '/u01/app/Oracle/10g/dbs/initorcl.ora'; Oracle instance started.
Total System Global Area 406847488 bytes Fixed Size 1219688 bytes Variable Size 150995864 bytes Database Buffers 251658240 bytes Redo Buffers 2973696 bytes Database mounted. Database opened.
SQL> create spfile from pfile; /*修改的內(nèi)容將會(huì)更新到spfile*/
File created.
--查看參數(shù)文件的名字 SQL> show parameter service_name
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string orcl
--查看當(dāng)前使用的哪個(gè)參數(shù)文件啟動(dòng)的 SQL> select distinct isspecified from v$spparameter;
ISSPEC ------ FALSE /* 如果第一個(gè)值是FALSE還是TRUE,如果是FALSE,則是pfile,否則則是spfile.
也可以嘗試修改spfile ,如果報(bào)錯(cuò)則可以判斷是從pfile啟動(dòng),當(dāng)然所修改的參數(shù)必須是可以修改的*/ SQL> alter system set sga_target = 200m scope = spfile; alter system set sga_target = 200m scope = spfile * ERROR at line 1: ORA-32001: write to SPFILE requested but no SPFILE specified at startup
--強(qiáng)制啟動(dòng)Oracle后再查看是使用的哪個(gè)參數(shù)啟動(dòng)的。 SQL> startup force Oracle instance started.
Total System Global Area 406847488 bytes Fixed Size 1219688 bytes Variable Size 150995864 bytes Database Buffers 251658240 bytes Redo Buffers 2973696 bytes Database mounted.
Database opened. SQL> select distinct isspecified from v$spparameter;
ISSPEC ------ TRUE FALSE /* 第一行為T(mén)RUE可知,是從spfile啟動(dòng)的,有兩行,其中第二行為FALSE,表示有兩個(gè)參數(shù)文件,一個(gè)是spfile,一個(gè)是pfile 再次嘗試看看能否修改spfile: */ SQL> alter system set sga_target = 380m scope = spfile; /*修改成功*/
System altered. /* 參數(shù)文件的修改: 如果是pfile ,直接使用vi,vim來(lái)修改即可 如果是spfile ,則使用 */ alter system|session set parametername = values scope = memory | spfile |both sid = 'sid' | ‘*’; scope memory : 只對(duì)當(dāng)前實(shí)例有效,下次啟動(dòng)則失效 spfile : 只對(duì)spfile 修改,必須經(jīng)過(guò)下一次啟動(dòng)才生效,當(dāng)前的實(shí)例沒(méi)有修改 both :內(nèi)存與參數(shù)文件都將修改,當(dāng)不指定scope時(shí),缺省為both. system | session system :
-- 查詢(xún)視圖:v$parameter isses_modifiable 可以被alter session修改 isssy_modifiable 可以被alter system修改 -- sid: sid :只對(duì)某一個(gè)實(shí)例 * :對(duì)所有的實(shí)例修改
SQL> show parameter sga_ /*查看與sga有關(guān)的參數(shù)*/
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ sga_max_size big integer 388M sga_target big integer 388M
SQL> alter system set sga_max_size = 350m; /*特殊的參數(shù)不能被修改*/ alter system set sga_max_size = 350m * ERROR at line 1: ORA-02095: specified initialization parameter cannot be modified
SQL> a scope = spfile 1* alter system set sga_max_size = 350m scope = spfile SQL> /
System altered.
SQL> select instance_name from v$instance;
INSTANCE_NAME ---------------- orcl
SQL> alter system set sga_max_size = 350m scope = spfile sid = 'orcl';
System altered.
--只改內(nèi)存 SQL> show parameter pga
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 129M
SQL> alter system set pga_aggregate_target = 130m scope = memory;
System altered.
-- 同時(shí)修改內(nèi)存和參數(shù)文件,以下兩條語(yǔ)句等效 SQL> alter system set pga_aggregate_target = 130m scope = both;
System altered.
SQL> alter system set pga_aggregate_target = 130m ;
System altered.
--alter session SQL> show parameter sql_
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ plsql_ccflags string plsql_code_type string INTERPRETED plsql_compiler_flags string INTERPRETED, NON_DEBUG plsql_debug boolean FALSE plsql_native_library_dir string plsql_native_library_subdir_count integer 0 plsql_optimize_level integer 2 plsql_v2_compatibility boolean FALSE plsql_warnings string DISABLE:ALL sql92_security boolean FALSE sql_trace boolean FALSE
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ sql_version string NATIVE sqltune_category string DEFAULT SQL> alter session set sql_trace = true;
Session altered.
-- 可以從v$parameter視圖中來(lái)得到哪些可以使用alter system修改,哪些可以使用alter session來(lái)修改。 SQL> col name for a40 SQL> select NAME,ISSES_MODIFIABLE,ISSYS_MODIFIABLE from v$parameter 2 where name like 'sql%';
NAME ISSES ISSYS_MOD ---------------------------------------- ----- --------- sql_trace TRUE IMMEDIATE sql92_security FALSE FALSE sql_version TRUE FALSE sqltune_category TRUE IMMEDIATE
-- TURE:可以該類(lèi)型修改,F(xiàn)LASE:不支持該類(lèi)型修改,IMMEDIATE:也是支持該類(lèi)型修改
SQL> alter system set sql_version = 8; /*不支持system類(lèi)型修改*/ alter system set sql_version = 8 * ERROR at line 1: ORA-02096: specified initialization parameter is not modifiable with this option SQL> alter session set sql_version = 8; ERROR: ORA-00096: invalid value 8 for parameter sql_version, must be from among MAX, NATIVE, 8.1.6, 8.1.5
SQL> alter session set sql_version = '8.1.6'; /*支持session類(lèi)型修改*/
Session altered.
SQL> select distinct issys_modifiable from v$parameter;
ISSYS_MOD --------- IMMEDIATE /*動(dòng)態(tài)參數(shù),直接修改到內(nèi)存的參數(shù)alter system set <> = <>,后面不需要跟scope*/ FALSE /*靜態(tài)參數(shù),不能直接修改到內(nèi)存,alter system set <> = <> scope = spfile*/ DEFERRED /*會(huì)話(huà)級(jí)別參數(shù),直接通過(guò)alter session set <> = <>*/
SQL> select distinct isses_modifiable from v$parameter;
ISSES ----- TRUE FALSE
--系統(tǒng)中的常用參數(shù): SQL> ho ls /u01/app/Oracle/10g/dbs/ hc_orcl.dat initdw.ora lkORCL spfileorcl.ora init.ora initorcl.ora orapworcl
SQL> ho cat /u01/app/Oracle/10g/dbs/initorcl.ora /*下面的參數(shù)描述了實(shí)例相關(guān)池的分配情況*/ orcl.__db_cache_size=251658240 orcl.__java_pool_size=4194304 orcl.__large_pool_size=4194304 orcl.__shared_pool_size=142606336 orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/Oracle/admin/orcl/adump' /*警告日志路徑*/ *.background_dump_dest='/u01/app/Oracle/admin/orcl/bdump' /*后臺(tái)進(jìn)程日志路徑*/ *.compatible='10.2.0.1.0' /*版本兼容號(hào)*/ /*下面是控制文件的信息*/ *.control_files='/u01/app/Oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl' *.core_dump_dest='/u01/app/Oracle/admin/orcl/cdump' /*服務(wù)器進(jìn)程相關(guān)的日志路徑*/ *.db_block_size=8192 /*內(nèi)存塊的大小*/ *.db_create_file_dest='/u01/app/Oracle/oradata/orcl' /*tablespace ,datafile路徑*/ *.db_create_online_log_dest_1='/u01/app/Oracle/disk1' /*聯(lián)機(jī)日志文件路徑*/ *.db_create_online_log_dest_2='/u01/app/Oracle/disk2' /*聯(lián)機(jī)日志文件路徑*/ *.db_domain='' /域名/ *.db_file_multiblock_read_count=16 /*一次可讀取塊的大小:*8k = 128kb*/ *.db_name='orcl' /數(shù)據(jù)庫(kù)標(biāo)識(shí)符/ *.db_recovery_file_dest='/u01/app/Oracle/flash_recovery_area' /*閃回路徑*/ *.db_recovery_file_dest_size=2147483648 /*閃回區(qū)可使用的大小GB*/ *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' /*共享服務(wù)器的配置參數(shù)*/ *.job_queue_processes=10 /*當(dāng)前作業(yè)進(jìn)程數(shù)*/ *.open_cursors=600 /*可打開(kāi)的游標(biāo)數(shù)*/ *.pga_aggregate_target=135266304 /*服務(wù)器進(jìn)程大小*/ *.processes=250 /*描述當(dāng)前可以運(yùn)行的進(jìn)程數(shù)*/ *.remote_login_passwordfile='EXCLUSIVE' /*遠(yuǎn)程登陸是否要用密碼文件*/ *.sga_target=406847488 /*定義了sga的大小*/ *.undo_management='AUTO' /*Undo表空間的管理方式為自動(dòng)管理*/ *.undo_tablespace='UNDOTBS1' /*指定使用哪一個(gè)undo表空間*/ *.user_dump_dest='/u01/app/Oracle/admin/orcl/udump' /**/
--11g中的參數(shù)文件:
-- 隱藏參數(shù): SQL> desc x$ksppi /*Name列中為隱藏參數(shù)的名字*/ Name Null? Type ----------------------------------------- -------- ---------------------------- ADDR RAW(4) INDX NUMBER INST_ID NUMBER KSPPINM VARCHAR2(80) KSPPITY NUMBER KSPPDESC VARCHAR2(255) KSPPIFLG NUMBER KSPPILRMFLG NUMBER KSPPIHASH NUMBER
--下面視圖中為隱藏參數(shù)的值 SQL> desc x$ksppcv Name Null? Type ----------------------------------------- -------- ---------------------------- ADDR RAW(4) INDX NUMBER INST_ID NUMBER KSPPSTVL VARCHAR2(512) KSPPSTDVL VARCHAR2(512) KSPPSTDF VARCHAR2(9) KSPPSTVF NUMBER KSPPSTCMNT VARCHAR2(255)
--使用下面的命令來(lái)查看系統(tǒng)中的隱藏參數(shù);
SQL> select ksppinm,ksppstvl from x$ksppi a,x$ksppcv b where a.indx = b.indx;
SQL> a and ksppinm like '%_allow%'; 1* select ksppinm,ksppstvl from x$ksppi a,x$ksppcv b where a.indx = b.indx and ksppinm like '%_allow%' SQL> /
KSPPINM KSPPSTVL ---------------------------------------- ---------- _allow_level_without_connect_by FALSE _asm_allow_only_raw_disks TRUE _asm_allow_resilver_corruption FALSE /* 參數(shù)的刪除: 對(duì)于pfile直接編輯刪除即可 對(duì)于spfile 例如使用alter system set pga_aggregate_target reset將恢復(fù)到默認(rèn)值 */ SQL> show parameter pga
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 130M
SQL> alter system reset pga_aggregate_target scope = spfile sid = '*';
System altered.
-- 修改會(huì)默認(rèn)值后重新啟動(dòng)可以看到該參數(shù)的值由M變?yōu)镸 SQL> show parameter pga;
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pga_aggregate_target big integer 76M /*
Oracle教程 更多參考 有關(guān)閃回特性請(qǐng)參考 Oracle 閃回特性(FLASHBACK DATABASE) Oracle 閃回特性(FLASHBACK DROP & RECYCLEBIN) Oracle 閃回特性(Flashback Query、Flashback Table) Oracle 閃回特性(Flashback Version、Flashback Transaction) 有關(guān)基于用戶(hù)管理的備份和備份恢復(fù)的概念請(qǐng)參考: Oracle 冷備份 Oracle 熱備份 Oracle 備份恢復(fù)概念 Oracle 實(shí)例恢復(fù) Oracle 基于用戶(hù)管理恢復(fù)的處理(詳細(xì)描述了介質(zhì)恢復(fù)及其處理) 有關(guān)RMAN的恢復(fù)與管理請(qǐng)參考: RMAN 概述及其體系結(jié)構(gòu) RMAN 配置、監(jiān)控與管理 RMAN 備份詳解 RMAN 還原與恢復(fù) 有關(guān)Oracle體系結(jié)構(gòu)請(qǐng)參考: Oracle 實(shí)例和Oracle數(shù)據(jù)庫(kù)(Oracle體系結(jié)構(gòu)) Oracle 表空間與數(shù)據(jù)文件 Oracle 密碼文件 Oracle 參數(shù)文件 Oracle 數(shù)據(jù)庫(kù)實(shí)例啟動(dòng)關(guān)閉過(guò)程 Oracle 聯(lián)機(jī)重做日志文件(ONLINE LOG FILE) Oracle 控制文件(CONTROLFILE) Oracle 歸檔日志
本文出自:億恩科技【1tcdy.com】 服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM] |