Automatic Storage Management
Automatic Storage Management provides easy file management. DBA need not to manage huge physical file manual. ASM manage database physical files in disk. ASM uses Oracle-managed files and provides benefits of mirroring and striping. It divides files into 1 MB extents and extents get store in all disk available in disk group. So manual intervention to tune disk IO is not required. ASM provides the redundancy level on a per-file basis. In this way two file (original and mirror) can be stored on same disk group. ASM provides mirroring at extent level. ASM provides three mirroring types.
· 2-Way Mirroring I mirror copy of every extent
· 3-Way Mirroring 2 mirror copy of every extent
· Unprotected No mirroring. (Mirroring provided by the disk subsystem)
ASM provides features to manage storage without stopping database. When you add/drop disk in/from disk group ASM re balances file data across all the disks of disk group. ASM can be used with old database file system. ASM requires one Oracle instance with SGA(smaller SGA) and background process. ASM instance can be used for more that one database. ASM diskgroup can be shared among all databases running on that server.
In RAC, each instance will have an ASM instance, which communicate to other node ASM instance. ASM instance in RAC environment can manage one or more that one RAC database or one or more than one single instance database. ASM supports database data files, control files, log files, archive files. You need to use RMAN to backup ASM database.
ASM Components
· Groups
A disk group is group of disk managed together as one unit. Disk group may store various database's files. Single database may use storage from multiple disk groups. Disk group type specifies disk group mirroring. There are three type of redundancy
Normal Redundancy (2 way) (Default Redundancy)
High Redundancy (3 way)
External Redundancy (none or unprotected)
· Disk
ADM disks is disks in disk group, witch is a partition of a logical unit number (LUN) or a network attached file.
· Failure Group
Failure group is applicable only to normal and high redundancy disk groups. Failure group define common potential failure mechanism.
· Files
Files are written on ASM disk called ASM files, which are spaced across all the ASM disks in the disk group. ASM automatically generate file names. User-friendly file name also can be specified. A ASM file can be stored in only one disk group.
· Templates
Collections of file attributes, which are used to set mirroring/striping of database file are created in ASM disk group are called templates
ASM Two new Background Process
ASM instace should be started before starting datbase instance. When you start ASM instace it does not mount ASM database it manages meta data required to make ASM files are available to all ASM storage database instances. . ASM starts background process and allocate SGA (SGA is very less compated to regulare database SGA). All the database running on ASM storage communicate to ASM database to get the disk group infomation. ASM instance starts two more background process RBAL and ASMB, which are not availagle in regualr oracle database or RAC database. RBAL coordinate rebalances activity for disk groups whereas ASMB performs the actual rebalance activity for AU movements. Rest of ASM background process are same as Oracle instance. When ASM instance starts, ASMB connects as a foreground process into the ASM instance and RBAL performs global open of disk groups.
ASM and Recovery feautre
In RAC enviorment where multiple ASM instance mounts same disk groups. If one instance fails other instance automatically recovers ASM metadata changes caused by failed instance.
In single ASM instance where multiple ASM instance mounts different disk groups, if ASM instance failes during its uses, disk groups are not recoverered util they are monted again. When ASM mounts failed disk groups it reads logs and recovers all changes. Such senario is called ASM crash recovery. So in RAC invironment it is always recommened to mount same set of disk group on all ASM instance.
ASMLibs
ASMLibs is ASM library to support ASM feature. It provides efficeint machanism for accessing block devices used by the ASM disk groups. ASM library provides ASM I/O to Linux disk without the limitations of the startard UNIX I/O API.
Detail installation of ASMLibs and ASM i will cover in my other post. I would like to discuss here only basic aspect of ASMLib.
Following three package are required to install ASMLib which can be downloaded from http://www.oracle.com/technology/tech/linux/asmlib/index.html
oracleasm-support-2.0.3-2
oracleasm-2.6.9-42.0.0.0.1-Elsmp-2.0.3-2
oracleasm-2.6.9-42.0.0.0.1.EL-2.0.3-2
Exact name depends on version of Linux(OS), which I will discuss in my next blog.
After installing ASMLib package you can configure ASMLib by executing following
# /etc/init.d/oracleasm configure
You can create ASM disk as given below
# /etc/init.d/oracleasm createdisk VAOL1 /dev/sdc1
You can scan ASM on other node in RAC
#/etc/init.d/oracleasm scandisks
To list ASM disk
#/etc/init.d/oracleasm listdisks
Install ASMLib
Check kernal version and system architecutre
# uname -r
2.6.9-42.0.0.0.1.ELsmp
I downloaded following ASMLib package
oracleasm-support-2.0.3-2
oracleasm-2.6.9-42.0.0.0.1-Elsmp-2.0.3-2
oracleasm-2.6.9-42.0.0.0.1.EL-2.0.3-2
Install ASM package.
$rpm -Uvh oracleasm-support-2.0.3-2 \
oracleasm-2.6.9-42.0.0.0.1-Elsmp-2.0.3-2 \
oracleasm-2.6.9-42.0.0.0.1.EL-2.0.3-2
Configure ASM
# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library driver. The following questions will determine whether the driver is loaded on boot and what permissions it will have. The current values will be shown in brackets ('[]'). Hitting <ENTER> without typing an answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
"oracleasm configure" creates "/etc/sysconfig/oracleasm" configuration file and "/dev/oracleasm" mount points. It loads oracleasm kernel module and mounts ASM library driver file system.
ASM Disk Creation
Lists disk name
# /sbin/fdisk -l
Create ASM disk
# /etc/init.d/oracleasm createdisk disk1 /dev/sdb1
Make available asm disk to other node.
# /etc/init.d/oracleasm scandisks
# /etc/init.d/oracleasm -help
Usage: /etc/init.d/oracleasm {startstoprestartenabledisableconfigurecreatediskdeletediskquerydisklistdisksscandiskstatus} start/stop/restart: To start/stop/restart ASM library driver without restarting the system. enable/disable: To enable/disable ASM library driver when system starts. configure: To configure the ASM library driver createdisk: To use disk with ASM library deletedisk: To unmark a name disk querydisk: To check if disk name is being used by ASM Library driver. listdisks: To list disk names of marked ASM library driver disksscandisks: To inform RAC node which shared disks are marked as ASM library disks on another node.
Once disk is prapared I have set ASM_DISKSTRING parameter as /dev/oracleasm/disks/*, default value is "ORCL:DISK*".
ASM Database Instance Creation
To create ASM based database DBCA checkes if ASM instance is running on current node, if yes, it lists disk groups. If ASM is not running DBCA creates a new ASM instance. ASM instance are very small, 64MB SGA is enough for largets ASM installations.
ASM Instance Initialization Parameters
INSTANCE_TYPE=ASM # Set to ASM for ASM instance DB_UNIQUE_NAME=+ASM # Uniqe DB Name, defaul value +ASM ASM_POWER_LIMIT = 1 # Controls rebalance operation speed, Range 1 to 11(fastest), default value is 1. ASM_DISKSTRING= '/dev/oracleasm/disks/*', , ,
# ASM instance discovers disk mounted using this parameter if specified value is NULL ASM_DISKGROUPS=ORCL_DATA1,FLASH_RECOVERY_ARE # List of disk groups which should be mounted when instance starts or when "ALTER DISKGROUP ALL MOUNT is used"LARGE_POOL_SIZE=8MB
ASM instance & RAC
Select DBCA "Oracle RAC" database option and then select all nodes. DBCA create one ASM instance on each node automatically.
CLUSTER_DATABASE=TURE # Set this parameter in each ASM RAC instace to start global cache services.
ASM_DISKGROUP= ' ' # Instances can have different value but it is recomended to mount same value. Shared disk must be mounted on all ASM instance.
ASM_DISKSTRING=' ' * Multiple instance may have different value
Startup/Shotdown ASM Instance
SQL> connect / as sysdba
SQL>startup
Mount option mounts disk groups specified by ASM_DISKGROUPS init parameter. OPEN is invalid and NOMOUNT starts up ASM without mounting any disk group.
You can not stop ASM instance till its all client database instance are stopped. In case of SHUTDOWN NORMAL ASM waits for all session to disconnect . ASM SHUTDOWN IMMEDIATE, TRANSACTIONA, or ABORT, ASM immediately terminates its database instance connections hence all database immediately abort. When IMMEDIATE or TRANSACTIONAL is uses, ASM waits for in-progress ASM SQL to complete before shutting down ASM instance.
SQL> connect / as sysdba
SQL> SHUTDOWN IMMEDIATE
Create Disk Group
SQL>CREATE DISKGROUP ORCL_DATA1 NORMAL REDUNDANCY DISK 'ORCL:VOL1';
Drop disk group
SQL> DROP DISKGROUP ORCL_DATA1 INCLUDING CONTENTS;
Add Disk
SQL> ALTER DISKGROUP ORCL_DATA1 ADD DISK
'ORCL:VOL2';
SQL> ALTER DISKGROP ORCL_DATA1 ADD DISK '/dev/oracleasm/disks/*';
Above SQL will add disks (/dev/oracleasm/disks/*), which were not not added. ASM instance ensure that disk is usable and then it formates and reblances. It moves AUs from every file onto the new disks.
Drop disks.
SQL> ALTER DISKGROUP ORCL_DATA1 DROP DISK '/dev/oracleasm/disks/VOL4';
Cancel Previous Drop, it works for only pending drops not after drop completion.
SQL> ALTER DISKGROUP ORCL_DATA1 UNDROP DISKS;
To rebalance disk. POWER level of "0" halts rebalancing until command is reinvoked.
SQL> ALTER DISKGROUP ORCL_DATA1 REBALANCE POWER 5;
Mount/Dismount DISK GROUP.
SQL> ALTER DISKGROUP ORCL_DATA1 DISMOUNT;
To very internal consistency of disk group metadata and repair if error found.
SQL> ALTER DISKGROUP ORCL_DATA1 CHECK ALL;
Some time it takes long time to rebalance AU across disk. Such operation can be monitored using V$ASM_OPERATION
ASM Files
ASM files, oracle managed files are stored in ASM disk groups. ASM oracle managed files are automatically deleted when not required. ASM files created using alias are not deleted automatically. Manual intervention is required to delete such files. Each file in a disk group is spread across all disks in the DISK group, so backup of single disk not not useful. RMAN must be use to backup ASM files.
ASM does not manage binaries, alert logs, trace files, password files, and Cluster Ready Services files.
ASM File Name are of following forms
Fully Qualified ASM file names are used to refer existing ASM files. It specify a disk group name, database name, a file type, a type-specific tag, a file number and an incarnation number. When file is created even using alias, a fully qualified name is also created. Fully qualified ASM file names are also called system aliases,
<group>/<dbname>/<file_type>/<tag>.<file#>.<incarnation#>
+ORCL_DATA1/orcl/controlfile/current.256.623848779
Numeric ASM File name are used for refererencing existing ASM files. It specifis a disk group name, a file number and an incarnation number.
+ORCL_DATA1.257.8675309
Alias ASM file name can be used for referncing existing ASM file and for creating new ASM files. Alias name specify a disk group name and inclu a user-fiendly string insteand of file and incarnation number. Alias file name uses hierarchical directory structure. Total length of Alias ASM file name is limited to 256 bytes. File name can have space in between but not at begining or at end. Alias ASM file names are case-insensitive.
+ORCL_DATA1/myfiles/control_file1
Using "ALTER DISKGROUP ADD ALIAS" an alias can be created for existing file.
Alias ASM file name with templates are used only while ASM file creation. It specifies a disk group name, an alias name, and a file creation template name. e.g. +ORCL_DATA/config1(spfile).
Incomplete ASM file names used during ASM file creation. It uses disk group name only. It uses a default template for incomplete ASM file name specified by their file type. +ORCL_DATA1
Incomplete ASM file names with templates are used for file creation. It uses disk group name followed by a template name. File creation attributes are determined by template name. e.g. +dgroupA(datafile).
Template and Alias
SQL>ALTER DISKGROUP ORCL_DATA1
ADD TEMPLATE DATA1TEMP ATTRIBUTES (MIRROR);
SQL> ALTER DISKGROUP ORCL_DATA1 DROP TEMPLATE DATA1TEMP;
SQL> ALTER DISKGROUP ORCL_DATA1 ADD DIRECTORY '+ORCL_DATA1/jai';
SQL> ALTER DISKGROUP ORCL_DATA1 RENAME DIRECTORY '+ORCL_DATA1/jai' TO '+ORCL_DATA1/jai';
SQL> ALTER DISKGROUP ORCL_DATA1 ADD ALIAS '+ORCL_DATA1/jai/users.dbf' FOR '+ORCL_DATA1/orcl/datafile/users.265.623849191';
SQL> ALTER DISKGROUP ORCL_DATA1 RENAME ALIAS '+ORCL_DATA1/jai/users.dbf' TO '+ORCL_DATA1/jai/users1.dbf' ;
SQL> ALTER DISKGROUP ORCL_DATA1 DROP ALIAS '+ORCL_DATA1/jai/users1.dbf' ;
SQL> ALTER DISKGROUP ORCL_DATA1 DROP DIRECTORY '+ORCL_DATA1/jai';
SQL> ALTER DISKGROUP ORCL_DATA1 DROP FILE '+ORCL_DATA1/jai/users1.dbf' ;
List Aliases Information
SQL> SELECT reference_index INTO :al_id FROM V$ASM_ALIAS WHERE NAME='+ORCL_DATA1';
SQL> SELECT reference_index INTO :al_id FROM V$ASM_ALIAS WHERE PARENT_INDEX=:al_id AND NAME='jai' ; REM jai is direcotry name
SQL> SELECT name FROM V$ASM_ALIAS WHERE parent_index=al_id;
ASM Data Dictionary View
V$ASM_DISKGROUP To check disk group information (Number, name, size, state, redundancy type). in DB instance one row for every disk group mounted by ASM instance.
V$ASM_DISK One row for every discovered disk in ASM instance. In DB instance, disk used by database.
V$ASM_FILE In ASM instance one row for every ASM file in all disk group mounted by ASM instance. DB instance contains no rows.
V$ASM_TEMPLATE In ASM and DB, one row for every templated present in disk group mounted by ASM instance.
V$ASM_ALIAS In ASM instance one row for every alias present in every disk mounted by ASM
V$ASM_OPERATION, To check long running ASM opertaion in ASM instance
V$ASM_CLIENT In ASM instance lists databases using disk group managed by the ASM instance. In DB instance list one row if database has any open ASM files.
No comments:
Post a Comment