创建磁盘组
假设asm_diskstring初始化参数设置成/devices/*,下面的磁盘被asm发现
ASM disk discovery identifies the following disks in directory /devices
.
-
/devices/diska1
-
/devices/diska2
-
/devices/diska3
-
/devices/diska4
-
/devices/diskb1
-
/devices/diskb2
-
/devices/diskb3
-
/devices/diskb4
-
The disks
diska1
-diska4
are on a separate SCSI controller from disksdiskb1
-diskb4
.
SQL> STARTUP NOMOUNT
SQL> CREATE DISKGROUP dgroup1 NORMAL REDUNDANCY
2 FAILGROUP controller1 DISK
3 '/devices/diska1',
4 '/devices/diska2',
5 '/devices/diska3',
6 '/devices/diska4'
7 FAILGROUP controller2 DISK
8 '/devices/diskb1',
9 '/devices/diskb2',
10 '/devices/diskb3',
11 '/devices/diskb4';
添加磁盘组
Adding Disks to a Disk Group: Example 1 The following statement adds disks to dgroup1:
ALTER DISKGROUP dgroup1 ADD DISK '/devices/diska5' NAME diska5, '/devices/diska6' NAME diska6;
Because no FAILGROUP
clauses are included in the ALTER DISKGROUP
statement, each disk is assigned to its own failure group. The NAME
clauses assign names to the disks, otherwise they would have been assigned system-generated names.
删除磁盘组
Dropping Disks from Disk Groups: Example 1 This example drops diska5
(the operating system independent name assigned to /devices/diska5
in "Adding Disks to a Disk Group: Example 1") from disk group dgroup1
.
ALTER DISKGROUP dgroup1 DROP DISK diska5;
Dropping Disks from Disk Groups: Example 2 This example drops diska5
from disk group dgroup1
, and also illustrates how multiple actions are possible with one ALTER DISKGROUP
statement.
alter diskgroup dgroup1 drop disk diska5 add failgroup failgrp1 disk '/devices/diska9' name diska9;
手工平衡一个磁盘组
Manually Rebalancing a Disk Group: Example The following example manually rebalances the disk group dgroup2
. The command does not return until the rebalance operation is complete.
alter diskgroup dgroup2 rebalance power 5 wait;
挂载和卸载磁盘组
ALTER DISKGROUP dgroup1 MOUNT;
ALTER DISKGROUP ALL DISMOUNT;
检查磁盘组元数据的内部一致性
ALTER DISKGROUP dgroup1 CHECK ALL;
删除磁盘组
如果要删除磁盘组中包含的所有数据文件,你可以指定including contents,默认的是excluding contents.
DROP DISKGROUP dgroup1;
管理磁盘组中的目录
example of a system-generated filename:
+dgroup2/sample/controlfile/Current.256.541956473
The plus sign represents the root of the ASM file system. The dgroup2
directory is the parent directory for all files in the dgroup2
disk group. The sample
directory is the parent directory for all files in the sample
database, and the controlfile
directory contains all control files for the sample
database.
创建目录
Creating a New Directory: Example 1 The following statement creates a hierarchical directory for disk group dgroup1
, which can contain, for example, the alias name +dgroup1/mydir/control_file1
:
ALTER DISKGROUP dgroup1 ADD DIRECTORY '+dgroup1/mydir';
Creating a New Directory: Example 2 Assuming no subdirectory exists under the directory +dgoup1/mydir
, the following statement fails:
ALTER DISKGROUP dgroup1 ADD DIRECTORY '+dgroup1/mydir/first_dir/second_dir';
重命名目录
系统命名的目录不能重命名
Renaming a Directory: Example The following statement renames a directory:
ALTER DISKGROUP dgroup1 RENAME DIRECTORY '+dgroup1/mydir' TO '+dgroup1/yourdir'管理别名v$asm_alias视图提供了asm实例中的每个别名Adding an Alias Name for an ASM Filename: Example 1 The following statement adds a new alias name for a system-generated file name:
ALTER DISKGROUP dgroup1 ADD ALIAS '+dgroup1/mydir/second.dbf' FOR '+dgroup1/sample/datafile/mytable.342.3'; 重命名别名Renaming an Alias Name for an ASM Filename: Example The following statement renames an alias:
ALTER DISKGROUP dgroup1 RENAME ALIAS '+dgroup1/mydir/datafile.dbf' TO '+dgroup1/payroll/compensation.dbf';删除别名ALTER DISKGROUP dgroup1 DROP ALIAS '+dgroup1/payroll/compensation.dbf';删除文件及相关的别名Dropping Files and Associated Aliases from a Disk Group: Example 1The following statement uses the alias name for the file to delete both the file and the alias:ALTER DISKGROUP dgroup1 DROP FILE '+dgroup1/payroll/compensation.dbf';Dropping Files and Associated Aliases from a Disk Group: Example 2In this example the system-generated filename is used to drop the file and any associated alias:ALTER DISKGROUP dgroup1 DROP FILE '+dgroup1/sample/datafile/mytable.342.372642';管理模板当磁盘组被创建了,asm为磁盘组创建一些默认的模板,对每种类型的文件都有模板。v$asm_template视图提供了asm中的所有模板。模板属性Table 12-3 Permitted Values for ASM Template Striping Attribute
Striping Attribute Value | Description |
---|---|
FINE | Striping in 128KB chunks. |
COARSE | Striping in 1MB chunks. |
Table 12-4 Permitted Values for ASM Template Redundancy Attribute
Redundancy Attribute Value | Resulting Mirroring in Normal Redundancy Disk Group | Resulting Mirroring in High Redundancy Disk Group | Resulting Mirroring in External Redundancy Disk Group |
---|---|---|---|
MIRROR | 2-way mirroring | 3-way mirroring | (Not allowed) |
HIGH | 3-way mirroring | 3-way mirroring | (Not allowed) |
UNPROTECTED | No mirroring | (Not allowed) | No mirroring |
Table 12-5 ASM System Default Templates Attribute Settings
Template Name | Striping | Mirroring, Normal Redundancy Disk Group | Mirroring, High Redundancy Disk Group | Mirroring, External Redundancy Disk Group |
---|---|---|---|---|
CONTROLFILE | FINE | HIGH | HIGH | UNPROTECTED |
DATAFILE | COARSE | MIRROR | HIGH | UNPROTECTED |
ONLINELOG | FINE | MIRROR | HIGH | UNPROTECTED |
ARCHIVELOG | COARSE | MIRROR | HIGH | UNPROTECTED |
TEMPFILE | COARSE | MIRROR | HIGH | UNPROTECTED |
BACKUPSET | COARSE | MIRROR | HIGH | UNPROTECTED |
PARAMETERFILE | COARSE | MIRROR | HIGH | UNPROTECTED |
DATAGUARDCONFIG | COARSE | MIRROR | HIGH | UNPROTECTED |
FLASHBACK | FINE | MIRROR | HIGH | UNPROTECTED |
CHANGETRACKING | COARSE | MIRROR | HIGH | UNPROTECTED |
DUMPSET | COARSE | MIRROR | HIGH | UNPROTECTED |
XTRANSPORT | COARSE | MIRROR | HIGH | UNPROTECTED |
AUTOBACKUP | COARSE | MIRROR | HIGH | UNPROTECTED |
Adding Templates to a Disk Group: Example 1 The following statement creates a new template named reliable
for the normal redundancy disk group dgroup2
:
ALTER DISKGROUP dgroup2 ADD TEMPLATE reliable ATTRIBUTES (HIGH FINE);
Adding Templates to a Disk Group: Example 2 This statement creates a new template named unreliable
that specifies files are to be unprotected (no mirroring). (Oracle discourages the use of unprotected files unless hardware mirroring is in place; this example is presented only to further illustrate how the attributes for templates are set.)
ALTER DISKGROUP dgroup2 ADD TEMPLATE unreliable ATTRIBUTES (UNPROTECTED);
修改磁盘组模板
Modifying a Disk Group Template: Example The following example changes the striping attribute specification of the
reliable
template for disk groupdgroup2
.ALTER DISKGROUP dgroup2 ALTER TEMPLATE reliable ATTRIBUTES (COARSE);删除磁盘模板Dropping Templates from a Disk Group: Example This example drops the previously created template
unreliable
fromdgroup2
:ALTER DISKGROUP dgroup2 DROP TEMPLATE unreliable;