溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Oracle修改控制文件路徑的方法

發(fā)布時(shí)間:2021-09-15 13:38:18 來源:億速云 閱讀:211 作者:chen 欄目:關(guān)系型數(shù)據(jù)庫

這篇文章主要介紹“Oracle修改控制文件路徑的方法”,在日常操作中,相信很多人在Oracle修改控制文件路徑的方法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”O(jiān)racle修改控制文件路徑的方法”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

控制文件----二進(jìn)制文件,在數(shù)據(jù)庫啟動(dòng)和數(shù)據(jù)庫運(yùn)行中有著巨大的作用
參數(shù)文件----pfile             可文本編輯
               spfile             二進(jìn)制文件,不可文本編輯
下面介紹兩種修改控制文件兩種方法
################ 1 #####################

如果在startup里指定了pfile=''的話,Oracle將從你指定的文件作為啟動(dòng)參數(shù)文件,如果是沒有指定pfile的話,Oracle會(huì)先去默認(rèn)目錄($ORACLE_HOME/)下找spfileSID.ora,如果沒有找到,則找spfile.ora,如果還是沒有,找initSID.ora,這個(gè)就是以前的靜態(tài)參數(shù)文件了,如果沒有則找init.ora;如果沒有找到的話,這時(shí)候,啟動(dòng)就會(huì)有,找不到參數(shù)文件的錯(cuò)誤,同時(shí)會(huì)動(dòng)態(tài)注冊實(shí)例名到監(jiān)聽服務(wù)里。

把對應(yīng)的controlfile移動(dòng)到目標(biāo)路徑下,由于control01.ctl的路徑?jīng)]有發(fā)生變動(dòng)所以mv:提示不影響操作

  1. [oracle@sink dbs]$ mv /u01/app/oracle/oradata/sink/control01.ctl /u01/app/oracle/oradata/sink/control01.ctl

  2. mv: `/u01/app/oracle/oradata/sink/control01.ctl' and `/u01/app/oracle/oradata/sink/control01.ctl' are the same file

  3. [oracle@sink dbs]$ mv /u01/app/oracle/fast_recovery_area/sink/control02.ctl /u01/app/oracle/oradata/sink/control02.ctl

一定要先關(guān)閉數(shù)據(jù)庫之后才移動(dòng)控制文件,不然會(huì)后面會(huì)出一系列錯(cuò)誤

  1. 13:35:03 SYS @ sink >shutdown immediate;

  2. Database closed.

  3. Database dismounted.

  4. ORACLE instance shut down.

  5. 13:36:03 SYS @ sink >

到$ORACLE_HOME/dbs路徑下vim編輯控制文件路徑   然后    :wq  保存退出(w 保存 q 退出  q! 強(qiáng)制退出)

  1. [oracle@sink dbs]$ pwd

  2. /u01/app/oracle/product/11.2.0/dbhome_1/dbs

  3. [oracle@sink dbs]$ vim initsink.ora


  4. *.audit_file_dest='/u01/app/oracle/admin/sink/adump'

  5. *.audit_trail='db'

  6. *.compatible='11.2.0.4.0'

  7. *.control_files='/u01/app/oracle/oradata/sink/control01.ctl','/u01/app/oracle/oradata/sink/control02.ctl'

  8. *.db_block_size=8192

  9. *.db_create_file_dest='+DATA'

剛我們修改了pfile但是spfile還沒有改動(dòng),所以先指定使用pfile啟動(dòng)數(shù)據(jù)庫

  1. 13:41:29 SYS @ sink >startup pfile=$ORACLE_HOME/dbs/initsink.ora

  2. ORACLE instance started.


  3. Total System Global Area  835104768 bytes

  4. Fixed Size            2257840 bytes

  5. Variable Size          553651280 bytes

  6. Database Buffers      276824064 bytes

  7. Redo Buffers            2371584 bytes

  8. Database mounted.

  9. Database opened.

  10. 13:42:13 SYS @ sink >

查看此時(shí)的controlifle的路徑信息,好了,沒錯(cuò),那么這么pifle是成功的

  1. 13:42:13 SYS @ sink >col name for a55

  2. 13:43:50 SYS @ sink >select name from v$controlfile;


  3. NAME

  4. -------------------------------------------------------

  5. /u01/app/oracle/oradata/sink/control01.ctl

  6. /u01/app/oracle/oradata/sink/control02.ctl


  7. 2 rows selected.


  8. Elapsed: 00:00:00.00

  9. 13:44:01 SYS @ sink >

用pfile生成spifle,因?yàn)閜file成功了,但是spifle還沒有被修改,還沒有生效,默認(rèn)以spfile啟動(dòng),所以此操作合理


  1. 13:44:01 SYS @ sink >create spfile from pfile;


  2. File created.


  3. Elapsed: 00:00:00.02

  4. 13:46:59 SYS @ sink >

PS : 如果數(shù)據(jù)庫以spfile啟動(dòng),然后你在執(zhí)行 create spfile from pfile 則會(huì)報(bào)錯(cuò)
      ORA-32002: cannot create SPFILE already being used by the instance

數(shù)據(jù)庫正常關(guān)閉,然后,startup 不指定任何參數(shù)而數(shù)據(jù)庫又存在spfile,所以oracle 默認(rèn) 以 spfile啟動(dòng)

  1. 13:46:59 SYS @ sink >shutdown immediate;

  2. Database closed.

  3. Database dismounted.

  4. ORACLE instance shut down.

  5. 13:52:08 SYS @ sink >startup

  6. ORACLE instance started.


  7. Total System Global Area  835104768 bytes

  8. Fixed Size            2257840 bytes

  9. Variable Size          553651280 bytes

  10. Database Buffers      276824064 bytes

  11. Redo Buffers            2371584 bytes

  12. Database mounted.

  13. Database opened.

  14. 13:52:22 SYS @ sink >

啟動(dòng)后,查詢控制文件路徑,發(fā)現(xiàn)成功轉(zhuǎn)移,故修改控制文件路徑成功

  1. 13:52:22 SYS @ sink >select name from v$controlfile;


  2. NAME

  3. -------------------------------------------------------

  4. /u01/app/oracle/oradata/sink/control01.ctl

  5. /u01/app/oracle/oradata/sink/control02.ctl


  6. 2 rows selected.


  7. Elapsed: 00:00:00.00

  8. 13:53:51 SYS @ sink >

到此,關(guān)于“Oracle修改控制文件路徑的方法”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI