Thursday, July 17, 2008

Basics of ASM (Automatic Storage Management) - I

Here are some basics about using ASM storage. Installation and configuration is not in scope of this blog :-) The tips listed in this blog are helpful when you are working in an enviornment where ASM is already in use and you are completely novice with ASM

Using ASM

1. To use ASM storage you need to install an ASM instance.

2. ASM storage can be viewed and accessed using the command line utility called ASMCMD. To use ASMCMD, you need to first source the environment for ASM instance.

Following is a small demo of using ASMCMD:

oracle@ipw-dev-db:~> . oraenv
ORACLE_SID = [mydb] ? +ASM

oracle@ipw-dev-db:~> asmcmd

ASMCMD [+] > ls -l
State Type Rebal Unbal Name
MOUNTED EXTERN N N DATA/

ASMCMD [+] > cd +DATA

ASMCMD [+DATA] > ls -l
Type Redund Striped Time Sys Name
Y MYDB/
Y MYDB_1/

ASMCMD [+DATA] >

3. Commands that can be used in ASMCMD are:
mkdir, ls, rm, cd

4. ASM assigns its own names to the datafiles

5. ASM storage is entirely different from a normal filesystem storage.

Viewing ASM information

ASM information can be viewed by using dynamic performance views like v$asm_diskgroup. You need to login to the ASM instance to view this. Using ASMCMD or normal OS commands (like df –h), you can not directly know the vital information like size of the ASM diskgroup, free space etc. You have to query some relevant views to get this information. For example:

oracle@ipw-dev-db:~> sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.3.0 - Production on Thu Jul 17 01:27:08 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning and Data Mining options

SQL> select free_mb, total_mb from v$asm_diskgroup;

FREE_MB TOTAL_MB
---------- ----------
181331 664697

SQL>

Moving datafiles in ASM storage

1. Shutdown and start up the database in MOUNT state. Datafile movement should be done only in MOUNT state.

2. Connect to RMAN and target database without any recovery catalog

RMAN> Connect target /

3. Assuming that I am moving a datafile of database MYDB from ‘+DATA/mydb_1/datafile’ to ‘+DATA/mydb/datafile’

RMAN> copy datafile '+DATA/MYDB_1/DATAFILE/users.488.658972917' to '+DATA';
RMAN> switch datafile '+DATA/MYDB_1/DATAFILE/users.488.658972917' to copy;

4. You can move system and sysaux datafiles also similarly because the database is mounted and not open.

5. Switch command is responsible for updating the controlfile with the new location

Happy learning !!!! More to come (ofcourse as soon as i learn something worth sharing :-))

- Rohit