oracle11g启动过程中加载配置文件

oracle指定配置文件启动,要是不指定配置文件启动的话 默认找的参数文件顺序如下:
在oracle11g中 oracle启动过程中默认会加载相应的配置文件来启动oracle服务。检查参数文件有两个,一个是spfile<ORACLE_SID>.ora文件,另一个是inti<ORACLE_SID>.ora文件。
oracle软件服务安装完成后,spfile文件和pfile文件默认会存放在/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs 这个路径下,本示例ORACLE_SID为orcl,所以spfile文件名为spfileorcl.ora,pfile文件是init.ora。
本示例spfile和pfile具体文件路径如下:

[oracle@oracle dbs]$ ll /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/init.ora ;ll /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/bak-spfileorcl.ora.ori 
-rw-r--r-- 1 oracle oinstall 3181 Sep 25 11:01 /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/init.ora
-rw-r----- 1 oracle oinstall 3584 Sep 19 11:35 /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/spfileorcl.ora

Oracle在启动到nomount状态下时,会先读取spfile文件,如果spfile不存在,再读取pfile文件。因此,只要spfile文件存在,就不需要管pfile文件是否存在了

下面示例演示环境为centos7.8 X86_64位最小化安装系统, 安装linux版本oracle-11.2.0.1.0

样例演示一:模拟Oracle在启动到nomount状态下时,让其读取pfile文件来启动oracle实例

1.1 对文件dbs/spfileorcl.ora进行改名称

cd /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs
mv spfileorcl.ora bak-spfileorcl.ora.ori

1.2 dbs/initorcl.ora文件参数默认如下:


[oracle@oracle dbs]$ egrep -v "^$|^#" init.ora 
### Change '<ORACLE_BASE>' to point to the oracle base (the one you specify at install time)
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='<ORACLE_BASE>/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='<ORACLE_BASE>/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='<ORACLE_BASE>'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'

1.3演示过程:

Oracle在启动到nomount状态下时的具体指令如下
sqlplus / as sysdba
startup ;或者startup nomount;

第一次启动报错如下:

SQL> startup ;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/initorcl.ora'
报错提示不存在文件initorcl.ora,于是修改init.ora文件为initorcl.ora

第二次启动报错如下:

SQL> startup ;
ORA-48108: invalid value given for the diagnostic_dest init.ora parameter
ORA-48140: the specified ADR Base directory does not exist [/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/<ORACLE_BASE>]
ORA-48187: specified directory does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
SQL> 
报错提示不存在路径,找不到路径,于是修改initorcl.ora文件中的<ORACLE_BASE>为实际路径 /u01/oracle/tools/oracle11g

第三次启动报错如下:

SQL> startup ;
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers 5554176 bytes
ORA-00205: error in identifying control file, check alert log for more info
提示识别不到control file文件 
提示在initorcl.ora 中 指定具体的控制文件实际路径
control_files = ("/u01/oracle/tools/oracle11g/oradata/orcl/control01.ctl", "/u01/oracle/tools/oracle11g/flash_recovery_area/orcl/control02.ctl")

第四次启动成功:

第三次启动虽然找不到控制文件,但是oracle实例已经启动,所以需要先关闭掉,然后再进行第四次启动
SQL> shutdown immediate ;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup ;
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers 5554176 bytes
Database mounted.
Database opened.

修改后的配置文件参数如下:

[oracle@oracle dbs]$ egrep -v "^$|^#" /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/initorcl.ora 
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='/u01/oracle/tools/oracle11g/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/oracle/tools/oracle11g/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/oracle/tools/oracle11g'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = ("/u01/oracle/tools/oracle11g/oradata/orcl/control01.ctl", "/u01/oracle/tools/oracle11g/flash_recovery_area/orcl/control02.ctl")
compatible ='11.2.0'

样例演示二:模拟Oracle在启动到nomount状态下时,让其直接读取spfile文件来启动oracle实例
修改文件名称:

mv bak-spfileorcl.ora.ori spfileorcl.ora
mv initorcl.ora bak-initorcl.ora.ori 

关闭oracle实例:

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

然后再次nomount启动oracle,日志提示已经启动成功,说明nomount下启动,直接通过spfile文件spfileorcl.ora启动的

SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1586708480 bytes
Fixed Size 2213736 bytes
Variable Size 922749080 bytes
Database Buffers 654311424 bytes
Redo Buffers 7434240 bytes
[oracle@oracle dbs]$ ss -lntup|grep oracle
udp UNCONN 0 0 [::1]:31518 [::]:* users:(("oracle",pid=4922,fd=16))
udp UNCONN 0 0 [::1]:42350 [::]:* users:(("oracle",pid=4924,fd=16))
udp UNCONN 0 0 [::1]:58791 [::]:* users:(("oracle",pid=4890,fd=17))
tcp LISTEN 0 128 [::]:30904 [::]:* users:(("oracle",pid=4922,fd=17))
[oracle@oracle dbs]$ 

特别说明:
本文演示当然也可以直接使用spfile创建pfile文件 然后来演示,这样就不会出现样例演示一中演示过程中启动报错了。本着学习的目的样例一演示繁琐了点

使用spfile创建pfile文件:

[oracle@oracle dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 25 12:02:34 2024
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create pfile from spfile;
File created.

生成的文件内容具体如下:

[oracle@oracle dbs]$ cat /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1/dbs/initorcl.ora 
orcl.__db_cache_size=654311424
orcl.__java_pool_size=16777216
orcl.__large_pool_size=16777216
orcl.__oracle_base='/u01/oracle/tools/oracle11g'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=637534208
orcl.__sga_target=956301312
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=251658240
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/oracle/tools/oracle11g/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oracle/tools/oracle11g/oradata/orcl/control01.ctl','/u01/oracle/tools/oracle11g/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain='oracle'
*.db_name='orcl'
*.db_recovery_file_dest='/u01/oracle/tools/oracle11g/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/u01/oracle/tools/oracle11g'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.memory_target=1580204032
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

样例演示三:指定配置文件通过挂载方式来启动oracle实例

startup pfile='/u01/oracle/interlib/initorcl.ora' mount;
SQL> startup pfile='/u01/oracle/interlib/initorcl.ora' mount;
ORACLE instance started.
Total System Global Area 1586708480 bytes
Fixed Size 2213736 bytes
Variable Size 922749080 bytes
Database Buffers 654311424 bytes
Redo Buffers 7434240 bytes
Database mounted.

以上就是oracle启动过程中加载配置文件的简单演示,欢迎一起留言交流学习。

作者:勤奋的蓝猫原文地址:https://www.cnblogs.com/ywdba668/p/18531755

%s 个评论

要回复文章请先登录注册