ASM is the most powerful feature in 10G. As a DBA we don‘t worry about database file (Data file, control files, redo log files, archive logs RMAN backup set and so on) management task because ASM completely automates file management task. Only we deal with a few disk groups, instead for direct handling data files. (Example: When we use ASM enable database. We don‘t need to refer table space by filename. We just use simple Disk Group name)
Another big advantage is that 10G gives us power to by pass using a third- party LVM, mirroring and Striping our disk directly because ASM works as LVM and it also handle striping and mirroring functions.
As a DBA no need to perform relocation of data because ASM prevent disk fragmentation. ASM performs mirroring and stripping. Mirroring is applied on file basic rather then disk basic.
ASM automatically balance I/O.
Three major components are ASM Instance, Disk Group and ASM Files. In ASM Enable database, we first start the ASM instance (This is not a full database instance; just the memory structures and as such is very small and lightweight), ASM instance manage the Disk Group and help the database to access the ASM files
Important
The default database name is ―+ASM‖
The default RAC instance are ―+ASMn‖, where n is the node number The ASM database may be managed with srvctl command
Normally auto-managed by Oracle Functionality of ASM
Manage group of Disk, Called disk groups. Manages disk redundancy within a disk group
Provides near-optimal I/O balancing without any manual tuning Support largs file
Advantage of ASM
Disk Addition—Adding a disk becomes very easy. No downtime is required and file extents are redistributed automatically.
I/O Distribution—I/O is spread over all the available disks automatically, without manual intervention..
Stripe Width—Striping can be fine grained as in Redo Log Files (128K for faster transfer rate) and coarse for datafiles (1MB for transfer of a large number of blocks at one time). Buffering—The ASM filesystem is not buffered, making it direct I/O capable by design. Kernelized Asynch I/O—There is no special setup necessary to enable kernelized
asynchronous I/O, without using raw or third-party filesystems such as Veritas Quick I/O. Mirroring—Software mirroring can be set up easily, if hardware mirroring is not
ASM instance, Archicture and management
ASM Instance maintains the ASM file metadata. Database can use it to access the files directly. ASM does not mount the database files. ASM also does not have a data dictionary. ASM instance only manage the disk group, protect disk group and communication file metadata to database instance using ASM files.
ASM has own background process like SMON, PMON and LGWR process.
On ASM Instance side, the two new background processes introduce ASM rebalance Master (RBAL) and ASM rebalance (ARBn).
ASM rebalance Master (RBAL) is in charge of co-coordinating disk activity.
ASM rebalance (ARBn) perform the actual rebalancing work like moving data extents around.
On Database Instance side, two new background processes introduceRBAL and ASMB. RBAL process performs global open of the disks in the ASM disk groups.
ASMB background process connects as a foreground process into your ASM instance. Starting ASM Instance
We can use the STARTUP command with NOMOUNT, MOUNT, RESTRICT and FORCE option.
Database startup command, read the control file and mount the file system specified in the control file but ASM startup command, mount the disk group because ASM instance does not have any file system to mount.
STARTUP FORCE command, the ASM instance is shutdown with STARTUP ABORT command before restarting it.
STARTUP RESTRICT command, prevent any client Oracle database instance from connecting to the ASM instance.
Shutting Down Instance
SHUTDOWN and SHUTDOWN NORMAL (Instance wait for all connected database instance to terminate their ASM connections before shutting down)
SHUTDOWN IMMEDIATE and SHUTDOWN TRANSACTIONAL (ASM instance wait until all currently executing SQL in the dependent database completes, but does not wait for the database instance to disconnect.)
STHUDOWN ABORT (ASM instance instantly abort, all open connections to the ASM instance are terminated and All oracle database will terminate immediately.
Managing ASM Directories, Aliases, Files, Metadata and Template Important Note
We cannot use ASM for alert, trace, binary and password file.
Oracle automatically create ASM file with a specify redundancy level and stripping policy. This redundancy and stripping policies are set permanently for the file and we specify the attribute when we create disk group.
Only file created by ASM will be automatically deleted.
We never need to put file name at the time of database file creation, tablespace creating, adding and assign file to table space.
Operating System cannot see ASM file but RMAN and other oracle utility can view. Type of ASM Filenames
Fully Qualified ASM filenames Numeric ASM filenames Alias ASM filename Incomplete ASM filename
Fully Qualified ASM Filename: We use only for referencing existing ASM files. Example: +group/dbname/file_type/tag.file.incarnation
Group – is the disk group name. Dbname – Name of the database file_type – ASM file type tag – type specific about the file
file.incarnation – is the file/incarnation number pair, used to ensure uniqueness.
Important: We cannot supply a fully qualified ASM filename while creating a new file.
Numeric ASM filename: - The numeric ASM filename can be used for referencing existing files. It is derived from the fully qualified ASM filename and takes the form:
+group.file.incarnation
Numeric ASM filenames can be used in any interface that requires an existing file name. An example of a numeric ASM filename is:
+dgroup2.257.541956473
Alias ASM filename:- We can use ASM alias file both when creating new ASM files and when referring to existing file.
Incomplete ASM filename: - We can use an incomplete ASM filename only when creating files. Incomplete filenames include just the group name nothing else.
ASM Directories
How to create a directory:
ALTER DISKGROUP DB_DATA ADD DIRECTORY '+DB_DATA/my_dir'; How to rename a directory:
ALTER DISKGROUP DB_DATA RENAME DIRECTORY '+DB_DATA/my_dir' TO '+DB_DATA/my_dir_2';
How to delete a directory and all its contents:
Aliases
Aliases allow you to reference ASM files using user-friendly names, rather than the fully qualified ASM filenames.
How to create an alias using the fully qualified filename:
ALTER DISKGROUP DB_DATA ADD ALIAS '+DB_DATA/my_dir/my_file.dbf' FOR '+DB_DATA/mydb/datafile/my_ts.342.3';
How to create an alias using the numeric form filename:
ALTER DISKGROUP Db_DATA ADD ALIAS '+DB_DATA/my_dir/my_file.dbf' FOR '+DB_DATA.342.3';
How to rename an alias:
ALTER DISKGROUP DB_DATA RENAME ALIAS '+DB_DATA/my_dir/my_file.dbf' TO '+DB_DATA/my_dir/my_file2.dbf';
How to delete an alias:
ALTER DISKGROUP DB_DATA DELETE ALIAS '+DB_DATA/my_dir/my_file.dbf'; Files
Files are not deleted automatically if they are created using aliases, as they are not Oracle Managed Files (OMF), or if a recovery is done to a point-in-time before the file was created. For these circumstances it is necessary to manually delete the files, as shown below.
How to Drop file using an alias?
ALTER DISKGROUP DB_DATA DROP FILE '+DB_DATA/my_dir/my_file.dbf'; How to Drop file using a numeric form filename?
ALTER DISKGROUP Db_DATA DROP FILE '+DB_DATA.342.3'; How to Drop file using a fully qualified filename?
ALTER DISKGROUP DB_DATA DROP FILE'+DB_DATA/mydb/datafile/my_ts.342.3'; Metadata
The internal consistency of disk group metadata can be checked in a number of ways using the CHECK clause of the ALTER DISKGROUP statement.
ALTER DISKGROUP DB_DATA CHECK FILE '+DB_DATA/my_dir/my_file.dbf' How to check metadata for a specific failure group in the disk group?
ALTER DISKGROUP DB_DATA CHECK FAILGROUP failure_group_1; How to check metadata for a specific disk in the disk group?
ALTER DISKGROUP DB_DATA CHECK DISK diska1; How to check metadata for all disks in the disk group? ALTER DISKGROUP DB_DATA CHECK ALL;
Templates
Templates are named groups of attributes that can be applied to the files within a disk group. The following example show how templates can be created, altered and dropped.
How to create a new template?
ALTER DISKGROUP DB_DATA ADD TEMPLATE my_template ATTRIBUTES (MIRROR FINE);
How to modify template?
ALTER DISKGROUP DB_DATA ALTER TEMPLATE my_template ATTRIBUTES (COARSE);
How to Drop template?
ALTER DISKGROUP DB_DATA DROP TEMPLATE my_template; Important:
Available attributes include:
UNPROTECTED - No mirroring or striping regardless of the redundancy setting. MIRROR - Two-way mirroring for normal redundancy and three-way mirroring for high
redundancy. This attribute cannot be set for external redundancy.
COARSE - Specifies lower granuality for striping. This attribute cannot be set for external redundancy.
FINE - Specifies higher granularity for striping. This attribute cannot be set for external redundancy.
Managing ASM Disk Group
ASM Disk group is a collection of disks. When we add storage to our ASM system we simply add disk to an ASM Disk group.
We can create disk group by using Database Control Disk Group Administration page or manually by using CREATE DISKGROUP command.
How to Create DISK GROUP
Example:
Suppose we have two Disk Controller and a total six disks. DiskA1 through DiskA3 are on a separate SCSI Controller and DiskB1 through DiskB3 are on yet another disk controller. Here we create two failure group, each with three disks. The first three disk (DiskA1,DiskA2 and DiskA3) will be on disk controller 1 and second 3 disk (DiskB1,DiskB2 and DiskB3)will be on disk controller 2.
Now we start ASM instance in NOMOUNT mode. ASM instance is ready for create a disk group. Then we create Disk group to correspond with 2 fail groups.
SQL> create diskgroup DB_DATA normal redundancy
Failgroup groupA disk ‗/devices/DiskA1‘, ‗/devices/DiskA2‘, ‗/devices/DiskA3‘, Failgroup groupB disk ‗/devices/DiskB1‘, ‗/devices/DiskB2‘, ‗/devices/DiskB3‘,
When oracle writes data to the disks in the first failure group GroupA, it also wites those extents to disk in the other failure group Group B
Important:
When you don‘t specify a FAILGROUP clause, the disk is in its own failure group. Adding Disks to a Disk Group
ALTER DISKGROUP DB_DATA ADD DISK '/devices/DiskA4‘,‘/device/DiskB4'; Note:
1. When a disk is added, it is formatted and then rebalanced.
When you don‘t specify a FAILGROUP clause, the disk is in its own failure group. When you don‘t specify a REDUNDANCY clause, the disk is in its own failure group. 2. If you don't specify the NAME clause, Oracle assigns its own system-generated names. 3. If the disk already belongs to a disk group, the statement will fail.
Dropping disks and disk groups?
ALTER DISKGROUP DB_DATA DROP DISK DiskA4; DROP DISKGROUP DB_DATA INCLUDING CONTENTS;
Note:
DROPT DISKGROUP statements requires the instance to be in MOUNT state.
When a disk is dropped, the disk group is rebalanced by moving all of the file extents from the dropped disk to other disks in the disk group. The header on the dropped disk is then cleared.
If you specify the FORCE clause for the drop operation, the disk is dropped even if Automatic Storage Management cannot read or write to the disk.
You can also drop all of the disks in specified failure groups using the DROP DISKS IN FAILGROUP clause.
Rebalance Disk Group
ASM rebalance a disk group automatically, whenever we add or remove disks form disk group. Disk groups can be rebalanced manually using the REBALANCE clause of the ALTER DISKGROUP
statement. If the POWER clause is omitted the ASM_POWER_LIMIT parameter value is used. ALTER DISKGROUP DB_DATA REBALANCE POWER 5;
Resize the Disk
Resize a specific disk.
ALTER DISKGROUP DB_DATA RESIZE DISK DISK1 SIZE 100G; Resize all disks in a disk group.
ALTER DISKGROUP DB_DATA RESIZE ALL SIZE 100G; Undrop Disk
The UNDROP DISKS clause of the ALTER DISKGROUP statement allows pending disk drops to be undone. It will not revert drops that have completed, or disk drops associated with the dropping of a disk group.
ALTER DISKGROUP disk_group_1 UNDROP DISKS; Mount and Dismount the ASM DISKGROUP
Disk groups are mounted at ASM instance startup and unmounted at ASM instance shutdown. Manual mounting and dismounting can be accomplished using the ALTER DISKGROUP statement as seen below.
ALTER DISKGROUP ALL DISMOUNT; ALTER DISKGROUP ALL MOUNT;
ALTER DISKGROUP disk_group_1 MOUNT Move Non-ASM database to ASM
Step 1 Obtain current Datafile, Control file and redo log files locations using V$DATAFILE,