Oracle 12c ASM專題|Flex磁碟組到底有多Fexible?

沃趣科技發表於2017-09-08

原文連結

譯者  周天鵬 


## Flex Disk Group屬性
前三部分我分享了關於ASM Flex Disk Group、File Group和Quota Group如何強制對儲存空間進行限制的實驗結果。但是我還沒有測試修改磁碟組屬性會產生什麼效果。我所關心的屬性都是資料保護級別相關的,正如官方文件中所討論的那樣-Automatic Storage Management Administrator’s Guide ()。除了保護模式相關的屬性之外當然也有其他的一些磁碟組屬性,但是本次實驗並不涉及。

一個Flex冗餘度的ASM磁碟組可以被設定為任意保護模式(3副本、2副本、無保護),預設情況下,Flex冗餘度的磁碟組使用2副本模式。不像其他的磁碟組,你可以改變Flex磁碟組內某個單獨的DB或PDB的保護模式。這裡最好給大家舉個例子:

點選(此處)摺疊或開啟

  1. SQL> select filegroup_number,name,guid from v$asm_filegroup

  2. FILEGROUP_NUMBER NAME GUID
  3. ---------------- -------------------- --------------------------------
  4.                0 DEFAULT_FILEGROUP
  5.                1 CDB_CDB$ROOT 4700A987085A3DFAE05387E5E50A8C7B
  6.                2 CDB_PDB$SEED 536DF51E8E28221BE0534764A8C0FD81
  7.                3 PDB1 537B677EF8DA0F1AE0534764A8C05729
  8.                4 ORCL_CDB$ROOT 4700A987085A3DFAE05387E5E50A8C7B
  9.                5 ORCL_PDB$SEED 537E63B952183748E0534764A8C09A7F
  10.                6 PDB1_0001 537EB5B87E62586EE0534764A8C05530

  11. 7 rows selected.
 上面的列表展示了我的ASM例項中的檔案組資訊。本章將要修改6號檔案組(PDB1_0001)的屬性,該檔案組存放在Flex磁碟組上。知道哪些檔案屬於這個檔案組非常重要。這裡是一個列表:

點選(此處)摺疊或開啟

  1. SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
  2.   2 from v$asm_file where filegroup_number = 6;
  3.   
  4. FILE_NUMBER BYTES SPACE TYPE REDUNDANCY REDUNDANCY_LOWERED STRIPED REMIRROR
  5. 309 104865792 218103808 DATAFILE MIRROR U COARSE N
  6. 310 262152192 541065216 DATAFILE MIRROR U COARSE N
  7. 311 419438592 859832320 DATAFILE MIRROR U COARSE N
  8. 312 67117056 142606336 TEMPFILE MIRROR U COARSE N
 官方文件說的沒錯,存放在Flex磁碟組上的資料檔案預設冗餘度是2副本。

## 檔案組屬性
在磁碟組內部改變冗餘度和其他一些屬性都依賴於你擁有檔案組。檔案組的屬性可以透過sql或者asmcmd來進行檢視。如下:

點選(此處)摺疊或開啟

  1. ASMCMD> lsfg -G flex --filegroup PDB1_0001
  2. File Group Disk Group Property Value File Type
  3. PDB1_0001 FLEX PRIORITY MEDIUM
  4. PDB1_0001 FLEX STRIPING COARSE CONTAINER
  5. PDB1_0001 FLEX STRIPING FINE CONTROLFILE
  6. PDB1_0001 FLEX REDUNDANCY MIRROR DATAFILE
  7. PDB1_0001 FLEX STRIPING COARSE DATAFILE
  8. PDB1_0001 FLEX REDUNDANCY MIRROR ONLINELOG
  9. PDB1_0001 FLEX STRIPING COARSE ONLINELOG
  10. PDB1_0001 FLEX REDUNDANCY MIRROR ARCHIVELOG
  11. PDB1_0001 FLEX STRIPING COARSE ARCHIVELOG
  12. PDB1_0001 FLEX REDUNDANCY MIRROR TEMPFILE
  13. PDB1_0001 FLEX STRIPING COARSE TEMPFILE
  14. PDB1_0001 FLEX REDUNDANCY MIRROR BACKUPSET
  15. PDB1_0001 FLEX STRIPING COARSE BACKUPSET
  16. PDB1_0001 FLEX REDUNDANCY MIRROR PARAMETERFILE
  17. PDB1_0001 FLEX STRIPING COARSE PARAMETERFILE
  18. PDB1_0001 FLEX REDUNDANCY MIRROR DATAGUARDCONFIG
  19. PDB1_0001 FLEX STRIPING COARSE DATAGUARDCONFIG
  20. PDB1_0001 FLEX REDUNDANCY MIRROR CHANGETRACKING
  21. PDB1_0001 FLEX STRIPING COARSE CHANGETRACKING
  22. PDB1_0001 FLEX REDUNDANCY MIRROR FLASHBACK
  23. PDB1_0001 FLEX STRIPING COARSE FLASHBACK
  24. PDB1_0001 FLEX REDUNDANCY MIRROR DUMPSET
  25. PDB1_0001 FLEX STRIPING COARSE DUMPSET
  26. PDB1_0001 FLEX REDUNDANCY MIRROR AUTOBACKUP
  27. PDB1_0001 FLEX STRIPING COARSE AUTOBACKUP
  28. PDB1_0001 FLEX REDUNDANCY MIRROR VOTINGFILE
  29. PDB1_0001 FLEX STRIPING COARSE VOTINGFILE
  30. PDB1_0001 FLEX REDUNDANCY MIRROR OCRFILE
  31. PDB1_0001 FLEX STRIPING COARSE OCRFILE
  32. PDB1_0001 FLEX REDUNDANCY MIRROR ASMVOL
  33. PDB1_0001 FLEX STRIPING COARSE ASMVOL
  34. PDB1_0001 FLEX REDUNDANCY MIRROR ASMVDRL
  35. PDB1_0001 FLEX STRIPING COARSE ASMVDRL
  36. PDB1_0001 FLEX REDUNDANCY MIRROR OCRBACKUP
  37. PDB1_0001 FLEX STRIPING COARSE OCRBACKUP
  38. PDB1_0001 FLEX REDUNDANCY MIRROR FLASHFILE
  39. PDB1_0001 FLEX STRIPING COARSE FLASHFILE
  40. PDB1_0001 FLEX REDUNDANCY MIRROR XTRANSPORT BACKUPSET
  41. PDB1_0001 FLEX STRIPING COARSE XTRANSPORT BACKUPSET
  42. PDB1_0001 FLEX REDUNDANCY MIRROR AUDIT_SPILLFILES
  43. PDB1_0001 FLEX STRIPING COARSE AUDIT_SPILLFILES
  44. PDB1_0001 FLEX REDUNDANCY MIRROR INCR XTRANSPORT BACKUPSET
  45. PDB1_0001 FLEX STRIPING COARSE INCR XTRANSPORT BACKUPSET
  46. PDB1_0001 FLEX REDUNDANCY MIRROR KEY_STORE
  47. PDB1_0001 FLEX STRIPING COARSE KEY_STORE
  48. PDB1_0001 FLEX REDUNDANCY MIRROR AUTOLOGIN_KEY_STORE
  49. PDB1_0001 FLEX STRIPING COARSE AUTOLOGIN_KEY_STORE
  50. PDB1_0001 FLEX REDUNDANCY MIRROR CONTAINER
  51. PDB1_0001 FLEX REDUNDANCY HIGH CONTROLFILE
  52. ASMCMD>
 輸出包含兩大類屬性:冗餘和條帶化。我真正關心的只有冗餘度,而且我也沒接觸過條帶化相關的屬性。查了下官方文件 ASM Administrator’s guide(),
對條帶化屬性的解釋如下:
> 這是檔案型別的屬性,僅需為每個檔案型別設定。一般使用預設值就夠了,不需要人為改變。

看到這個我很高興。

使用sql依然可以達到這種效果,這裡是等價的輸出:

點選(此處)摺疊或開啟

  1. SQL> select file_type, name, value from v$asm_filegroup_property where filegroup_number = 6;

  2. FILE_TYPE NAME VALUE
  3. ------------------------------ ------------------------------ ------------------------------
  4.                                PRIORITY MEDIUM
  5. CONTROLFILE REDUNDANCY HIGH
  6. CONTROLFILE STRIPING FINE
  7. DATAFILE REDUNDANCY MIRROR
  8. DATAFILE STRIPING COARSE
  9. ONLINELOG REDUNDANCY MIRROR
  10. ONLINELOG STRIPING COARSE
  11. ARCHIVELOG REDUNDANCY MIRROR
  12. ARCHIVELOG STRIPING COARSE
  13. TEMPFILE REDUNDANCY MIRROR
  14. TEMPFILE STRIPING COARSE
  15. BACKUPSET REDUNDANCY MIRROR
  16. BACKUPSET STRIPING COARSE
  17. PARAMETERFILE REDUNDANCY MIRROR
  18. PARAMETERFILE STRIPING COARSE
  19. DATAGUARDCONFIG REDUNDANCY MIRROR
  20. DATAGUARDCONFIG STRIPING COARSE
  21. CHANGETRACKING REDUNDANCY MIRROR
  22. CHANGETRACKING STRIPING COARSE
  23. FLASHBACK REDUNDANCY MIRROR
  24. FLASHBACK STRIPING COARSE
  25. DUMPSET REDUNDANCY MIRROR
  26. DUMPSET STRIPING COARSE
  27. AUTOBACKUP REDUNDANCY MIRROR
  28. AUTOBACKUP STRIPING COARSE
  29. VOTINGFILE REDUNDANCY MIRROR
  30. VOTINGFILE STRIPING COARSE
  31. OCRFILE REDUNDANCY MIRROR
  32. OCRFILE STRIPING COARSE
  33. ASMVOL REDUNDANCY MIRROR
  34. ASMVOL STRIPING COARSE
  35. ASMVDRL REDUNDANCY MIRROR
  36. ASMVDRL STRIPING COARSE
  37. OCRBACKUP REDUNDANCY MIRROR
  38. OCRBACKUP STRIPING COARSE
  39. FLASHFILE REDUNDANCY MIRROR
  40. FLASHFILE STRIPING COARSE
  41. XTRANSPORT BACKUPSET REDUNDANCY MIRROR
  42. XTRANSPORT BACKUPSET STRIPING COARSE
  43. AUDIT_SPILLFILES REDUNDANCY MIRROR
  44. AUDIT_SPILLFILES STRIPING COARSE
  45. INCR XTRANSPORT BACKUPSET REDUNDANCY MIRROR
  46. INCR XTRANSPORT BACKUPSET STRIPING COARSE
  47. KEY_STORE REDUNDANCY MIRROR
  48. KEY_STORE STRIPING COARSE
  49. AUTOLOGIN_KEY_STORE REDUNDANCY MIRROR
  50. AUTOLOGIN_KEY_STORE STRIPING COARSE
  51. CONTAINER REDUNDANCY MIRROR
  52. CONTAINER STRIPING COARSE

  53. 49 rows selected.
 除了v$asm_file檢視,你們也可以查v$asm_filegroup_file這個檢視:

點選(此處)摺疊或開啟

  1. SQL> select filegroup_number, file_number, incarnation
  2.   2 from v$asm_filegroup_file
  3.   3 where filegroup_number = 6
  4.   4 order by file_number;

  5. FILEGROUP_NUMBER FILE_NUMBER INCARNATION
  6. ---------------- ----------- -----------
  7.                6 309 948464269
  8.                6 310 948464269
  9.                6 311 948464269
  10.                6 312 948464283

  11. SQL>
 FILE_NUMBER欄位和INCARNATION可以被關聯上v$asm_file。

回到主題上:我想把冗餘度從normal轉為high,但該操作僅對6號檔案組有效。v$asm_file檢視中有一些大小、型別、當前冗餘度、條帶級別和是否正在re-mirror的資訊。在進行操作之前,我們先看下里面的內容:

點選(此處)摺疊或開啟

  1. SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
  2.   2 from v$asm_file where filegroup_number = 6;

  3. FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
  4. ----------- ---------- ---------- -------------------- ------ - ------ -
  5.         309 104865792 218103808 DATAFILE MIRROR U COARSE N
  6.         310 262152192 541065216 DATAFILE MIRROR U COARSE N
  7.         311 419438592 859832320 DATAFILE MIRROR U COARSE N
  8.         312 67117056 142606336 TEMPFILE MIRROR U COARSE N

  9. SQL>
 檔案309和312使用mirror的冗餘度(2副本,也就是normal冗餘)。讓我們嘗試改變這個冗餘度,看看會發生什麼。

## 修改資料檔案冗餘度
這裡真正的操作才開始。Automatic Storage Management Administrator’s Guide的Administering Oracle ASM Disk Groups章節的Managing Oracle ASM Flex Disk Groups這個部分()
說了所有檔案組的屬性都可以被修改。讓我們用文件上的例子,來改變6號檔案組的屬性:

點選(此處)摺疊或開啟

  1. SQL> alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy'='high';

  2. Diskgroup altered.
 這條命令(其他改變儲存屬性的操作)必須以SYSASM方式登陸ASM例項才可以執行。從DB例項執行會報如下錯誤:

點選(此處)摺疊或開啟

  1. SQL> alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy' = 'high';

  2. Error starting at line : 1 in command -
  3. alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy' = 'high'
  4. Error report -
  5. ORA-15000: command disallowed by current instance type
  6. 15000. 00000 - "command disallowed by current instance type"
  7. *Cause: The user has issued a command to a conventional RDBMS instance
  8.            that is only appropriate for an ASM instance. Alternatively, the
  9.            user has issued a command to an ASM instance that is only
  10.            appropriate for an RDBMS instance.
  11. *Action: Connect to the correct instance type and re-issue the command.
  12. SQL>
 命令結束後,資料檔案立刻開始了re-mirror操作。在re-mirror的過程中(即remirror欄位為Y),冗餘度依然為MIRROR。只有當re-mirror操作完成後(即remirror欄位為N),冗餘度才變為high。注意:312號檔案的冗餘度依然為normal,想想也對,我們修改的是datafile.redundancy,而312號檔案是臨時檔案。

點選(此處)摺疊或開啟

  1. SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
  2.   2 from v$asm_file where filegroup_number = 6;

  3. FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
  4. ----------- ---------- ---------- -------------------- ------ - ------ -
  5.         309 104865792 339738624 DATAFILE MIRROR U COARSE Y
  6.         310 262152192 805306368 DATAFILE MIRROR U COARSE Y
  7.         311 419438592 1283457024 DATAFILE MIRROR U COARSE Y
  8.         312 67117056 142606336 TEMPFILE MIRROR U COARSE N

  9. SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
  10.   2 from v$asm_file where filegroup_number = 6;

  11. FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
  12. ----------- ---------- ---------- -------------------- ------ - ------ -
  13.         309 104865792 339738624 DATAFILE HIGH U COARSE N
  14.         310 262152192 805306368 DATAFILE HIGH U COARSE N
  15.         311 419438592 1283457024 DATAFILE HIGH U COARSE N
  16.         312 67117056 142606336 TEMPFILE MIRROR U COARSE N
 為了讓實驗結果更詳細,我下面還列了ASM例項警告日誌中的相關資訊,我發現觀察ASM做了啥操作非常有意思。

點選(此處)摺疊或開啟

  1. SQL> alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy'='high'
  2. NOTE: updated format of group 5 file 311 for 3-way mirroring
  3. NOTE: updated redundancy of group 5 file 311 to 3-way mirrored (remirror 0x4)
  4. NOTE: updated format of group 5 file 310 for 3-way mirroring
  5. NOTE: updated redundancy of group 5 file 310 to 3-way mirrored (remirror 0x4)
  6. NOTE: updated format of group 5 file 309 for 3-way mirroring
  7. NOTE: updated redundancy of group 5 file 309 to 3-way mirrored (remirror 0x4)
  8. NOTE: GroupBlock outside rolling migration privileged region
  9. NOTE: client +ASM1:+ASM:rac122pri no longer has group 5 (FLEX) mounted
  10. NOTE: client +ASM1:+ASM:rac122pri no longer has group 3 (DATA) mounted
  11. NOTE: client +ASM1:+ASM:rac122pri no longer has group 2 (MGMT) mounted
  12. NOTE: requesting all-instance membership refresh for group=5
  13. NOTE: membership refresh pending for group 5/0x4718f00c (FLEX)
  14. GMON querying group 5 at 835 for pid 25, osid 11576
  15. SUCCESS: refreshed membership for 5/0x4718f00c (FLEX)
  16. SUCCESS: alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy'='high'
  17. 2017-07-06 13:17:47.169000 +01:00
  18. NOTE: Attempting voting file refresh on diskgroup FLEX
  19. NOTE: Refresh completed on diskgroup FLEX. No voting file found.
  20. NOTE: starting rebalance of group 5/0x4718f00c (FLEX) at power 1
  21. NOTE: starting process ARBA
  22. Starting background process ARBA
  23. ARBA started with pid=33, OS id=9904
  24. NOTE: starting process ARB0
  25. Starting background process ARB0
  26. ARB0 started with pid=48, OS id=9906
  27. NOTE: assigning ARBA to group 5/0x4718f00c (FLEX) to compute estimates
  28. NOTE: assigning ARB0 to group 5/0x4718f00c (FLEX) with 1 parallel I/O
  29. 2017-07-06 13:18:29.554000 +01:00
  30. NOTE: Starting expel slave for group 5/0x4718f00c (FLEX)
  31. NOTE: stopping process ARB0
  32. NOTE: stopping process ARBA
  33. NOTE: GroupBlock outside rolling migration privileged region
  34. NOTE: requesting all-instance membership refresh for group=5
  35. SUCCESS: rebalance completed for group 5/0x4718f00c (FLEX)
  36. NOTE: membership refresh pending for group 5/0x4718f00c (FLEX)
  37. GMON querying group 5 at 836 for pid 25, osid 11576
  38. SUCCESS: refreshed membership for 5/0x4718f00c (FLEX)
  39. 2017-07-06 13:18:32.568000 +01:00
  40. NOTE: Attempting voting file refresh on diskgroup FLEX
  41. NOTE: Refresh completed on diskgroup FLEX. No voting file found.
 re-mirror操作在警告日誌中被列為(mini) rebalance操作。

## 新加的資料檔案會怎樣?
後設資料的改變在v$asm_filegroup_properties檢視中也可以看到。該PDB建立的每個新資料檔案都是HIGH冗餘度。

點選(此處)摺疊或開啟

  1. SQL> select file_type, name, value from v$asm_filegroup_property
  2.   2 where filegroup_number = 6 and file_type = 'DATAFILE';

  3. FILE_TYPE NAME VALUE
  4. --------------- -------------------- --------------------
  5. DATAFILE REDUNDANCY HIGH
  6. DATAFILE STRIPING COARSE
 加了個表空間,新的資料檔案也依然是HIGH冗餘度。

點選(此處)摺疊或開啟

  1. SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
  2.   2 from v$asm_file where filegroup_number = 6
  3.   3 order by file_number;

  4. FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
  5. ----------- ---------- ---------- --------------- ------ - ------ -
  6.         309 167780352 528482304 DATAFILE HIGH U COARSE N
  7.         310 272637952 843055104 DATAFILE HIGH U COARSE N
  8.         311 471867392 1434451968 DATAFILE HIGH U COARSE N
  9.         312 67117056 142606336 TEMPFILE MIRROR U COARSE N
  10.         313 2147491840 6467616768 DATAFILE HIGH U COARSE N
## 總結
Flex ASM磁碟組繼續讓我驚歎。使用檔案組,我可以單獨為任意實體(non-CDB, CDB, PDB)定義屬性,而且可以在磁碟組內部進行更細粒度的資料保護模式設定。在12c之前的版本,雖然我也可以完成同樣的任務,但是操作要複雜很多很多。不得不承認,Flex磁碟組確實相當flexible。

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

相關文章