Tuesday, April 19, 2011

ASM

ASM Basics

·         The smallest unit of storage written to disk is called an "allocation unit" (AU) and is usually 1MB (4MB recommended for Exadata)
·         Very simply, ASM is organized around storing files
·         Files are divided into pieces called "extents"
·         Extent sizes are typically equal to 1 AU, except in 11.1 and 11.2 where it will use variable extent sizes that can be 1, 8, 64 AUs  or   1, 4, 16 AUs respectively
·         File extent locations are maintained by ASM using file extent maps.
·         ASM maintains file metadata in headers on the disks rather than in a data dictionary
·         The file extent maps are cached in the RDBMS shared pool; these are consulted when an RDBMS process does I/O
·         ASM is very crash resilient since it uses instance / crash recovery similar to a normal RDBMS (similar to using undo and redo logging)

ASM Diskgroups 

Creating Diskgroup:

CREATE DISKGROUP disk_group_1 NORMAL
REDUNDANCY
FAILGROUP failure_group_1 DISK
'/devices/diska1' NAME diska1,
'/devices/diska2' NAME diska2,
FAILGROUP failure_group_2 DISK
'/devices/diskb1' NAME diskb1,
'/devices/diskb2' NAME diskb2;

NOTE :  The above disk group given as NORMAL redundancy, that means it contain 2 Fail groups (i.e., 2 sets of each data is maintained) also similarly for HIGH redundancy each data is made into thrice(1 original and 2 duplicates) so it makes 3 fail groups in Disk group

Drop disk groups
DROP DISKGROUP DATA INCLUDING CONTENTS;

Add disks
ALTER DISKGROUP DATA ADD DISK '/dev/sda3';

Drop a disk
ALTER DISKGROUP DATA DROP DISK DATA_0001;

Resize all disks in a disk group
ALTER DISKGROUP DATA RESIZE ALL SIZE 100G;

UNDROP DISKS clause of the ALTER DISKGROUP
ALTER DISKGROUP DATA UNDROP DISKS;

Rebalance diskgroup
ALTER DISKGROUP DATA REBALANCE POWER 5;

Check Diskgroup
ALTER DISKGROUP DATA CHECK;
ALTER DISKGROUP DATA CHECK NOREPAIR;

Diskgroup Metadata Backup
md_backup -b asm_backup.mdb.txt -g data,fra

ASM Specific Init.ora Parameters
*.cluster_database=true
*.asm_diskstring='/dev/sd*1'
*.instance_type=asm
*.shared_pool_size=100M
*.large_pool_size=80M
*.db_cache_size=60M
*.asm_diskgroups='DATA','FRA'

Initialize ASM for non-RAC
./localconfig add

Manually start CSSD (non-RAC)
/etc/init.d/init.cssd start

Manually stop CSSD ( non-RAC)
/etc/init.d/init.cssd stop

Resetting CSS to new Oracle Home
localconfig reset /apps/oracle/product/11.1.0/ASM

ASM Dictionary Views
v$asm_alias  ---list all aliases in all currently mounted diskgroups
v$asm_client ---list all the databases currently accessing the diskgroups
v$asm_disk ----lists all the disks discovered by the ASM instance.
v$asm_diskgroup ---Lists all the diskgroups discovered by the ASM instance.
v$asm_file ---Lists all files that belong to diskgroups mounted by the ASM instance.
v$asm_operation ---Reports information about current active operations. Rebalance activity is reported in this view.
v$asm_template ---Lists all the templates currently mounted by the ASM instance.
v$asm_diskgroup_stat ---same as v$asm_diskgroup but does discover new disgroups. Use this view instead of v$asm_diskgroup.
v$asm_disk_stat ---same as v$asm_disk but does not discover new disks. Use this view instead of v$asm_disk.

srvctl commands
ADD
srvctl add asm -n rac3 -i +ASM3 -o /opt/oracle/app/product/10.2.0/asm

ENABLE
srvctl enable asm -n rac3 -i +ASM3

DISABLE
srvctl disable asm -n rac3 -i +ASM3

START
srvctl start asm -n rac3

STOP
srvctl stop asm -n rac3

CONFIG
srvctl config asm -n rac1

REMOVE
srvctl remove asm -n rac1
STATUS
srvctl status asm
srvctl status asm -n rac1

MODIFY
srvctl modify asm -o -n rac1

ASMLIB commands ( as root)
/etc/init.d/oracleasm start
/etc/init.d/oracleasm stop
/etc/init.d/oracleasm restart
/etc/init.d/oracleasm configure
/etc/init.d/oracleasm status
/etc/init.d/oracleasm enable
/etc/init.d/oracleasm disable
/etc/init.d/oracleasm listdisks
/etc/init.d/oracleasm deletedisk
/etc/init.d/oracleasm scandisks
/etc/init.d/oracleasm querydisk /dev/sdb1
/etc/init.d/oracleasm createdisk /dev/sdb1 VOL1
/etc/init.d/oracleasm renamedisk /dev/sdb1 VOL1

asmcmd Commands
cd -----changes the current directory to  the specified directory
du -----Displays the total disk space occupied by ASM files in the specified
           ASM directory and all its subdirectories, recursively.
find -----Lists the paths of all occurrences of the specified name ( with wildcards) under the specified directory.
ls +data/testdb ----Lists the contents of an ASM  director, the attributes of the specified file, or the names and attributes of all disk groups.
lsct -----Lists information about current ASM clients.
lsdg ----Lists all disk groups and their attributes
mkalias ----Creates an alias for a system generated filename.
mkdir -----Creates ASM directories.
pwd --------Displays the path of the current ASM directory.
rm        -------Deletes the specified ASM Files or directories.
rm -f       
rmalias ---------Deletes the specified alias, retaining the file that the alias points to
lsdsk ----------Lists disks visible to ASM.
md_backup ------Creates a backup of all of the mounted disk groups.
md_restore ------Restores disk groups from a backup.
remap ----repairs a range of physical blocks on a disk.
cp ------copies files into and out of ASM.
          

SYSASM Role (Starting in Oracle Database 11g)
SQL> Grant sysasm to sys; ---sysdba deprecated sqlplus / as sysasm

ASM Rolling Upgrades START
alter system start rolling migration to 11.2.0.2;

DISABLE
alter system stop rolling migration;

Database INIT parameters for ASM.
*.control_files='+DATA/orcl/controlfile/control1.ctl','+FRA/orcl/controlfile/control2.ctl'
*.db_create_file_dest='+DATA'
*.db_create_online_log_dest_1='+DATA'
*.db_recovery_file_dest='+DATA'
*.log_archive_dest_1='LOCATION=+DATA'
*.log_file_name_convert='+DATA/VISKDR','+DATA/VISK' ##added for DG


Removing disks from an ASM disk group

      SQL> select group_number,name from v$asm_disk  order by group_number,name;

GROUP_NUMBER   NAME
------------ ------------------------------
1 ASM_ORADATA31_0000
1 ASM_ORADATA31_0001
1 ASM_ORADATA31_0002
1 ASM_ORADATA31_0003
1 ASM_ORADATA31_0004
1 ASM_ORADATA31_0005
2 ASM_ORADATA32_0000
2 ASM_ORADATA32_0001
2 ASM_ORADATA32_0002
2 ASM_ORADATA32_0003
2 ASM_ORADATA32_0004
2 ASM_ORADATA32_0005

12 rows selected.

SQL> ALTER DISKGROUP ASM_ORADATA31 DROP DISK ASM_ORADATA31_0005;
Diskgroup altered.

SQL> ALTER DISKGROUP ASM_ORADATA32 DROP DISK ASM_ORADATA32_0005;
Diskgroup altered.

SQL> select est_minutes from V$ASM_OPERATION;

EST_MINUTES
-----------
6

see:    Adding Disks to ASM diskgroup Manually


MIGRATE to ASM using RMAN
run
{
backup as copy database format '+DATA';
switch database to copy;
#For each logfile
sql "alter database rename '/data/oracle/VISK/redo1a.rdo' to '+DATA' ";
alter database open resetlogs;
#For each tempfile
sql "alter tablespace TEMP add tempfile" ;
}

Restore Database to ASM using SET NEWNAME 
run
{
allocate channel d1 type disk;
#For each datafile
set newname for datafile 1 to '+DATA';
restore database;
switch datafile all;
release channel d1;
}


Refer more Master Note for Automatic Storage Management (ASM) (Doc ID 1187723.1)
                  Information Center: Install and Configure Oracle Automatic Storage Management (Doc ID 1522675.2)


4 comments:

shailesh singh said...

Hi Chandu, as per my knowledge, external redundancy is on hardware level. Three failgroup is required in HIGH Redundancy.
Please correct me if i m going wrong.

chandu reddy said...

Yes you are right, thanks for the correction

venkat m said...

Thanks Bro..U really gave a valuable data...Please provide interview questions for 3 year experienced people...

Unknown said...

Thanks bro I can't thank you enough

Post a Comment

Auto Scroll Stop Scroll