原文連結
譯者 周天鵬
## 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的保護模式。這裡最好給大家舉個例子:
-
SQL> select filegroup_number,name,guid from v$asm_filegroup
-
-
FILEGROUP_NUMBER NAME GUID
-
---------------- -------------------- --------------------------------
-
0 DEFAULT_FILEGROUP
-
1 CDB_CDB$ROOT 4700A987085A3DFAE05387E5E50A8C7B
-
2 CDB_PDB$SEED 536DF51E8E28221BE0534764A8C0FD81
-
3 PDB1 537B677EF8DA0F1AE0534764A8C05729
-
4 ORCL_CDB$ROOT 4700A987085A3DFAE05387E5E50A8C7B
-
5 ORCL_PDB$SEED 537E63B952183748E0534764A8C09A7F
-
6 PDB1_0001 537EB5B87E62586EE0534764A8C05530
-
-
7 rows selected.
上面的列表展示了我的ASM例項中的檔案組資訊。本章將要修改6號檔案組(PDB1_0001)的屬性,該檔案組存放在Flex磁碟組上。知道哪些檔案屬於這個檔案組非常重要。這裡是一個列表:
-
SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
-
2 from v$asm_file where filegroup_number = 6;
-
-
FILE_NUMBER BYTES SPACE TYPE REDUNDANCY REDUNDANCY_LOWERED STRIPED REMIRROR
-
309 104865792 218103808 DATAFILE MIRROR U COARSE N
-
310 262152192 541065216 DATAFILE MIRROR U COARSE N
-
311 419438592 859832320 DATAFILE MIRROR U COARSE N
-
312 67117056 142606336 TEMPFILE MIRROR U COARSE N
官方文件說的沒錯,存放在Flex磁碟組上的資料檔案預設冗餘度是2副本。
## 檔案組屬性
在磁碟組內部改變冗餘度和其他一些屬性都依賴於你擁有檔案組。檔案組的屬性可以透過sql或者asmcmd來進行檢視。如下:
-
ASMCMD> lsfg -G flex --filegroup PDB1_0001
-
File Group Disk Group Property Value File Type
-
PDB1_0001 FLEX PRIORITY MEDIUM
-
PDB1_0001 FLEX STRIPING COARSE CONTAINER
-
PDB1_0001 FLEX STRIPING FINE CONTROLFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR DATAFILE
-
PDB1_0001 FLEX STRIPING COARSE DATAFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR ONLINELOG
-
PDB1_0001 FLEX STRIPING COARSE ONLINELOG
-
PDB1_0001 FLEX REDUNDANCY MIRROR ARCHIVELOG
-
PDB1_0001 FLEX STRIPING COARSE ARCHIVELOG
-
PDB1_0001 FLEX REDUNDANCY MIRROR TEMPFILE
-
PDB1_0001 FLEX STRIPING COARSE TEMPFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR BACKUPSET
-
PDB1_0001 FLEX STRIPING COARSE BACKUPSET
-
PDB1_0001 FLEX REDUNDANCY MIRROR PARAMETERFILE
-
PDB1_0001 FLEX STRIPING COARSE PARAMETERFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR DATAGUARDCONFIG
-
PDB1_0001 FLEX STRIPING COARSE DATAGUARDCONFIG
-
PDB1_0001 FLEX REDUNDANCY MIRROR CHANGETRACKING
-
PDB1_0001 FLEX STRIPING COARSE CHANGETRACKING
-
PDB1_0001 FLEX REDUNDANCY MIRROR FLASHBACK
-
PDB1_0001 FLEX STRIPING COARSE FLASHBACK
-
PDB1_0001 FLEX REDUNDANCY MIRROR DUMPSET
-
PDB1_0001 FLEX STRIPING COARSE DUMPSET
-
PDB1_0001 FLEX REDUNDANCY MIRROR AUTOBACKUP
-
PDB1_0001 FLEX STRIPING COARSE AUTOBACKUP
-
PDB1_0001 FLEX REDUNDANCY MIRROR VOTINGFILE
-
PDB1_0001 FLEX STRIPING COARSE VOTINGFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR OCRFILE
-
PDB1_0001 FLEX STRIPING COARSE OCRFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR ASMVOL
-
PDB1_0001 FLEX STRIPING COARSE ASMVOL
-
PDB1_0001 FLEX REDUNDANCY MIRROR ASMVDRL
-
PDB1_0001 FLEX STRIPING COARSE ASMVDRL
-
PDB1_0001 FLEX REDUNDANCY MIRROR OCRBACKUP
-
PDB1_0001 FLEX STRIPING COARSE OCRBACKUP
-
PDB1_0001 FLEX REDUNDANCY MIRROR FLASHFILE
-
PDB1_0001 FLEX STRIPING COARSE FLASHFILE
-
PDB1_0001 FLEX REDUNDANCY MIRROR XTRANSPORT BACKUPSET
-
PDB1_0001 FLEX STRIPING COARSE XTRANSPORT BACKUPSET
-
PDB1_0001 FLEX REDUNDANCY MIRROR AUDIT_SPILLFILES
-
PDB1_0001 FLEX STRIPING COARSE AUDIT_SPILLFILES
-
PDB1_0001 FLEX REDUNDANCY MIRROR INCR XTRANSPORT BACKUPSET
-
PDB1_0001 FLEX STRIPING COARSE INCR XTRANSPORT BACKUPSET
-
PDB1_0001 FLEX REDUNDANCY MIRROR KEY_STORE
-
PDB1_0001 FLEX STRIPING COARSE KEY_STORE
-
PDB1_0001 FLEX REDUNDANCY MIRROR AUTOLOGIN_KEY_STORE
-
PDB1_0001 FLEX STRIPING COARSE AUTOLOGIN_KEY_STORE
-
PDB1_0001 FLEX REDUNDANCY MIRROR CONTAINER
-
PDB1_0001 FLEX REDUNDANCY HIGH CONTROLFILE
-
ASMCMD>
輸出包含兩大類屬性:冗餘和條帶化。我真正關心的只有冗餘度,而且我也沒接觸過條帶化相關的屬性。查了下官方文件 ASM Administrator’s guide(),
對條帶化屬性的解釋如下:
> 這是檔案型別的屬性,僅需為每個檔案型別設定。一般使用預設值就夠了,不需要人為改變。
看到這個我很高興。
使用sql依然可以達到這種效果,這裡是等價的輸出:
-
SQL> select file_type, name, value from v$asm_filegroup_property where filegroup_number = 6;
-
-
FILE_TYPE NAME VALUE
-
------------------------------ ------------------------------ ------------------------------
-
PRIORITY MEDIUM
-
CONTROLFILE REDUNDANCY HIGH
-
CONTROLFILE STRIPING FINE
-
DATAFILE REDUNDANCY MIRROR
-
DATAFILE STRIPING COARSE
-
ONLINELOG REDUNDANCY MIRROR
-
ONLINELOG STRIPING COARSE
-
ARCHIVELOG REDUNDANCY MIRROR
-
ARCHIVELOG STRIPING COARSE
-
TEMPFILE REDUNDANCY MIRROR
-
TEMPFILE STRIPING COARSE
-
BACKUPSET REDUNDANCY MIRROR
-
BACKUPSET STRIPING COARSE
-
PARAMETERFILE REDUNDANCY MIRROR
-
PARAMETERFILE STRIPING COARSE
-
DATAGUARDCONFIG REDUNDANCY MIRROR
-
DATAGUARDCONFIG STRIPING COARSE
-
CHANGETRACKING REDUNDANCY MIRROR
-
CHANGETRACKING STRIPING COARSE
-
FLASHBACK REDUNDANCY MIRROR
-
FLASHBACK STRIPING COARSE
-
DUMPSET REDUNDANCY MIRROR
-
DUMPSET STRIPING COARSE
-
AUTOBACKUP REDUNDANCY MIRROR
-
AUTOBACKUP STRIPING COARSE
-
VOTINGFILE REDUNDANCY MIRROR
-
VOTINGFILE STRIPING COARSE
-
OCRFILE REDUNDANCY MIRROR
-
OCRFILE STRIPING COARSE
-
ASMVOL REDUNDANCY MIRROR
-
ASMVOL STRIPING COARSE
-
ASMVDRL REDUNDANCY MIRROR
-
ASMVDRL STRIPING COARSE
-
OCRBACKUP REDUNDANCY MIRROR
-
OCRBACKUP STRIPING COARSE
-
FLASHFILE REDUNDANCY MIRROR
-
FLASHFILE STRIPING COARSE
-
XTRANSPORT BACKUPSET REDUNDANCY MIRROR
-
XTRANSPORT BACKUPSET STRIPING COARSE
-
AUDIT_SPILLFILES REDUNDANCY MIRROR
-
AUDIT_SPILLFILES STRIPING COARSE
-
INCR XTRANSPORT BACKUPSET REDUNDANCY MIRROR
-
INCR XTRANSPORT BACKUPSET STRIPING COARSE
-
KEY_STORE REDUNDANCY MIRROR
-
KEY_STORE STRIPING COARSE
-
AUTOLOGIN_KEY_STORE REDUNDANCY MIRROR
-
AUTOLOGIN_KEY_STORE STRIPING COARSE
-
CONTAINER REDUNDANCY MIRROR
-
CONTAINER STRIPING COARSE
-
-
49 rows selected.
除了v$asm_file檢視,你們也可以查v$asm_filegroup_file這個檢視:
-
SQL> select filegroup_number, file_number, incarnation
-
2 from v$asm_filegroup_file
-
3 where filegroup_number = 6
-
4 order by file_number;
-
-
FILEGROUP_NUMBER FILE_NUMBER INCARNATION
-
---------------- ----------- -----------
-
6 309 948464269
-
6 310 948464269
-
6 311 948464269
-
6 312 948464283
-
-
SQL>
FILE_NUMBER欄位和INCARNATION可以被關聯上v$asm_file。
回到主題上:我想把冗餘度從normal轉為high,但該操作僅對6號檔案組有效。v$asm_file檢視中有一些大小、型別、當前冗餘度、條帶級別和是否正在re-mirror的資訊。在進行操作之前,我們先看下里面的內容:
-
SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
-
2 from v$asm_file where filegroup_number = 6;
-
-
FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
-
----------- ---------- ---------- -------------------- ------ - ------ -
-
309 104865792 218103808 DATAFILE MIRROR U COARSE N
-
310 262152192 541065216 DATAFILE MIRROR U COARSE N
-
311 419438592 859832320 DATAFILE MIRROR U COARSE N
-
312 67117056 142606336 TEMPFILE MIRROR U COARSE N
-
-
SQL>
檔案309和312使用mirror的冗餘度(2副本,也就是normal冗餘)。讓我們嘗試改變這個冗餘度,看看會發生什麼。
## 修改資料檔案冗餘度
這裡真正的操作才開始。Automatic Storage Management Administrator’s Guide的Administering Oracle ASM Disk Groups章節的Managing Oracle ASM Flex Disk Groups這個部分()
說了所有檔案組的屬性都可以被修改。讓我們用文件上的例子,來改變6號檔案組的屬性:
-
SQL> alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy'='high';
-
-
Diskgroup altered.
這條命令(其他改變儲存屬性的操作)必須以SYSASM方式登陸ASM例項才可以執行。從DB例項執行會報如下錯誤:
-
SQL> alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy' = 'high';
-
-
Error starting at line : 1 in command -
-
alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy' = 'high'
-
Error report -
-
ORA-15000: command disallowed by current instance type
-
15000. 00000 - "command disallowed by current instance type"
-
*Cause: The user has issued a command to a conventional RDBMS instance
-
that is only appropriate for an ASM instance. Alternatively, the
-
user has issued a command to an ASM instance that is only
-
appropriate for an RDBMS instance.
-
*Action: Connect to the correct instance type and re-issue the command.
-
SQL>
命令結束後,資料檔案立刻開始了re-mirror操作。在re-mirror的過程中(即remirror欄位為Y),冗餘度依然為MIRROR。只有當re-mirror操作完成後(即remirror欄位為N),冗餘度才變為high。注意:312號檔案的冗餘度依然為normal,想想也對,我們修改的是datafile.redundancy,而312號檔案是臨時檔案。
-
SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
-
2 from v$asm_file where filegroup_number = 6;
-
-
FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
-
----------- ---------- ---------- -------------------- ------ - ------ -
-
309 104865792 339738624 DATAFILE MIRROR U COARSE Y
-
310 262152192 805306368 DATAFILE MIRROR U COARSE Y
-
311 419438592 1283457024 DATAFILE MIRROR U COARSE Y
-
312 67117056 142606336 TEMPFILE MIRROR U COARSE N
-
-
SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
-
2 from v$asm_file where filegroup_number = 6;
-
-
FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
-
----------- ---------- ---------- -------------------- ------ - ------ -
-
309 104865792 339738624 DATAFILE HIGH U COARSE N
-
310 262152192 805306368 DATAFILE HIGH U COARSE N
-
311 419438592 1283457024 DATAFILE HIGH U COARSE N
-
312 67117056 142606336 TEMPFILE MIRROR U COARSE N
為了讓實驗結果更詳細,我下面還列了ASM例項警告日誌中的相關資訊,我發現觀察ASM做了啥操作非常有意思。
-
SQL> alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy'='high'
-
NOTE: updated format of group 5 file 311 for 3-way mirroring
-
NOTE: updated redundancy of group 5 file 311 to 3-way mirrored (remirror 0x4)
-
NOTE: updated format of group 5 file 310 for 3-way mirroring
-
NOTE: updated redundancy of group 5 file 310 to 3-way mirrored (remirror 0x4)
-
NOTE: updated format of group 5 file 309 for 3-way mirroring
-
NOTE: updated redundancy of group 5 file 309 to 3-way mirrored (remirror 0x4)
-
NOTE: GroupBlock outside rolling migration privileged region
-
NOTE: client +ASM1:+ASM:rac122pri no longer has group 5 (FLEX) mounted
-
NOTE: client +ASM1:+ASM:rac122pri no longer has group 3 (DATA) mounted
-
NOTE: client +ASM1:+ASM:rac122pri no longer has group 2 (MGMT) mounted
-
NOTE: requesting all-instance membership refresh for group=5
-
NOTE: membership refresh pending for group 5/0x4718f00c (FLEX)
-
GMON querying group 5 at 835 for pid 25, osid 11576
-
SUCCESS: refreshed membership for 5/0x4718f00c (FLEX)
-
SUCCESS: alter diskgroup flex modify filegroup PDB1_0001 set 'datafile.redundancy'='high'
-
2017-07-06 13:17:47.169000 +01:00
-
NOTE: Attempting voting file refresh on diskgroup FLEX
-
NOTE: Refresh completed on diskgroup FLEX. No voting file found.
-
NOTE: starting rebalance of group 5/0x4718f00c (FLEX) at power 1
-
NOTE: starting process ARBA
-
Starting background process ARBA
-
ARBA started with pid=33, OS id=9904
-
NOTE: starting process ARB0
-
Starting background process ARB0
-
ARB0 started with pid=48, OS id=9906
-
NOTE: assigning ARBA to group 5/0x4718f00c (FLEX) to compute estimates
-
NOTE: assigning ARB0 to group 5/0x4718f00c (FLEX) with 1 parallel I/O
-
2017-07-06 13:18:29.554000 +01:00
-
NOTE: Starting expel slave for group 5/0x4718f00c (FLEX)
-
NOTE: stopping process ARB0
-
NOTE: stopping process ARBA
-
NOTE: GroupBlock outside rolling migration privileged region
-
NOTE: requesting all-instance membership refresh for group=5
-
SUCCESS: rebalance completed for group 5/0x4718f00c (FLEX)
-
NOTE: membership refresh pending for group 5/0x4718f00c (FLEX)
-
GMON querying group 5 at 836 for pid 25, osid 11576
-
SUCCESS: refreshed membership for 5/0x4718f00c (FLEX)
-
2017-07-06 13:18:32.568000 +01:00
-
NOTE: Attempting voting file refresh on diskgroup FLEX
-
NOTE: Refresh completed on diskgroup FLEX. No voting file found.
re-mirror操作在警告日誌中被列為(mini) rebalance操作。
## 新加的資料檔案會怎樣?
後設資料的改變在v$asm_filegroup_properties檢視中也可以看到。該PDB建立的每個新資料檔案都是HIGH冗餘度。
-
SQL> select file_type, name, value from v$asm_filegroup_property
-
2 where filegroup_number = 6 and file_type = 'DATAFILE';
-
-
FILE_TYPE NAME VALUE
-
--------------- -------------------- --------------------
-
DATAFILE REDUNDANCY HIGH
-
DATAFILE STRIPING COARSE
加了個表空間,新的資料檔案也依然是HIGH冗餘度。
-
SQL> select file_number,bytes,space,type,redundancy,redundancy_lowered,striped,remirror
-
2 from v$asm_file where filegroup_number = 6
-
3 order by file_number;
-
-
FILE_NUMBER BYTES SPACE TYPE REDUND R STRIPE R
-
----------- ---------- ---------- --------------- ------ - ------ -
-
309 167780352 528482304 DATAFILE HIGH U COARSE N
-
310 272637952 843055104 DATAFILE HIGH U COARSE N
-
311 471867392 1434451968 DATAFILE HIGH U COARSE N
-
312 67117056 142606336 TEMPFILE MIRROR U COARSE N
-
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/,如需轉載,請註明出處,否則將追究法律責任。