Thursday, March 28, 2013

Automatic Storage Management (ASM) lessons 1
Automatic Storage Management (ASM) provides a centralized way to manage Oracle Database disk storage.ASM is somewhat like a logical volume manager, allowing you to reduce the management of Oracle files into ASM disk groups. It also provides redundancy configurations, rebalancing operations, and, when installed on top of clusterware, the ability to share database-related files.

Here are some features of ASM:
  • Automatic software data striping (RAID-0)
  • Load balancing across physical disks 
  • Software RAID-1 data redundancy with double or triple mirrors 
  • Elimination of fragmentation 
  • Simplification of file management via support for Oracle Managed Files (OMF) 
  • Ease of maintenance

Creating the ASM Instance
1. Creating the ASM Instance with the DBCA:- 
Before going with dbca we need to install CSS service .  ASM cannot be used until Oracle CSS service is started.
C:\Windows\system32>localconfig add
Step 1:  creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'admin', privgrp ''..
Operation successful.
Step 2:  creating new CSS service
successfully created local CSS service
successfully added CSS to home
C:\Windows\system32>

To create the ASM instance with the DBCA, do the following:
1. Start the Oracle DBCA.
2. The DBCA presents a list of options for you to choose from. Select Configure Automatic
Storage Management and click Next.
3. The DBCA then prompts you for the SYS password for the new ASM instance to be
created. Enter the password for the SYS account.
4. Oracle then creates the ASM instance. A new window appears giving you the option
to create new disk groups. You can choose to create disk groups (we will cover that
shortly) or you can click Finish to complete the ASM instillation.
5. The name of the resulting instance will be +ASM. You can log into the ASM instance
from SQL*Plus, as shown in this example:

C:\Windows\system32>sqlplus
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Mar 26 12:06:14 2013
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
+asm

SQL>

In 11g we will use sys as sysasm for connecting to asm instance.

Creating the ASM Instance Manually
Manual creation of an ASM instance is fairly straightforward. If you have ever manually
created a database, then manually creating an ASM instance should be easy for you. To
manually create an ASM instance, you would follow these steps:
1. Create directories for the ASM instance.
2. Create the instance parameter file.
3. Perform any Microsoft Windows–specific configuration.
4. Start the ASM instance.
5. Create the ASM server parameter file (spfile).
Let’s look at each of these steps in a bit more detail

The following steps can be used to create a fully functional ASM instance named +ASM. The node I am using in this example also has a regular 10g database running named TESTDB. These steps should all be carried out by the oracle UNIX user account:
  1. Create Admin DirectoriesWe start by creating the admin directories from the ORACLE_BASE. The admin directories for the existing database on this node, (TESTDB), is located at $ORACLE_BASE/admin/TESTDB. The new +ASM admin directories will be created alongside the TESTDB database:
    UNIX
    mkdir -p $ORACLE_BASE/admin/+ASM/bdump
    mkdir -p $ORACLE_BASE/admin/+ASM/cdump
    mkdir -p $ORACLE_BASE/admin/+ASM/hdump
    mkdir -p $ORACLE_BASE/admin/+ASM/pfile
    mkdir -p $ORACLE_BASE/admin/+ASM/udump
    Microsoft Windows
    mkdir %ORACLE_BASE%\admin\+ASM\bdump
    mkdir %ORACLE_BASE%\admin\+ASM\cdump
    mkdir %ORACLE_BASE%\admin\+ASM\hdump
    mkdir %ORACLE_BASE%\admin\+ASM\pfile
    mkdir %ORACLE_BASE%\admin\+ASM\udump
  2. Create Instance Parameter FileIn this step, we will manually create an instance parameter file for the ASM instance. This is actually an easy task as most of the parameters that are used for a normal instance are not used for an ASM instance. Note that you should be fine by accepting the default size for the database buffer cache, shared pool, and many of the other SGA memory sructures. The only exception is the large pool. I like to manually set this value to at least 12MB. In most cases, the SGA memory footprint is less then 100MB. Let's start by creating the file init.ora and placing that file in$ORACLE_BASE/admin/+ASM/pfile. The initial parameters to use for the file are:
    UNIX
    $ORACLE_BASE/admin/+ASM/pfile/init.ora
    ###########################################
    # Automatic Storage Management
    ###########################################
    # _asm_allow_only_raw_disks=false
    # asm_diskgroups='TESTDB_DATA1'
    
    # Default asm_diskstring values for supported platforms:
    #     Solaris (32/64 bit)   /dev/rdsk/*
    #     Windows NT/XP         \\.\orcldisk*
    #     Linux (32/64 bit)     /dev/raw/*
    #     HPUX                  /dev/rdsk/*
    #     HPUX(Tru 64)          /dev/rdisk/*
    #     AIX                   /dev/rhdisk/*
    # asm_diskstring=''
    
    ###########################################
    # Diagnostics and Statistics
    ###########################################
    background_dump_dest=/u01/app/oracle/admin/+ASM/bdump
    core_dump_dest=/u01/app/oracle/admin/+ASM/cdump
    user_dump_dest=/u01/app/oracle/admin/+ASM/udump
    
    ###########################################
    # Miscellaneous
    ###########################################
    instance_type=asm
    compatible=10.1.0.4.0
    
    ###########################################
    # Pools
    ###########################################
    large_pool_size=12M
    
    ###########################################
    # Security and Auditing
    ###########################################
    remote_login_passwordfile=exclusive
    Microsoft Windows
    %ORACLE_BASE%\admin\+ASM\pfile\init.ora
    ###########################################
    # Automatic Storage Management
    ###########################################
    # _asm_allow_only_raw_disks=false
    # asm_diskgroups='TESTDB_DATA1'
    
    # Default asm_diskstring values for supported platforms:
    #     Solaris (32/64 bit)   /dev/rdsk/*
    #     Windows NT/XP         \\.\orcldisk*
    #     Linux (32/64 bit)     /dev/raw/*
    #     HPUX                  /dev/rdsk/*
    #     HPUX(Tru 64)          /dev/rdisk/*
    #     AIX                   /dev/rhdisk/*
    # asm_diskstring=''
    
    ###########################################
    # Diagnostics and Statistics
    ###########################################
    background_dump_dest=C:\oracle\product\10.1.0\admin\+ASM\bdump
    core_dump_dest=C:\oracle\product\10.1.0\admin\+ASM\cdump
    user_dump_dest=C:\oracle\product\10.1.0\admin\+ASM\udump
    
    ###########################################
    # Miscellaneous
    ###########################################
    instance_type=asm
    compatible=10.1.0.4.0
    
    ###########################################
    # Pools
    ###########################################
    large_pool_size=12M
    
    ###########################################
    # Security and Auditing
    ###########################################
    remote_login_passwordfile=exclusive

    After creating the $ORACLE_BASE/admin/+ASM/pfile/init.ora file, UNIX users should create the following symbolic link:
    $ ln -s $ORACLE_BASE/admin/+ASM/pfile/init.ora $ORACLE_HOME/dbs/init+ASM.ora


Identify RAW Devices
Before starting the ASM instance, we should identify the RAW device(s) (UNIX) or logical drives (Windows) that will be used as ASM disks. For the purpose of this article, I have four RAW devices setup on Linux:
# ls -l /dev/raw/raw[1234]
crw-rw----  1 oracle dba 162, 1 Jun  2 22:04 /dev/raw/raw1
crw-rw----  1 oracle dba 162, 2 Jun  2 22:04 /dev/raw/raw2
crw-rw----  1 oracle dba 162, 3 Jun  2 22:04 /dev/raw/raw3
crw-rw----  1 oracle dba 162, 4 Jun  2 22:04 /dev/raw/raw4

   Attention Linux Users!This article does not use Oracle's ASMLib I/O libraries. If you plan on using Oracle's ASMLib, you will need to install and configure ASMLib, as well as mark all disks using:
/etc/init.d/oracleasm createdisk <ASM_VOLUME_NAME> <LINUX_DEV_DEVICE>
. For more information on using Oracle ASMLib, see "Installing Oracle10g Release 1 (10.1.0) on Linux - (RHEL 4)".


   Attention Windows Users!A task that must to be performed for Microsoft Windows users is to tag the logical drives that you will want to use for ASM storage. This is done using a new utility that is included with Oracle Database 10g called asmtool. This tool can be run either before or after creating the ASM instance. asmtool is responsible for initializing the drive headers and marks drives for use by ASM. This really assists in reducing the risk of overwriting a usable drive that is being used for normal operating system files.


Starting the ASM Instance
Once the instance parameter file is in place, it is time to start the ASM instance. It is important to note that an ASM instance never mounts an actual database. The ASM instance is responsible for mounting and managing disk groups.
   Attention Windows Users!If you are running in Microsoft Windows, you will need to manually create a new Windows service to run the new instance. This is done using the ORADIM utility which allows you to create both the instance and the service in one command.

UNIX

# su - oracle
$ ORACLE_SID=+ASM; export ORACLE_SID
$ sqlplus "/ as sysdba"

SQL> startup
ASM instance started
Total System Global Area   75497472 bytes
Fixed Size                   777852 bytes
Variable Size              74719620 bytes
Database Buffers                  0 bytes
Redo Buffers                      0 bytes
ORA-15110: no diskgroups mounted

SQL> create spfile from pfile='/u01/app/oracle/admin/+ASM/pfile/init.ora';

SQL> shutdown
ASM instance shutdown

SQL> startup
ASM instance started
Microsoft Windows
C:\> oradim -new -asmsid +ASM -syspwd change_on_install 
    -pfile C:\oracle\product\10.1.0\admin\+ASM\pfile\init.ora -spfile 
    -startmode manual -shutmode immediate
Instance created.
C:\> oradim -edit -asmsid +ASM -startmode a
C:\> set oracle_sid=+ASM
C:\> sqlplus "/ as sysdba"

SQL> startup pfile='C:\oracle\product\10.1.0\admin\+ASM\pfile\init.ora';
ASM instance started
Total System Global Area    125829120 bytes
Fixed Size                    769268 bytes
Variable Size               125059852 bytes
Database Buffers                   0 bytes
Redo Buffers                       0 bytes
ORA-15110: no diskgroups mounted 

SQL> create spfile from pfile='C:\oracle\product\10.1.0\admin\+ASM\pfile\init.ora';
File created.
SQL> shutdown
ASM instance shutdown
SQL> startup
ASM instance started
You will notice when starting the ASM instance, we received the error:
ORA-15110: no diskgroups mounted
This error can be safely ignored.Notice also that we created a server parameter file (SPFILE) for the ASM instance. This allows Oracle to automatically record new disk group names in the asm_diskgroups instance parameter, so that those disk groups can be automatically mounted whenever the ASM instance is started.
Now that the ASM instance is started, all other Oracle database instances running on the same node will be able to find it.
Note the following Oracle parameters that are specific to ASM instances,
INSTANCE_TYPE  : Used only with an ASM instance, this parameter indicated to Oracle
that this is an ASM instance. The default value is RDBMS, which indicates the instance is
an Oracle database instance. This parameter is not dynamic and is the only mandatory
parameter in an ASM instance.
ASM_DISKSTRING  : This parameter indicates where Oracle should search for disk devices
to be used by ASM. We will discuss this parameter in more detail later in this section.
This parameter can be dynamically changed.
ASM_DISKGROUPS  : This parameter lists ASM disk groups that ASM should mount when
it is started. You can also use the alter diskgroup all mount command to cause
these disk groups to be mounted. This parameter can be dynamically changed.
ASM_POWER_LIMIT  : This parameter controls the rate at which ASM can rebalance disks by
increasing or decreasing the degree of parallelism used. Lower values will slow rebalancing
but will also result in less of an IO impact by those operations. Higher values may
speed up rebalancing by parallelizing the rebalance operation. The default is 1, and this
is typically sufficient. This parameter can be set dynamically.

No comments:

Post a Comment