Automatic Storage Management (ASM)
Automatic Storage Management (ASM) is oracle’s logical volume manager, it uses OMF (Oracle Managed Files) to name and locate the database files. It can use raw disks, filesystems or files which can be made to look like disks as long as the device is raw. ASM uses its own database instance to manage the disks, it has its own processes and pfile or spfile, it uses ASM disk groups to manage disks as one logical unit.
The benefits of ASM are
The three components of ASM are
ASM Instance | is a special instance that does not have any data files, there is only ASM instance one per server which manages all ASM files for each database. The instance looks after the disk groups and allows access to the ASM files. Databases access the files directly but uses the ASM instance to locate them. If the ASM instance is shutdown then the database will either be automatically shutdown or crash. |
ASM Disk Groups | Disks are grouped together via disk groups, these are very much like logical volumes. |
ASM Files | Files are stored in the disk groups and benefit from the disk group features i.e. stripping and mirroring. |
ASM Summary |
|
ASM Processes
There are a number of new processes that are started when using ASM, both the ASM instance and Database will start new processes
ASM Instance |
|
RBAL (rebalance master) |
coordinates the rebalancing when a new disk is add or removed |
ARB[1-9] (rebalance) |
actually does the work requested by the RBAL process (upto 9 of these) |
Database Instance |
|
RBAL | opens and closes the ASM disk |
ASMB | connects to the ASM instance via session and is the communication between ASM and RBMS, requests could be file creation, deletion, resizing and also various statistics and status messages. |
ASM registers its name and disks with the RDBMS via the cluster synchronization service (CSS). This is why the oracle cluster services must be running, even if the node and instance is not clustered. The ASM must be in mount mode in order for a RDBMS to use it and you only require the instance type in the parameter file.
ASM Disk Groups
An ASM disk group is a logical volume that is created from the underlying physical disks. If storage grows you simply add disks to the disks groups, the number of groups can remain the same.
ASM file management has a number of good benefits over normal 3rd party LVM's
ASM Stripping
ASM stripes files across all the disks within the disk group thus increasing performance, each stripe is called an ‘allocation unit’. ASM offers two types of stripping which is dependent on the type of database file
Coarse Stripping | used for datafile, archive logs (1MB stripes) |
Fine Stripping | used for online redo logs, controlfile, flashback files(128KB stripes) |
ASM Mirroring
Disk mirroring provides data redundancy, this means that if a disk were to fail Oracle will use the other mirrored disk and would continue as normal. Oracle mirrors at the extent level, so you have a primary extent and a mirrored extent. When a disk fails, ASM rebuilds the failed disk using mirrored extents from the other disks within the group, this may have a slight impact on performance as the rebuild takes place.
All disks that share a common controller are in what is called a failure group, you can ensure redundancy by mirroring disks on separate failure groups which in turn are on different controllers, ASM will ensure that the primary extent and the mirrored extent are not in the same failure group. When mirroring you must define failure groups otherwise the mirroring will not take place.
There are three forms of Mirroring
ASM Files
The data files you create under ASM are not like the normal database files, when you create a file you only need to specify the disk group that the files needs to be created in, Oracle will then create a stripped file across all the disks within the disk and carry out any redundancy required, ASM files are OMF files. ASM naming is dependent on the type file being created, here are the different file-naming conventions
Creating ASM Instance
Creating a ASM instance is like creating a normal instance but the parameter file will be smaller, ASM does not mount any data files, it only maintains ASM metadata. ASM normally only needs about 100MB of disk space and will consume about 25MB of memory for the SGA, ASM does not have a data dictionary like a normal database so you must connect to the instance using either O/S authentication as SYSDBA or SYSOPER or using a password file.
The main parameters in the instance parameter file will be
You can start an ASM instance with nomount, mount but not open. When shutting down a ASM instance this passes the shutdown command to the RDBMS (normal, immediate, etc)
ASM Configuration |
|
Parameter file (init+asm.ora) |
instance_type=’asm’ Note: file should be created in $ORACLE_HOME/database |
Create service (windows only) | c:> oradim –new –asmsid +ASM –startmode manual |
Set the oracle_sid environment variable (windows or unix) | c:> set ORACLE_SID=+ASM (windows only) export ORACLE_SID=+ASM (unix only) |
Login to ASM instance and start instance | c:> sqlplus /nolog; Note: sometimes you get a ora-15110 which means that the diskgroups are not created yet. |
ASM Operations |
|
Instance name | select instance_name from v$instance; |
Create disk group | create diskgroup diskgrpA high redundancy create diskgroup diskgrpA external redundancy Note: force is used if disk has been in a previous diskgroup, external redundancy uses third party mirroring i.e SAN |
Add disks to a group | alter diskgroup diskgrpA add disk '\\.\i:' name disk4; '\\.\j:' name disk5; |
Remove disks from a group | alter diskgroup diskgrpA drop disk disk6; |
Remove disk group | drop diskgroup diskgrpA including contents |
resizing disk group | alter diskgroup diskgrpA resize disk 'disk3' size 500M; |
Undo remove disk group | alter database diskgrpA undrop disks; |
Display diskgroup info | select name, group_number, name, type, state, total_mb, free_mb from v$asm_diskgroup; |
Rebalance a diskgroup (after disk failure and disk has been replaced) | alter diskgroup diskgrpA rebalance power 8; Note: to speed up rebalancing increase the level upto 11, remember that this will also decrease performance, you can also use the wait parameter this will hold the commandline until it is finished |
Dismount or mount a diskgroup | alter diskgroup diskgrpA dismount; |
Check a diskgroups integrity | alter diskgroup diskgrpA check all; |
Diskgroup Directory | alter diskgroup diskgrpA add directory '+diskgrpA/dir1' Note: this is required if you use aliases when creating databse files i.e '+diskgrpA/dir/control_file1' |
adding and drop aliases | alter diskgroup diskgrpA add alias '+diskgrpA/dir/second.dbf' for '+diskgrpB/datafile/table.763.1'; alter diskgroup diskgrpA drop alias '+diskgrpA/dir/second.dbf' |
Drop files from a diskgroup | alter diskgroup diskgrpA drop file '+diskgrpA/payroll/payroll.dbf'; |
Using ASM Disks |
|
Examples of using ASM disks | create tablespace test datafile ‘+diskgrpA’ size 100m; |
Display performance | select path, reads, writes, read_time, write_time, read_time/decode(reads,0,1,reads) "AVGRDTIME", write_time/decode(writes,0,1,writes) "AVGWRTIME" from v$asm_disk_stat; |
RMAN backup
RMAN is the only way to backup ASM disks.
Backup | backup as copy database format ‘+dgroup1’ |