共計 3075 個字符,預(yù)計需要花費 8 分鐘才能閱讀完成。
這篇文章主要介紹“Oracle 修改控制文件路徑的方法”,在日常操作中,相信很多人在 Oracle 修改控制文件路徑的方法問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”O(jiān)racle 修改控制文件路徑的方法”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學(xué)習(xí)吧!
控制文件 —- 二進制文件,在數(shù)據(jù)庫啟動和數(shù)據(jù)庫運行中有著巨大的作用
參數(shù)文件 —-pfile 可文本編輯
spfile 二進制文件,不可文本編輯
下面介紹兩種修改控制文件兩種方法
################ 1 #####################
如果在 startup 里指定了 pfile= 的話,Oracle 將從你指定的文件作為啟動參數(shù)文件,如果是沒有指定 pfile 的話,Oracle 會先去默認目錄 ($ORACLE_HOME/) 下找 spfileSID.ora, 如果沒有找到,則找 spfile.ora, 如果還是沒有,找 initSID.ora, 這個就是以前的靜態(tài)參數(shù)文件了,如果沒有則找 init.ora; 如果沒有找到的話,這時候,啟動就會有,找不到參數(shù)文件的錯誤,同時會動態(tài)注冊實例名到監(jiān)聽服務(wù)里。
把對應(yīng)的 controlfile 移動到目標路徑下,由于 control01.ctl 的路徑?jīng)]有發(fā)生變動所以 mv: 提示不影響操作
[oracle@sink dbs]$ mv /u01/app/oracle/oradata/sink/control01.ctl /u01/app/oracle/oradata/sink/control01.ctl
mv: `/u01/app/oracle/oradata/sink/control01.ctl and `/u01/app/oracle/oradata/sink/control01.ctl are the same file
[oracle@sink dbs]$ mv /u01/app/oracle/fast_recovery_area/sink/control02.ctl /u01/app/oracle/oradata/sink/control02.ctl
一定要先關(guān)閉數(shù)據(jù)庫之后才移動控制文件,不然會后面會出一系列錯誤
13:35:03 SYS @ sink shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
13:36:03 SYS @ sink
到 $ORACLE_HOME/dbs 路徑下 vim 編輯控制文件路徑 然后 :wq 保存退出(w 保存 q 退出 q! 強制退出)
[oracle@sink dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@sink dbs]$ vim initsink.ora
*.audit_file_dest= /u01/app/oracle/admin/sink/adump
*.audit_trail= db
*.compatible= 11.2.0.4.0
*.control_files= /u01/app/oracle/oradata/sink/control01.ctl , /u01/app/oracle/oradata/sink/control02.ctl
*.db_block_size=8192
*.db_create_file_dest= +DATA
剛我們修改了 pfile 但是 spfile 還沒有改動,所以先指定使用 pfile 啟動數(shù)據(jù)庫
13:41:29 SYS @ sink startup pfile=$ORACLE_HOME/dbs/initsink.ora
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 553651280 bytes
Database Buffers 276824064 bytes
Redo Buffers 2371584 bytes
Database mounted.
Database opened.
13:42:13 SYS @ sink
查看此時的 controlifle 的路徑信息,好了,沒錯,那么這么 pifle 是成功的
13:42:13 SYS @ sink col name for a55
13:43:50 SYS @ sink select name from v$controlfile;
NAME
——————————————————-
/u01/app/oracle/oradata/sink/control01.ctl
/u01/app/oracle/oradata/sink/control02.ctl
2 rows selected.
Elapsed: 00:00:00.00
13:44:01 SYS @ sink
用 pfile 生成 spifle,因為 pfile 成功了,但是 spifle 還沒有被修改,還沒有生效,默認以 spfile 啟動,所以此操作合理
13:44:01 SYS @ sink create spfile from pfile;
File created.
Elapsed: 00:00:00.02
13:46:59 SYS @ sink
PS : 如果數(shù)據(jù)庫以 spfile 啟動,然后你在執(zhí)行 create spfile from pfile 則會報錯
ORA-32002: cannot create SPFILE already being used by the instance
數(shù)據(jù)庫正常關(guān)閉,然后,startup 不指定任何參數(shù)而數(shù)據(jù)庫又存在 spfile,所以 oracle 默認 以 spfile 啟動
13:46:59 SYS @ sink shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
13:52:08 SYS @ sink startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 553651280 bytes
Database Buffers 276824064 bytes
Redo Buffers 2371584 bytes
Database mounted.
Database opened.
13:52:22 SYS @ sink
啟動后,查詢控制文件路徑,發(fā)現(xiàn)成功轉(zhuǎn)移,故修改控制文件路徑成功
13:52:22 SYS @ sink select name from v$controlfile;
NAME
——————————————————-
/u01/app/oracle/oradata/sink/control01.ctl
/u01/app/oracle/oradata/sink/control02.ctl
2 rows selected.
Elapsed: 00:00:00.00
13:53:51 SYS @ sink
到此,關(guān)于“Oracle 修改控制文件路徑的方法”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>