Oracle 10g Automatic Storage Management (ASM), Part 2: Sample Implementation - Page 2December 22, 2005 Creating ASM Disk Groups without Using DBCAIf I am using DBCA to create my sample ASM instance, Oracle formats the commands necessary to create the initial ASM disk group(s) for the instance during its creation. However, I can also create the ASM disk groups separately after the necessary instance creation scripts have run successfully using the code shown in Listing 2.3. I have provided two different examples, one each for the Windows NT and Linux environments. Starting and Stopping an ASM InstanceAn ASM instance is managed in much the same way as a database instance, with a few exceptions. The major difference is that an ASM instance is never opened like a regular Oracle instance is opened, only mounted; therefore, I will either issue the STARTUP NOMOUNT; command to start just the ASM instance's memory processes, and then finish mounting the database with the ALTER DATABASE MOUNT; command. I can also open the ASM instance immediately by issuing the STARTUP MOUNT; command. Starting a Dormant ASM Instance. To start up a dormant ASM instance, I first have to remember to set the ORACLE_SID environment variable appropriately. In addition, before I can start the ASM instance in the Windows NT environment, I also need to remember to first start the Oracle Cluster Service as well as the ASM instance's service. Of course, I do not need to worry about this in the Linux environment the Cluster Service should have already been set up as part of the standard Linux installation of Oracle 10g. To start up the ASM instance, I then simply issue the STARTUP MOUNT command. Here is how a successful ASM instance startup appears in the Linux environment: $> export ORACLE_SID=+ASM $> sqlplus "sys as sysdba" SQL*Plus: Release 10.1.0.2.0 - Production on Tue Dec 13 16:58:17 2005 Copyright (c) 1982, 2004, Oracle. All rights reserved. Enter password: ******** Connected to an idle instance. SQL> startup mount; ASM instance started Total System Global Area 100663296 bytes Fixed Size 787648 bytes Variable Size 99875648 bytes Database Buffers 0 bytes Redo Buffers 0 bytes ASM diskgroups mounted Shutting Down an Active ASM Instance. To shut down this ASM instance, I once again set the ORACLE_SID environment variable and then simply issue the SHUTDOWN IMMEDIATE; command: $> export ORACLE_SID=+ASM $> sqlplus "sys as sysdba" SQL> Connected. SQL> shutdown immediate; ASM diskgroups dismounted ASM instance shutdown SQL> Implications of Shutting Down an Active ASM Instance. Now, a warning: When an ASM instance is shut down, it is important to be aware of the implications for any regular Oracle database instance that is using ASM files stored on that ASM instance. The ASM files will not be accessible to those regular Oracle databases until the ASM instance is restarted. Demonstrating ASM in a Sample DatabaseNow that I have explained how to create, start, and stop an ASM instance, I will next demonstrate how to add a tablespace to an existing Oracle database instance that uses the ASM instance's disk group instead of the database instance's disk storage to store the new tablespace's datafile. Creating an ASM-Managed Tablespace. What I really like about ASM is its simplicity. I no longer need to be concerned if the tablespace's datafile will fit on the drive or spindle I have targeted for storage; I simply inform ASM that it is responsible for storing the datafile and how large the datafile is, and ASM handles the rest. All I needed to do to create a new tablespace, TBS_ASM1, was to issue the following CREATE TABLESPACE command from a SQL*Plus session running against the database instance: SQL> CREATE TABLESPACE tbs_asm1 DATAFILE '+DGROUP1' SIZE 32M; Tablespace created. Note that I did not have to specify the exact location of the datafile, since ASM determined from the size of the tablespace exactly how it should be striped across the disks in the ASM disk group. Moreover, since ASM uses Oracle Managed Files (OMF) for naming the datafile, ASM automatically named the datafile using the appropriate OMF standard. (I will delve into ASM file naming conventions in greater detail in the next article in this series.) Even more interesting, I did not have to do anything special to inform the database instance that it needed to start up the appropriate Rebalancing (RBAL) and ASM Bridge (ASM) processes. As soon as this new tablespace was created, the database instance detected that ASM storage was in use, and it automatically started these two background processes, as this snippet from the database's alert log clearly shows: ... Sun Dec 11 18:35:00 2005 CREATE TABLESPACE tbs_asm1 DATAFILE '+DGROUP1' SIZE 32M Sun Dec 11 18:35:03 2005 Starting background process ASMB ASMB started with pid=21, OS id=776 Starting background process RBAL RBAL started with pid=22, OS id=3524 Sun Dec 11 18:35:09 2005 SUCCESS: diskgroup DGROUP1 was mounted Completed: CREATE TABLESPACE tbs_asm1 DATAFILE '+DGROUP1' SIZ ... Migrating an Existing Tablespace to ASM-Managed Storage. Another great thing about ASM: I did not have to recreate an existing tablespace when I wanted to migrate it to ASM storage. Instead, I used Recovery Manager (RMAN) to create an image copy of the tablespace's datafile, and then I simply migrated that datafile to ASM. To demonstrate, I created a new tablespace in the database instance. I then issued the appropriate RMAN commands to take the tablespace offline, create the image copy of the tablespace, transfer the tablespace to ASM, and then bring the tablespace back online. See Listing 2.4 for the SQL statements and RMAN commands that I used to complete this task. Setting Up Enterprise Manager (EM) for ASM Instance ManagementOracle 10g Enterprise Manager (EM) does provide a simple and elegant way to manage ASM storage; however, I needed to reconfigure my database instance's EM configuration to take advantage of these tools via the Enterprise Manager Configuration Assistant (EMCA). Once I had created the ASM instance and had then created at least one ASM-managed file in my database instance, I removed the original EM configuration for the database instance and then replaced it with a new EM configuration that fully supports ASM. A sample set of EMCA commands are shown in Listing 2.5. After I restarted the EM Database Console service for my database, I was then able to view details about the ASM instance as well by clicking on the ASM link on my database instance's home page (see Figure 2.3 for an example of that screen). I will explore the various diagnostic tools and maintenance operations available via EM in more detail in the next article in this series. Viewing ASM Instance Information Via SQL QueriesFinally, there are several dynamic and data dictionary views available to view an ASM configuration from within the ASM instance itself:
I was also able to query the following dynamic views against my database instance to view the related ASM storage components of that instance:
See Listing 2.6 for the SQL*Plus queries that I used to view information from the ASM and database instances. Next StepsThe next article in this series will concentrate on some of the more advanced features of ASM, including how to add disks to and remove disks from an ASM disk group, how to increase the survivability of ASM disk groups with additional striping and mirroring features, and how to monitor and manage ASM storage through the Enterprise Manager (EM) interface. References and Additional ReadingWhile there is no substitute for direct experience, reading the manual is not a bad idea, either. I have drawn upon the following Oracle 10g documentation for the deeper technical details of this article: B10130-02 Oracle Database Installation Guide 10g (10.1.0.2) For Windows, Section 2.5.3 B10739-01 Oracle Database Administrator's Guide, Chapter 12 B10743-01 Oracle Database Concepts, Chapter 14 B10755-01 Oracle Database Reference B10759-01 Oracle Database SQL Reference |
||||||||||||||||||||||||||||