oracle 参数文件笔记

参数文件
广义上oracle里能够配置的文件都可以叫参数文件,这里专指数据库参数文件,又称初始文件,
记录了数据库的相关参数,如数据库名、内存结构大小、控制文件位置以键值方式记录

两种形式:
init<ORACLE_SID>.ora 
1、init file 9i以前,可直接打开或编辑的纯文本文件
2alter system命令修改参数后还要手动修改init file

spfile<ORACLE_SID>.ora 
1、server parameter file 9i后的默认的二进制服务器参数文件
2、可用RMAN备份到备份集中
3alter system 命令同步更新spfile

有时需要有些特殊的设置用于完成数据库维护,可由spfile生成一个pfile并在启动实例时指定该文件

无initoral.ora
SQL> !ls  
hc_orcl.dat  initdw.ora  init.ora  initorcl.ora.bk  lkORCL  orapworcl  spfileorcl.ora  test_spfile

SQL> create pfile from spfile;

File created.

产生了initoral.ora文件
SQL> !ls
hc_orcl.dat  init.ora       initorcl.ora.bk  orapworcl        test_spfile
initdw.ora   initorcl.ora  lkORCL        spfileorcl.ora

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

用上面产生的init参数文件启动实例
SQL> startup pfile=/ora/ora10g/product/10.2.0/db_1/dbs/initorcl.ora
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size            1218992 bytes
Variable Size          100664912 bytes
Database Buffers      180355072 bytes
Redo Buffers            2973696 bytes
Database mounted.
Database opened.

此时再查看spfile参数已经是空,因为本次我们是用的init文件启动
SQL> show parameter spfile;

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
spfile                     string

但在下次用startup直接启动实例后,spfile参数就还会是原来spfile文件
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size            1218992 bytes
Variable Size          100664912 bytes
Database Buffers      180355072 bytes
Redo Buffers            2973696 bytes
Database mounted.
Database opened.
SQL> show parameter spfile;

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
spfile                     string     /ora/ora10g/product/10.2.0/db_
                         1/dbs/spfileorcl.ora

参数文件默认位置: /$ORACLE_HOME/product/10.2.0/db_1/dbs/spfile<ORACLE_SID>.ora
改变参数文件位置后,启动实例时加上pfile=文件完整路径(强烈建议不修改默认路径)

启动实例时startup 时查询参数文件顺序如下:
spfile<ORACLE_SID>.ora -> init<ORACLE_SID>.ora 都找不着则报错

模拟参数文件丢失情况
1、将默认位置的参数文件重命名
[oracle@localhost dbs]$ mv spfileorcl.ora spfileorcl.ora.bk
[oracle@localhost dbs]$ mv initorcl.ora initorcl.ora.bk

2、SQL> startup 
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/ora/ora10g/product/10.2.0/db_1/dbs/initorcl.ora'
启动实例时报错,无法找到参数文件

3、将spfile文件恢复到默认位置后,实例启动成功
[oracle@localhost dbs]$ mv spfileorcl.ora.bk spfileorcl.ora
SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size            1218992 bytes
Variable Size          100664912 bytes
Database Buffers      180355072 bytes
Redo Buffers            2973696 bytes
Database mounted.
Database opened.

查看参数文件位置
SQL> show parameter spfile

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
spfile                     string     /ora/ora10g/product/10.2.0/db_
                         1/dbs/spfileorcl.ora

 

posted on 2013-06-07 01:38  doclaim  阅读(198)  评论(0编辑  收藏  举报