原文链接 https://martincarstenbach.wordpress.com/2017/07/21/12-2-new-feature-the-flex-asm-disk-group-part-3/ 译者 周天鹏
本专题的上一部分中,我介绍了Flex ASM Diskgroup的两个相关概念,配额组和文件组。但配额组的配额是否真的写多少就是多少呢?(还是超出个百分之多少也没关系)我对此非常好奇。 幸运的是,我又发现了12c ASM相关的值得写博客跟大家分享的一些点,所以:
配额组的配额是强制的吗? 其实配额组的目的就是限制磁盘组的配额,就像文件系统那样。这非常有意思,因为对于存放在某磁盘组中的某CDB/PDB(即使是non-CDB),你都可以给一个硬的限制来限制这个库在这个磁盘组上可使用的存储空间。 我将要回答的问题是:这个配额真的管用吗?如果你看了前两部分,你应该知道,我在Flex ASM Diskgroup上创建了两个数据库:ORCL和CDB,都是容器数据库。 我的文件组当前状态是酱紫的:
ASMCMD> lsfg
File Group Disk Group Quota Group Used Quota MB Client Name Client Type
DEFAULT_FILEGROUP FLEX GENERIC 2488
CDB_CDB$ROOT FLEX QG_CDB 6744 CDB_CDB$ROOT DATABASE
CDB_PDB$SEED FLEX QG_CDB 1656 CDB_PDB$SEED DATABASE
PDB1 FLEX QG_CDB 1784 PDB1 DATABASE
ORCL_CDB$ROOT FLEX GENERIC 9104 ORCL_CDB$ROOT DATABASE
ORCL_PDB$SEED FLEX GENERIC 1616 ORCL_PDB$SEED DATABASE
PDB1_0001 FLEX GENERIC 9424 PDB1 DATABASE
名为CDB的数据库用的是叫做QG_CDB的配额组,ORCL那个库没指定配额组,所以还用的默认配额组。我想让这个库使用新建的QG_ORCL这个配额组,因为我想让不同的库用不同的配额组。
ASMCMD> mkqg -G FLEX QG_ORCL quota 20G
Diskgroup altered.
ASMCMD> lsqg
Group_Num Quotagroup_Num Quotagroup_Name Incarnation Used_Quota_MB Quota_Limit_MB
2 1 GENERIC 1 22632 0
2 2 QG_ORCL 7 0 20480
2 3 QG_CDB 1 10184 20480
ASMCMD>
如果你看过前两部分,应该还记得名为Flex的Flex Diskgroup的磁盘组号原本是5,但重启机器后,磁盘组号从5变成了2。
SQL> select group_number, name, state, type from v$asm_diskgroup
2 where group_number = 2;
GROUP_NUMBER NAME STATE TYPE
------------ ------------------------------ ----------- ------
2 FLEX CONNECTED FLEX
不要为此困扰。 回到刚才的例子:文件组ORCL_CDB$ROOT, ORCL_PDB$SEED和PDB1_0001还不属于QG_ORCL。这可以通过ASMCMD使用3个简单的mvfg命令来修改,或者使用sql也可以。移动命令完成后,配额组仍然后空间剩余(虽然已经不多了)。
ASMCMD> mvfg -G flex --filegroup PDB1_0001 QG_ORCL
Diskgroup altered.
ASMCMD> mvfg -G flex --filegroup ORCL_PDB$SEED QG_ORCL
Diskgroup altered.
ASMCMD> mvfg -G flex --filegroup ORCL_CDB$ROOT QG_ORCL
Diskgroup altered.
ASMCMD> lsfg
File Group Disk Group Quota Group Used Quota MB Client Name Client Type
DEFAULT_FILEGROUP FLEX GENERIC 2488
CDB_CDB$ROOT FLEX QG_CDB 6744 CDB_CDB$ROOT DATABASE
CDB_PDB$SEED FLEX QG_CDB 1656 CDB_PDB$SEED DATABASE
PDB1 FLEX QG_CDB 1784 PDB1 DATABASE
ORCL_CDB$ROOT FLEX QG_ORCL 9104 ORCL_CDB$ROOT DATABASE
ORCL_PDB$SEED FLEX QG_ORCL 1616 ORCL_PDB$SEED DATABASE
PDB1_0001 FLEX QG_ORCL 9424 PDB1 DATABASE
ASMCMD> lsqg
Group_Num Quotagroup_Num Quotagroup_Name Incarnation Used_Quota_MB Quota_Limit_MB
2 1 GENERIC 1 2488 0
2 2 QG_ORCL 7 20144 20480
2 3 QG_CDB 1 10184 20480
ASMCMD>
现在我要把它占用的存储空间撑到配额组的配额极限,来看下配额组是不是真的靠谱。方法当然很简单:在ORCL库中创建一个表空间嘛。
SQL> show con_name
CON_NAME
------------------------------
PDB1
SQL> create tablespace userdata datafile size 500m;
create tablespace userdata datafile size 500m
*
ERROR at line 1:
ORA-01119: error in creating database file '+FLEX'
ORA-17502: ksfdcre:4 Failed to create file +FLEX
ORA-15437: Not enough quota available in quota group QG_ORCL.
SQL>
这报错和我们之前创建pdb时指定storage子句的时候非常类似。但是,对于ASM上的非数据文件(例如参数文件,日志文件等)来说会怎样呢?
SQL> get /tmp/non_data_files
1 SELECT
2 f.group_number as DG_NUMBER,
3 f.file_number,
4 f.incarnation as file_incarnation,
5 f.type,
6 fg.name as filegroup_name,
7 a.name as file_name
8 FROM
9 v$asm_alias a,
10 v$asm_file f,
11 v$asm_filegroup fg
12 WHERE
13 a.group_number = f.group_number
14 AND
15 a.file_number = f.file_number
16 AND
17 a.file_incarnation = f.incarnation
18 AND
19 fg.group_number = f.group_number
20 AND
21 fg.filegroup_number = f.filegroup_number
22 AND
23* f.type 'DATAFILE';
SQL> start /tmp/non_data_files
DG_NUMBER FILE_NUMBER FILE_INCARNATION TYPE FILEGROUP_NAME FILE_NAME
---------- ----------- ---------------- --------------- -------------------- ------------------------------
2 282 948453843 PASSWORD DEFAULT_FILEGROUP pwdorcl.282.948453843
2 287 948462715 PASSWORD DEFAULT_FILEGROUP pwdorcl.287.948462715
2 293 948462849 CONTROLFILE ORCL_CDB$ROOT Current.293.948462849
2 292 948462849 CONTROLFILE ORCL_CDB$ROOT Current.292.948462849
2 294 948462855 ONLINELOG ORCL_CDB$ROOT group_2.294.948462855
2 295 948462855 ONLINELOG ORCL_CDB$ROOT group_1.295.948462855
2 296 948462861 ONLINELOG ORCL_CDB$ROOT group_1.296.948462861
2 297 948462861 ONLINELOG ORCL_CDB$ROOT group_2.297.948462861
2 304 948463227 ONLINELOG ORCL_CDB$ROOT group_3.304.948463227
2 305 948463231 ONLINELOG ORCL_CDB$ROOT group_3.305.948463231
2 306 948463239 ONLINELOG ORCL_CDB$ROOT group_4.306.948463239
2 307 948463243 ONLINELOG ORCL_CDB$ROOT group_4.307.948463243
2 298 948462891 TEMPFILE ORCL_CDB$ROOT TEMP.298.948462891
2 302 948462937 TEMPFILE ORCL_PDB$SEED TEMP.302.948462937
2 308 948463249 PARAMETERFILE ORCL_CDB$ROOT spfile.308.948463249
2 312 948464283 TEMPFILE PDB1_0001 TEMP.312.948464283
16 rows selected.
新建一个online redo log试试:
SQL> alter database add logfile thread 1 size 1g;
alter database add logfile thread 1 size 1g
*
ERROR at line 1:
ORA-00301: error in adding log file '+FLEX' - file cannot be created
ORA-17502: ksfdcre:4 Failed to create file +FLEX
ORA-15437: Not enough quota available in quota group QG_ORCL.
这些都证明了配额组确实是强制的。至少对于上面的例子来说是的。
小 结
对于配额组来说,确实还有很多东中西值得探索,例如:自动扩展的数据文件、归档日志、临时文件以及undo文件等等。但是初步看来,配额组确实还不错。