Thursday, April 4, 2013

Automatic Storage Management (ASM) lessons 4

Using ASM Storage
We have discussed management of an ASM instance. This section covers how to actually
use ASM from an Oracle instance. You can put all sorts of Oracle-related files into an
ASM instance, including these:
  • Oracle datafiles
  • Database tempfiles
  • Online redo logs
  • Archived redo logs
  • Control files
  • Spfiles
  • RMAN backup sets
  • The flash recovery area (FRA)
  • Data-pump dump sets

What Are ASM Files?

We have already created ASM disk groups. To actually use the ASM disk groups, we have
to populate them with ASM files. In this section, we will discuss what ASM files are and
then we will discuss the different kinds of ASM filenames that you might deal with.

ASM Files
ASM files are created in a number of different ways; for example, when you execute the
create tablespace command and you indicate that the resulting datafile(s) should be
stored in an ASM disk group, the result will be the creation of ASM files in that ASM
disk group.A goodly number of Oracle file types can be stored in ASM, including datafiles, controlfiles, redo logs, and archived redo logs. There are some Oracle files that cannot be stored inan ASM group. These are mostly the administrative files like trace files, the alert log, andso on.

ASM Filename Types
When a file is created on an ASM disk, the filename is generated by ASM. There is a number of different kinds of ASM filename types:
  • Fully qualified ASM filenames
  • Numeric ASM filenames
  • Alias ASM filenames
  • Alias filenames with templates
  • Incomplete filenames
  • Incomplete filenames with templates .
For example,
  • 1. Fully Qualified ASM Filename: +group/dbname/file_type/file_type_tag.file.incarnation
    Example:
    +dgroup2/sample/controlfile/Current.256.541956473
  • 2. Numeric ASM Filename: +group.file.incarnation
    Example:
    +dgroup2.257.541956473
  • 3. Alias ASM Filenames: +group/dir_1/…/dir_n/filename
    Example:
    +dgroup1/myfiles/control_file1
    +dgroup2/mydir/second.dbf
  • 4. Alias ASM Filename with Template: +group(template_name)/alias
    Example:
    +dgroup1(my_template)/config1
  • 5. Incomplete ASM Filename:+group
    Example:
    +dgroup1
  • 6. Incomplete ASM Filename with Template: +group(template_name)
    Example:
    +dgroup1(my_template)
Note:- Incomplete ASM file names are most  commonly used by DBA.  Incomplete ASM file names are used only for file creation operations. They consist of a disk group name only. ASM will then use the appropriate default template to translate the incomplete ASM file name, as defined by its file type. For example, here is the SQL command I executed originally to create the TBSASM tablespace in the ASM1DG1 disk group:

SQL> CREATE TABLESPACE tbsasm DATAFILE '+ASM1DG1' SIZE 32M;

Defining ASM as the Default Destination for Database Files

If you decide you want to allow Oracle to create all file types as ASM file types, you can set the values of various parameters such that ASM will automatically be employed. One of the big benefits of this feature is the standardization of your database, ensuring that all files get placed where they belong and in the ASM structure to which they belong. You can define default ASM destinations be defining incomplete ASM filenames. The following database parameters take incomplete ASM filenames:

  • DB_CREATE_FILE_DEST
  • DB_CREATE_ONLINE_LOG_DEST_n
  • DB_RECOVERY_FILE_DEST
  • CONTROL_FILES
  • LOG_ARCHIVE_DEST_n (log_archive_dest_format will be ignored)
  • LOG_ARCHIVE_DEST (log_archive_dest_format will be ignored)
  • STANDBY_ARCHIVE_DEST

Here is an example of using an incomplete name when setting the DB_CREATE_FILE_DEST
parameter so that it will use the ASM disk group +sp_dgroup1:

SQL> alter system set db_create_file_dest=’+cooked_dgroup1’ scope=both;

Creating a Tablespace Using an ASM Disk Group as the Destination
There are different ways to create tablespaces using ASM disks. In this section, we will first look at creating an ASM tablespace, allowing the default ASM disk location to be used (as a result of having set the DB_CREATE_FILE_DEST parameter as we did earlier). We will then look at how to create a tablespace datafile by explicitly referencing the ASM disk group that it is supposed to be assigned to.

Creating Tablespaces Using Default ASM Assignments

Now that you have seen how to define a default ASM location, you can use the create
tablespace command to create a tablespace that will have a file in the ASM disk group by
default, as shown in this example:

SQL> create tablespace test_rgf datafile size 100k;
Let’s see where Oracle put the datafile now by querying the DBA_DATA_FILES view:

SQL> Select tablespace_name, file_name
from dba_data_files Where tablespace_name=’TEST_RGF’;
TABLESPACE FILE_NAME
---------- ---------------------------------------------------------
TEST_RGF +COOKED_DGROUP1/11gDB/datafile/test_rgf.256.613064385


You can have a mix of ASM datafiles and normal datafiles assigned to a tablespace, as shown in this create table statement:
SQL> Create tablespace part_asm_tbs Datafile ’c:\oracle\oradata\11gDB\part_asm_tbs_01.dbf’ size 10m, ’+COOKED_DGROUP1’ size 100k;

Let’s look and see where the datafiles were created:
SQL> Select tablespace_name, file_name from dba_data_files Where tablespace_name=’PART_ASM_TBS’;
TABLESPACE_NAME FILE_NAME
--------------- ------------------------------------------------------------
PART_ASM_TBS C:\ORACLE\ORADATA\11GDB\PART_ASM_TBS_01.DBF
PART_ASM_TBS +COOKED_DGROUP1/11GDB/datafile/part_asm_tbs.256.613066047


Note:- if you drop the PART_ASM_TBS tablespace, only the ASM files
related to that tablespace would be removed from the disk when you issue the drop
tablespace command. In cases such as these, you need to make sure you include the
including contents and datafiles parameter with the drop tablespace command.

Creating Tablespaces Referencing Specific ASM Disk Groups
There are going to be many times when you will not want to define a default ASM disk
group to write all tablespaces to. In this case, you will want to reference the specific ASM
disk group that you want a datafile created in when you issue the create tablespace command. Here is an example:
SQL> create tablespace another_test datafile ’+COOKED_DGROUP1’ size 100k;


No comments:

Post a Comment