关于pfile和spfile

什么是pfile文件和spfile文件,这2个文件是干什么用的?下面做下总结。

Pfile文件
Pfile(Parameter File)文件是基于文本格式的参数文件,含有数据库的配置参数。
Oracle 9i在安装时为每个数据库建立了一个Pfile,默认的名称为“init+例程名.ora”,这是一个文本文件,可以用任何文本编辑工具打开。
spfile文件
spfile(server parameter file 服务器参数文件)是基于二进制格式的参数文件,含有数据库及例程的参数和数值,但不能用文本编辑器打开。
spfile:
格式:二进制格式。
编辑方式:1>:利用企业管理器对pfile进行修改,然后转换成spfile.2>:在SQL/PLUS里使用ALTER SYSTEM语句进行修改。3>:用文本编辑器对pfile进行修改,然后使用(create spfile from pfile='youe pfile location')
默认名称:spfile+例程名.ora
默认路径:/opt/oracle/product/9.2.0/dbs
启动次序:spfile优于pfile

pfile:
格式:文本格式
编辑方式:1>:利用文本工具直接进行修改.2>:在企业管理器里修改配置后导出形成
默认名称:init+例程名.ora 实际参数文件init.ora
默认路径:ORACLE_HOME/admin/pfile/
启动次序:Pfile低于Spfile


spfile与pfile的转换
1:查看系统是以SPFILE还是PFILE启动:
select * from v$spparameter;
V$SPPARAMETER这个视力显示SPFILE文件的信息,如果实例启动方式不是以SPFILE方式,则这张表里面的ISSPECIFIED字段都显示FALSE,否则如果ISSPECIFIED有TRUE,则表示用SPFILE进行了指定
另外还有V$PARAMETER2,和V$PARAMETER这是手册记录的原话:
V$SPPARAMETER displays information about the contents of the server parameter file. If a server parameter file was not used to start the instance, then each row of the view will contain FALSE in the ISSPECIFIED column.
V$PARAMETER2 displays information about the initialization parameters that are currently in effect for the session, with each list parameter value appearing as a row in the view. A new session inherits parameter values from the instance-wide values displayed in the V$SYSTEM_PARAMETER2 view.
V$PARAMETER displays information about the initialization parameters that are currently in effect for the session. A new session inherits parameter values from the instance-wide values displayed by the V$SYSTEM_PARAMETER view.

2:使用SPFILE的好处:
SPFILE改正了PFILE管理混乱的问题,在多结点环境里,PFILE会有多个image,启动时需要跟踪最新的image。这是个烦琐的过程。
用SPFILE以后,所有参数改变都写在SPFILE里面,(只需定义scope=spfile或both),参数配置有个权威的来源。

3:从SPFILE获取PFILE,从PFILE获取SPFILE.
Create pfile='d:pfileSID.ora' from spfile;
Create pfile='d:pfileSID.ora' from spfile='spfile_location';
从pfile获取spfile
Create spfile from pfile='Your_pfile_location'
Create spfile='spfile_location' from pfile='Your_pfile_location'

4:动态修改参数
alter system set parameter=Value scope=spfile|both|memory

5:强制用PFILE启动
SQL>startup pfile='Your_Pfile.ora'
SQL>startup spfile='/data/oracle/product/10.2.0/db_1/dbs/dbs/spfile_mqq.ora' force

 

posted @ 2012-09-05 17:22  晓睿  阅读(612)  评论(0编辑  收藏  举报