Managing the ASM Instance管理ASM实例

you should be able to: 1、Describe the benefits of using ASM 2、Manage the ASM instance 3、Create and drop ASM disk groups 4、Extend ASM disk groups 5、Retrieve ASM metadata by using various utilities

ASM:内存+进程

sqlplus / as sysasm; v$asm_disk; v$asm_diskgroup;

shared pool:元数据信息 large pool :大池,并行操作的 asm cache: 重平衡,(值最小1,最大11,越大重平衡越快) free memory: 空闲内存

ASM实例初始化参数 The ASM instance uses a small subset of the parameters that an Oracle Database instance uses.

[INSTANCE_TYPE = ASM ASM_POWER_LIMIT = 1 ASM_DISKSTRING = '/dev/sda1','/dev/sdb*' ASM_DISKGROUPS = DATA2, FRA ASM_PREFERRED_READ_FAILURE_GROUPS = DATA.FailGroup2 DIAGNOSTIC_DEST = /u01/app/oracle LARGE_POOL_SIZE = 12M REMOTE_LOGIN_PASSWORDFILE = EXCLUSIVE]

SQL> show parameter spfile; SQL>show parameter instance_type;

ASM Instance: Dynamic Performance Views ASM动态性能视图 ASM只有动态性能视图,文件是保存在OS的$ORACLE_HOME/dbs/orapw+asm中的

The ASM instance hosts memory-based metadata tables presented as dynamic performance views. Accessed by ASM utilities to retrieve metadata-only information using the SQL language Contains many dedicated ASM-related views such as: V$ASM_ALIAS V$ASM_ATTRIBUTE V$ASM_CLIENT V$ASM_DISK V$ASM_DISK_IOSTAT V$ASM_DISK_STAT V$ASM_DISKGROUP V$ASM_DISKGROUP_STAT V$ASM_FILE V$ASM_OPERATION V$ASM_TEMPLATE

先关DB,再关ASM。先开ASM,再开DB; Starting and Stopping ASM Instances Using SQL*Plus 用sqlplus起停ASM实例

$ . oraenv ORACLE_SID = [orcl] ? +ASM The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle $ sqlplus / AS SYSASM SQL*Plus: Release 11.2.0.1.0 - Production on Wed Jul 8 20:46:46 2009 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ASM instance started

Total System Global Area 284565504 bytes Fixed Size 1336028 bytes Variable Size 258063652 bytes ASM Cache 25165824 bytes ASM diskgroups mounted ASM diskgroups volume enabled SQL> shutdown abort

Starting and Stopping ASM Instances Using srvctl 用srvctl起停ASM实例 $ . oraenv ORACLE_SID = [orcl] ? +ASM The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle $ srvctl start asm -o mount $ srvctl stop asm -f

$ srvctl status asm ASM is running on edrsr25p1

Starting and Stopping ASM Instances Using asmcmd 用ASMCMD起停ASM实例 $ . oraenv ORACLE_SID = [orcl] ? +ASM The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle $ asmcmd Connected to an idle instance. ASMCMD> startup ASM instance started

Total System Global Area 284565504 bytes Fixed Size 1336028 bytes Variable Size 258063652 bytes ASM Cache 25165824 bytes ASM diskgroups mounted ASM diskgroups volume enabled ASMCMD> shutdown --abort ASM instance shut down Connected to an idle instance.

ASM disks are divided into allocation units (AU): AU size is configurable at disk group creation. Default AU size is 1 MB: Small enough to be cached by database and large enough for efficient sequential access Allowable AU sizes: 1, 2, 4, 8, 16, 32, or 64 MB Large AUs may be useful in very large database (VLDB) scenarios or when using specialized storage hardware

ASM files: Are a collection of ASM extents composed of AUs Variable sized extents support large files Appear as normal files to the database kernel Have file names that start with '+' For example, +DATA/orcl/datafile/system.256.689832921 May be associated with an optional alias file name For example, +DATA/dbfiles/mydb/system01.dbf Are evenly distributed across disks in a disk group Are mirrored according to the policies defined in the disk group

Striping Granularity 条带化粒度

1、ASM separates striping for load balance and striping for latency: Coarse-grain striping concatenates allocation units for load balancing. 数据文件粗粒度,以AU如1M为单元逐磁盘写入。

2、Fine-grain striping puts 128 KB stripe units across groups of allocation units to improve latency. Disk group with 8 disks and external redundancy Default AU size of 1 MB in use First 1 MB extent written as 128 KB stripes across 8 AUs 细粒度 ,以128K为单元逐磁盘写入,如控制文件、日志文件用细粒度。

管理ASM磁盘组 CREATE DISKGROUP ALTER DISKGROUP DROP DISKGROUP

Creating and Dropping Disk Groups Using SQLPlus 例: $ . oraenv ORACLE_SID = [orcl] ? +ASM The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle $ sqlplus / AS SYSASM SQLPlus: Release 11.2.0.1.0 - Production on Wed Jul 8 20:46:46 2009 Copyright (c) 1982, 2009, Oracle. All rights reserved. .. SQL> CREATE DISKGROUP dgroupA NORMAL REDUNDANCY
FAILGROUP controller1 DISK '/devices/A1' NAME diskA1 SIZE 120G FORCE, '/devices/A2', FAILGROUP controller2 DISK '/devices/B1', '/devices/B2';

SQL> DROP DISKGROUP dgroupA INCLUDING CONTENTS;

例: Remove a disk from dgroupA: ALTER DISKGROUP dgroupA DROP DISK A5;

Add and drop a disk in a single command: 增加和删除DISK用1条命令完成 ALTER DISKGROUP dgroupA DROP DISK A6 ADD FAILGROUP controller3 DISK '/dev/sdi1' NAME A9;

Add and drop a disk in a single command: ALTER DISKGROUP dgroupA UNDROP DISKS;

例: Adding Disks to Disk Groups ALTER DISKGROUP dgroupA ADD DISK '/dev/sde1' NAME A5, '/dev/sdf1' NAME A6, '/dev/sdg1' NAME A7, '/dev/sdh1' NAME A8;

ALTER DISKGROUP dgroupA ADD DISK '/devices/A*';

ASMCMD> lsdsk desc v$asm_disk; create diskgroup dg_test external redurancy disk '/dev/sdi5' name i5;

ASMCMD>lsdg drop diskgroup dg_test including contents;

**ASM Disk Group Compatibility ASM磁盘组兼容性 **

**Retrieving ASM Metadata 检索ASM元数据 **SQL> SELECT f.type, f.redundancy, f.striped, f.modification_date, a.system_created, a.name FROM v$asm_alias a, v$asm_file f WHERE a.file_number = f.file_number and a.group_number = f.group_number and type='DATAFILE'; TYPE REDUND STRIPE MODIFICAT S NAME


DATAFILE MIRROR COARSE 08-JUL-09 Y SYSTEM.256.689832921 DATAFILE MIRROR COARSE 08-JUL-09 Y SYSAUX.257.689832923 ..

ASMCMD> ls -l +DATA/orcl/datafile Type Redund Striped Time Sys Name DATAFILE MIRROR COARSE JUL 08 21:00:00 Y SYSTEM.256.689832921 DATAFILE MIRROR COARSE JUL 08 21:00:00 Y SYSAUX.257.689832923 ..