Oracle 12C Database File Mapping for Oracle ASM Files

eric0435發表於2018-08-13

為了理解I/O效能,你必須要詳細瞭解儲存檔案的儲存層次資訊。Oracle提供了一組動態效能視國來顯示檔案到邏輯卷中間層到實際的物理裝置之間的對映資訊。使用這些動態效能檢視,可以找到一個檔案的任何資料塊所內建的實際物理磁碟。Oracle資料庫使用一個名叫FMON的後臺程式來管理對映資訊。Oracle提供了PL/SQL dbms_storage_map包來將對映操作填充到對映檢視中。Oracle資料庫檔案對映當對映Oracle ASM檔案時不需要使用第三方的動態庫。另外,Oracle資料庫支援在所有作業系統平臺上對Oracle ASM檔案的對映。

對Oracle ASM檔案啟用檔案對映
為了啟用檔案對映,需要將引數file_mapping設定為true。資料庫例項不必關閉來設定這個引數。可以使用以下alter system語句來設定這個引數:

SQL> alter system set file_mapping=true scope=both sid='*';
System altered.

執行合適的dbms_storage_map對映過程
.在冷啟動情況下,Oracle資料庫在剛剛啟動時沒有對映操作被呼叫。可以執行dbms_storage_map.map_all過程來為資料庫相關的整個I/O子系統來構建對映資訊。例如,下面的命令構建對映資訊並且提供10000事件:

SQL> execute dbms_storage_map.map_all(10000);
PL/SQL procedure successfully completed.

.在暖啟動情況下,Oracle資料庫已經構建了對映資訊,可以選擇執行dbms_storage_map.map_save過程來將對映資訊儲存在資料字典中。預設情況下這個過程將被dbms_storage_map.map_all過程呼叫,這將強制SGA中的所有對映資訊被重新整理到磁碟。預設情況下dbms_storage_map.map_save過程將被dbms_storage_map.map_all()。在重啟資料庫後,使用dbms_storage_map.restore()過程來還原對映資訊到SGA中。如果需要,dbms_storage_map.map_all()可以用來重新整理對映資訊。

由dbms_storage_map包生成的對映資訊會被捕獲到動態效能檢視中。這些檢視包括v$map_comp_list,v$map_element,v$map_ext_element,v$map_file,v$map_file_extent,v$map_file_io_stack,v$map_library與v$map_subelement。
可以使用v$map_file來查詢檔案對映資訊:

SQL> select file_map_idx, substr(file_name,1,45), file_type, file_structure from v$map_file;
FILE_MAP_IDX SUBSTR(FILE_NAME,1,45)                                                                     FILE_TYPE   FILE_STRU
------------ ------------------------------------------------------------------------------------------ ----------- ---------
           0 +DATA/CS/DATAFILE/system.272.970601831                                                     DATAFILE    ASMFILE
           1 +DATA/CS/DATAFILE/sysaux.273.970601881                                                     DATAFILE    ASMFILE
           2 +DATA/CS/DATAFILE/undotbs1.274.970601905                                                   DATAFILE    ASMFILE
           3 +DATA/CS/4700A987085B3DFAE05387E5E50A8C7B/DAT                                              DATAFILE    ASMFILE
           4 +DATA/CS/4700A987085B3DFAE05387E5E50A8C7B/DAT                                              DATAFILE    ASMFILE
           5 +DATA/CS/DATAFILE/users.275.970601909                                                      DATAFILE    ASMFILE
           6 +DATA/CS/4700A987085B3DFAE05387E5E50A8C7B/DAT                                              DATAFILE    ASMFILE
           7 +DATA/CS/DATAFILE/undotbs2.284.970602381                                                   DATAFILE    ASMFILE
           8 +DATA/CS/DATAFILE/test.326.976211663                                                       DATAFILE    ASMFILE
           9 +DATA/CS/DATAFILE/jy.331.976296525                                                         DATAFILE    ASMFILE
          10 +DATA/CS/6C61AD7B443C2CD2E053BE828A0A2A74/DAT                                              DATAFILE    ASMFILE
          11 +DATA/CS/6C61AD7B443C2CD2E053BE828A0A2A74/DAT                                              DATAFILE    ASMFILE
          12 +DATA/CS/6C61AD7B443C2CD2E053BE828A0A2A74/DAT                                              DATAFILE    ASMFILE
          13 +DATA/CS/ONLINELOG/group_2.277.970601985                                                   LOGFILE     ASMFILE
          14 +DATA/CS/ONLINELOG/group_1.278.970601985                                                   LOGFILE     ASMFILE
          15 +DATA/CS/ONLINELOG/group_3.285.970602759                                                   LOGFILE     ASMFILE
          16 +DATA/CS/ONLINELOG/group_4.286.970602761                                                   LOGFILE     ASMFILE
          17 +DATA/CS/ONLINELOG/redo05.log                                                              LOGFILE     ASMFILE
          18 +DATA/CS/ONLINELOG/redo06.log                                                              LOGFILE     ASMFILE
          19 +DATA/CS/ONLINELOG/redo07.log                                                              LOGFILE     ASMFILE
          20 +DATA/CS/ONLINELOG/redo08.log                                                              LOGFILE     ASMFILE
          21 +DATA/CS/ONLINELOG/redo09.log                                                              LOGFILE     ASMFILE
          22 +DATA/CS/ONLINELOG/redo10.log                                                              LOGFILE     ASMFILE
          23 +DATA/CS/TEMPFILE/temp.279.970602003                                                       TEMPFILE    ASMFILE
          24 +DATA/CS/67369AA1C9AA3E71E053BE828A0A8262/TEM                                              TEMPFILE    ASMFILE
          25 +DATA/CS/6C61AD7B443C2CD2E053BE828A0A2A74/TEM                                              TEMPFILE    ASMFILE
          26 +DATA/arch/1_222_970601983.dbf                                                             ARCHIVEFILE ASMFILE
          27 +DATA/arch/1_223_970601983.dbf                                                             ARCHIVEFILE ASMFILE
          28 +DATA/arch/2_277_970601983.dbf                                                             ARCHIVEFILE ASMFILE
          29 +DATA/arch/2_278_970601983.dbf                                                             ARCHIVEFILE ASMFILE
          30 +DATA/arch/2_279_970601983.dbf                                                             ARCHIVEFILE ASMFILE
          31 +DATA/CS/CONTROLFILE/current.276.970601979                                                 CONTROLFILE ASMFILE
31 rows selected.

可以使用dbms_storage_map PL/SQL包中的過程來控制對映操作。例如,可以使用dbms_storage_map.map_object過程透過指定物件名,所有者與型別來對資料庫物件來構建對映資訊。在dbms_storage_map.map_object過程執行之後,那麼可以透過查詢map_object檢視來查詢對映資訊

SQL> execute dbms_storage_map.map_object('T1','C##TEST','TABLE');
PL/SQL procedure successfully completed.
SQL> select io.object_name o_name, io.object_owner o_owner, io.object_type o_type,
  2  mf.file_name, me.elem_name, io.depth,
  3  (sum(io.cu_size * (io.num_cu - decode(io.parity_period, 0, 0,
  4  trunc(io.num_cu / io.parity_period)))) / 2) o_size
  5  from map_object io, v$map_element me, v$map_file mf
  6  where io.object_name = 'T1'
  7  and io.object_owner = 'C##TEST'
and io.object_type = 'TABLE'
  8    9  and me.elem_idx = io.elem_idx
 10  and mf.file_map_idx = io.file_map_idx
 11  group by io.elem_idx, io.file_map_idx, me.elem_name, mf.file_name, io.depth,
 12  io.object_name, io.object_owner, io.object_type
 13  order by io.depth;
O_NAME               O_OWNER              O_TYP FILE_NAME                                          ELEM_NAME                 DEPTH     O_SIZE
-------------------- -------------------- ----- -------------------------------------------------- -------------------- ---------- ----------
T1                   C##TEST              TABLE +DATA/CS/DATAFILE/users.275.970601909              +/dev/asmdisk04               0         64


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2199958/,如需轉載,請註明出處,否則將追究法律責任。

相關文章