Oracle控制檔案多工時要注意的問題

來源:互聯網
上載者:User

Oracle控制檔案多工時要注意的問題
由於控制檔案對於資料庫的重要性很高,所以通常在dbca建庫以後,都會對控制檔案多工。如,在Oracle10g中,預設控制檔案有3份,內容完全一致,通常位於$ORACLE_BASE/oradata/SID/下面,名字為control01.ctl,control02.ctl,control03.ctl,而到了11g,預設只有2個份,一個位於$ORACLE_BASE/oradata/SID/下面,名字為control01.ctl,另一份位於$ORACLE_BASE/fast_recovery_area/SID/下面,名字為control02.ctl。當然了,我說的都是預設安裝的情況下,完全可以通過在pfile中自訂不同的路徑。有時候,可能會碰到某些庫只有1個控制檔案,沒有鏡像,即沒有對控制檔案多工,顯然這是不太好的,需要為資料庫增加控制檔案的鏡像檔案,下面來做個測試

----------------------------華麗麗的分割線----------------------------

Oracle控制檔案的多工

Oracle 單一實例 從32位 遷移到 64位 方法 

在CentOS 6.4下安裝Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虛擬機器中安裝步驟

Debian 下 安裝 Oracle 11g XE R2

Oracle匯入匯出expdp IMPDP詳解

Oracle 10g expdp匯出報錯ORA-4031的解決方案

----------------------------華麗麗的分割線---------------------------- --啟動資料庫,查看當前控制檔案資訊SQL> startupORACLE instance started. Total System Global Area  835104768 bytesFixed Size                  2232960 bytesVariable Size             507514240 bytesDatabase Buffers          322961408 bytesRedo Buffers                2396160 bytesDatabase mounted.Database opened.SQL> show parameter control_file NAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time        integer     7control_files                        string      /u01/app/oracle/oradata/zlm11g                                                 /control01.ctl, /u01/app/oracl                                                 e/fast_recovery_area/zlm11g/co                                                 ntrol02.ctl 預設裝完庫以後,已經有2個控制檔案,其中,control02.ctl是鏡像 --查看control_file參數是否可以線上修改SQL> col name for a20SQL> select name,issys_modifiable from v$parameter where name='control_files'; NAME                 ISSYS_MOD-------------------- ---------control_files        FALSE 顯然,FALSE表示無法線上修改該參數,那麼多工控制檔案就意味著要重啟資料庫了 --建立pfileSQL> create pfile from spfile; File created. --關閉資料庫並修改pfile,增加控制檔案鏡像(在control_files參數後面添加鏡像的位置、檔案名稱)SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> ! zlm11g.__db_cache_size=322961408zlm11g.__java_pool_size=4194304zlm11g.__large_pool_size=4194304zlm11g.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environmentzlm11g.__pga_aggregate_target=335544320zlm11g.__sga_target=503316480zlm11g.__shared_io_pool_size=0zlm11g.__shared_pool_size=163577856zlm11g.__streams_pool_size=0*.audit_file_dest='/u01/app/oracle/admin/zlm11g/adump'*.audit_trail='db'*.compatible='11.2.0.0.0'*.control_files='/u01/app/oracle/oradata/zlm11g/control01.ctl','/u01/app/oracle/fast_recovery_area/zlm11g/control02.ctl','/u01/control03.ctl'--紅色部分為新增的控制檔案鏡像*.db_block_size=8192zlm11g.db_create_file_dest='/u01/app/oracle/oradata/zlm11g/'*.db_domain=''*.db_name='zlm11g'*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'*.db_recovery_file_dest_size=4322230272*.diagnostic_dest='/u01/app/oracle'*.dispatchers='(PROTOCOL=TCP) (SERVICE=zlm11gXDB)'*.log_archive_format='%t_%s_%r.dbf'*.memory_target=838860800*.memory_target=838860800*.open_cursors=300"/u01/app/oracle/product/11.2.0/db_1/dbs/initzlm11g.ora" 27L, 1048C written --在OS層級複製一份控制檔案鏡像[oracle@zlm ~]$ cp $ORACLE_BASE/oradata/zlm11g/control01.ctl /u01/control03.ctl
[oracle@zlm ~]$ cd /u01[oracle@zlm u01]$ lsapp  bak  control03.ctl  dave.trc  expdp  rman.log  rman.trc[oracle@zlm u01]$ exitexit --用pfile啟動資料庫SQL> startup pfile=$ORACLE_HOME/dbs/initzlm11g.oraORACLE instance started. Total System Global Area  835104768 bytesFixed Size                  2232960 bytesVariable Size             507514240 bytesDatabase Buffers          322961408 bytesRedo Buffers                2396160 bytesDatabase mounted.Database opened.SQL> show parameter control_files NAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------control_files                        string      /u01/app/oracle/oradata/zlm11g                                                 /control01.ctl, /u01/app/oracl                                                 e/fast_recovery_area/zlm11g/co                                                 ntrol02.ctl, /u01/control03.ct 新增的鏡像控制檔案已經生效,現在有3個控制檔案了,一個原始檔案,2路複用 --建立新的spfile                                                 lSQL> create spfile from pfile; File created. --關庫並用spfile重新啟動SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started. Total System Global Area  835104768 bytesFixed Size                  2232960 bytesVariable Size             507514240 bytesDatabase Buffers          322961408 bytesRedo Buffers                2396160 bytesDatabase mounted.Database opened.SQL> show parameter control_files NAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------control_files                        string      /u01/app/oracle/oradata/zlm11g                                                 /control01.ctl, /u01/app/oracl                                                 e/fast_recovery_area/zlm11g/co                                                 ntrol02.ctl, /u01/control03.ct 至此,已經完成了對控制檔案的複用,從2份增加到了3份,注意,是必須停庫的。下面嘗試用另一種方式來增加控制檔案鏡像,採用spfile動態修改+備份控制檔案的方式,看是否可行                                       --修改spfile,添加第4個控制檔案SQL> alter system set control_files='/u01/app/oracle/oradata/zlm11g/control01.ctl,/u01/oracle/fast_recovery_area/zlm11g/control02.ctl,/u01/control03.ctl,/u01/control04.ctl' scope=spfile; System altered. --備份當前控制檔案並產生鏡像檔案SQL> alter database backup controlfile to '/u01/control04.ctl'; Database altered. SQL> alter database backup controlfile to trace as '/u01/control.bak'; Database altered. 注意這兩條命令的區別,前面的語句產生的是binary的控制檔案,而後面的語句是產生可讀的trace檔案(通常用於重建控制檔案)

 

更多詳情見請繼續閱讀下一頁的精彩內容:

  • 1
  • 2
  • 3
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.