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啟動過程中載入配置檔案的簡單演示,歡迎一起留言交流學習。