先看Oracle 官方解釋
Oracle managed file (OMF)
A file that is created automatically by the Oracle database {
tagshow(event, 'server');
}" href="javascript:;" target="_self">
server when it is needed and automatically deleted when it is no longer needed. 如何判斷你的資料庫是否為支援OMF
SQL> show parameter db_create_file_dest; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_create_file_dest string |
如果Value 為空白則不支援,有值則支援。 如何設定DB 支援? 修改初始化參數檔案
[oracle@itc-test9 dbs]more initOCM.ora .......*.user_dump_dest='/disk/oracle/admin/OCM/udump' db_create_file_dest = '/disk/oracle/oradata' |
使用 ALTER SYSTEM 命令動態設定
| SQL> alter system set db_create_file_dest='/disk/oracle/oradata ; System altered. |
OMF有些用呢?我大體總結一個一下就下面幾點: 1: 建立Tablespace 是不需要寫資料檔案名稱和大小 (default 100M,自動成長,Autoextend 為unlimited)
| SQL> create tablespace omf;Tablespace created. Os: [oracle@itc-test9 datafile]pwd /disk/oracle/oradata/OCM/datafile [oracle@itc-test9 datafile]ll total 102512 -rw-r----- 1 oracle dba 104865792 Apr 29 16:13 o1_mf_omf_4zj30b2p_.dbf |
建立資料檔案屬性:
Name /disk/oracle/oradata/OCM/datafile/o1_mf_omf_4zj30b2p_.dbf Tablespace OMF Status Online File Size (KB) 102400 AutoExtend Yes Increment 100MB Maximum File Size 32767MB |
2: 向Tablespace 添加檔案是只適用add datafile 就可以了,參數如1.
| SQL> alter tablespace omf add datafile; Tablespace altered. Os [oracle@itc-test9 datafile]ll total 205024 -rw-r----- 1 oracle dba 104865792 Apr 29 16:13 o1_mf_omf_4zj30b2p_.dbf -rw-r----- 1 oracle dba 104865792 Apr 29 16:28 o1_mf_omf_4zj3wj0v_.dbf |
3: 可動態修改資料庫建立檔案的位置。
SQL> alter system set db_create_file_dest='/disk/oracle/oradata/OCM' ; System altered.不做{ tagshow(event, '%B2%E2%CA%D4'); }" href="javascript:;" target="_self">測試了,和前面一樣。 |
4: 刪除Tablespace 時,後面對應的Datafile 在OS一併刪除。
SQL> drop tablespace omf; Tablespace dropped.[oracle@itc-test9 datafile]ll total 0 |
檔案一併刪除。==================================================================================
檔案建立之後,Oracle就可以分配和命名這些檔案。Oracle OMF使用如下的命名轉換慣例。預設的檔案大小為100M,並按如下格式命名:
where
%u is a unique 8 digit code
%g is the log file group number
%t is the tablespace name
Controlfiles ora_%u.ctl
Redo Log Files ora_%g_%u.log
Datafiles ora_%t_%u.dbf
Temporary Datafilesora_%t_%u.tmp
Oracle9i OMF工具還有一個新的警告日誌訊息(alert log message),它用來告訴我們OMF資料檔案何時發生了改動。下面是關於警告日誌的一個例子。
Fri Mar 23 01:44:46 2001
CREATE TABLESPACE omf1 DATAFILE SIZE 10M AUTOEXTEND OFF
Fri Mar 23 01:44:47 2001
Created Oracle managed file /databases/ed25/OMF1/ora_omf1_xcp6rg84.dbf
Completed: CREATE TABLESPACE omf1 DATAFILE SIZE 10M AUTOEXTE
Fri Mar 23 01:45:45 2001
drop tablespace omf1
Fri Mar 23 01:45:45 2001
Deleted Oracle managed file /databases/ed25/OMF1/ora_omf_xcp6rg84.dbf
Completed: drop tablespace omf1
不過也有人認為OMF對於一個專業的DBA來說是雞肋,呵呵,沒有太大的實際意義。
下面來說明一下我認為Oracle OMF 為雞肋的原因: 1: 建立Tablespace 是不需要寫資料檔案名稱和大小作為一個DBA 在維護DB 時就應該規劃好資料檔案存放的位置,命名規則和初始大小。o1_mf_omf_4zj30b2p_.dbf 這樣的檔案你能看懂和那個Tablespace有關係嘛,更何況生產環境一般都幾十個tablesapce 以上。找對應關係也會在日常維護過程中浪費很多時間。2:向Tablespace 添加檔案是只適用add datafile 就可以了觀點如1.3:動態調整檔案存放位置如果你的資料檔案存放位置一直要改的話,還是建議你好好規劃一下。4:連帶刪除資料檔案
| SQL> drop tablespace noomf including contents and datafiles; Tablespace dropped. |
使用上面的語句一樣能安全快捷的刪除。 以上幾點我認為Oracle OMF 為雞肋,玩玩可以在生產環境使用就有點兒戲了。