This chapter from Oracle Database 11g: A Beginner's Guide explains how to work with high availability features in Oracle 11g such as Real Application Clusters (RAC), Automatic Storage Management (ASM), and Data Guard. In this section, learn how to work with ASM in Oracle, including how to set up an ASM instance and create ASM Disk Groups.
Define high availability
Define, Install and Test Real Application Clusters (RAC)
ASM Instance and ASM Disk Groups
How to manage an ASM instance with ASMCMD and ASMLIB
Implementing Oracle 11g data guard and data guard protection modes
Creating an Oracle physical standby server
As mentioned with the RAC environment, Automatic Storage Management (ASM) is both the file and disk manager for the Oracle database files. Now you might be thinking that this seems like a more advanced topic, and possibly too detailed for a beginner's guide. However, ASM is an important component in a highly available database environment and for addressing performance issues and management of Oracle files. Even after years of working with applications and databases, there is always I/O contention, and reading and writing to disk is a main part of what a database does. So, a database administrator ends up understanding more about disk, mirroring, and striping than they might really want to know. Debating different RAID strategies and optimizing I/O may seem like intermediate topics, but even some of these areas are handled by ASM and have simplified the management of the Oracle disk and file needs.
There are several more in-depth discussions and topics revolving around ASM, but this chapter will provide only a general introduction as well as the basic configuration and how to get started with ASM.
In large databases, the number of data files for an instance can grow out of control; even a tablespace for a large environment can become unmanageable. Then, any disk migrations or moving of tablespaces becomes a very difficult task and leaves areas of vulnerabilities open due to the sheer number of data files. ASM manages the files using disk groups, and disks are added to the disk groups even while the database is open and running and the ASM instance is being accessed.
CRITICAL SKILL 8.5
Set Up the ASM Instance
In Oracle 11g, the ASM instance can now be set up as a cluster for providing rolling patches, and one ASM instance manages the files for one RAC node or one single Oracle server. An ASM instance can manage the following files for all of the instances on each cluster node: control files, data files, tempfiles, spfiles, redo logs, archive logs, RMAN backups, Data Pump dumpsets, and flashback logs. Just as with the RAC instance, the ASM instance will fail over to the other nodes in the cluster and continue to manage the disk.
RAC is not necessary for using ASM. In fact, ASM can be installed on a single server as well as used in a RAC environment. However, an ASM instance is needed for each server. In Figure 8-4, you'll see two standalone servers, each with their own ASM instance. Even though each server needs its own ASM instance, one ASM instance can manage the files for more than one database instance on that server. Each of the databases for that ASM instance on that server has access to all of the disk groups, which are the available disks that have been allocated by creating groups.
FIGURE 8-4. ASM instance standalone
As you can see in Figure 8-5, the difference with ASM instances in the RAC environment is that they are also instances that are available for failover; this means that RAC components need to be available to manage the failover. An ASM instance is still created on each node, but the instances manage the disk groups and files across all of the nodes.
FIGURE 8-5. ASM instance RAC
An ASM instance is a small database instance because it is basically the memory structures, and this provides the framework for managing disk groups. The disk groups contain several physical disks and can be from different disk formats. The formats can be a raw disk partition, LUNS (hardware RAID), LVM (redundant functionality), or NFS (can load balance over NFS system and doesn't depend on the OS to support NFS). However, the advantage of ASM is using raw devices which bypass any OS buffering.
The ASM instance can be created on installation of the Oracle software or by using Database Configuration Assistant (dbca). The name of the instance normally starts with +ASM, and then the Oracle Cluster Synchronization Server (CSS) must be configured. This service is added with the localconfig script, which will add the OCR repository that is necessary for ASM. Also, there is a new role to log in as administrator of the ASM instance, SYSASM. The OS group of OSASM goes along with this new role.
The following are screenshots from creating the ASM instance using the Database Configuration Assistant or dbca. In walking through the configuration of a database, you have a choice to create a regular database or to configure Automatic Storage Management. If you want to create a database using ASM, the ASM instance needs to be created first. However, you can also migrate an existing database to ASM, allowing the instance to be created for that migration as well. Either way, the dbca (see Figure 8-6) provides an easy way to get the ASM instance created.
FIGURE 8-6. Creating ASM instance in dbca
If the Oracle Cluster Synchronization Server (CSS) has not yet been started, a message will come up that says it needs to be running in order to configure ASM. Another window can be opened to start this; the command is provided in the pop-up window as shown in Figure 8-7.
Now the ASM instance is ready to be created, so a click on OK, as shown in Figure 8-8, will create the ASM instance. Now you'll just need to configure the parameters for finding the available disks and the disk groups.
In order for the ASM instance to discover the available disks, an initialization parameter is used: ASM_DISKSTRING. Other parameters include ASM_DISKGROUPS, which specifics which files are managed by ASM, and ASM_POWER_LIMIT, which is the default value for disk rebalancing. INSTANCE_TYPE is set to indicate that the instance is an ASM instance and not a database:
Parameters: ASM_DISKGROUPS = CONTROLFILE, DATAFILE, LOGFILE ASM_DISKSTRING = /dev/rdsk/* ASM_POWER_LIMIT = 0 /* 0 to 11 0 disables and 11 to enable rebalancing more quickly */ INSTANCE_TYPE = ASM
FIGURE 8-7. Creating ASM instance (CSS)
FIGURE 8-8. Creating ASM instance (Completion)
Disk groups can be created during instance creation. After the instance is created, sqlplus is used to start up ASM. Project 8-1 Install ASMLib
For Linux, there is an option for using raw devices or ASMLib to manage the available disks for Automatic Storage Management. ASMLib is a tool that will need to be installed as a Linux operating system package.
Step by Step
1. After installing the packages as the root user, the Linux software, and the Oracle software, the following packages are needed for the ASMLib:
# rpm –Uvh oracleasm-support-2.0.1.-1.i386.rpm # rpm –Uvh oracleasmlib-2.0.1.-1.i386.rpm # rpm –Uvh oracleasm-2.6.9-34.ELsmp-2.0.1-1.i686.rpm2. Verify that the package is installed:
# rpm –q oracleasm*
3. The previous step installed the ASMLib software. Now, to configure, run the following:
# /etc/init.d/oracleasm configure
4. With the ASMLib software installed, the available partitions can be used to create ASM disks:
# /etc/init.d/oracleasm createdisk VOL1 /dev/disk1 # /etc/init.d/oracleasm createdisk VOL2 /dev/disk2
5. To view the disks from the OS level that were just created: # /etc/init.d/oracleasm listdisks
VOL1 VOL2Project Summary
This project has taken you through the steps to install the package needed for the ASMLib utility, as well as demonstrated some of the tasks that can be completed using this command-line utility. Having ASMLib configured will be useful for managing ASM disks and files.
CRITICAL SKILL 8.6
Create ASM Disk Groups Starting up the ASM instance is very similar to a database instance. Instead of connecting as SYSDBA, SYASM should be used:
ORACLE_SID=+ASM SQLPLUS /NOLOG SQL> connect SYS as SYSASM Enter password: sys_password Connected to an idle instance. SQL> STARTUP ASM instance started
Shutdown is also similar to database instances, but the IMMEDIATE clause checks for databases that are still connected to the ASM instance and returns an error if this is the case. Any databases connected to the ASM instance during a shutdown abort will also abort:
SQL> SHUTDOWN NORMALIMMEDIATEABORT
The redundancy type for a DISKGROUP is specified when the group is created and cannot be changed. However new groups can be created with different redundancy types and then migrated to. There are three types of redundancy: EXTERNAL, NORMAL, and HIGH. With EXTERNAL, ASM is not providing any redundancy, and is assuming that an outside source is such as the storage array is providing fault tolerance. NORMAL requires two groups for failover and will handle the failure of one group. HIGH redundancy provides three-way failover and needs three groups. The NORMAL and HIGH redundancies also eliminate the single point of failure for the ASM disk. A small number of disk groups can normally be used even for a large database.
Project 8-2: Create Disk Groups
The next steps will give the commands for creating disk groups with external redundancy or normal redundancy. Once the groups are created they are available to create tablespaces.
Step by Step
1. Create disk groups by using the following:
SQL> create diskgroup DGEXT1 external redundancy disk '/dev/rdsk1/disk1'; SQL> create diskgroup DGNORM1 normal redundancy disk FAILGROUP controller1 DISK '/dev/rdsk/disk1' name disk1, '/dev/rdsk/disk2' name disk2 FAILGROUP controller2 DISK '/dev/rdsk/disk3' name disk3, '/dev/rdsk/disk4' name disk4;
2. Now that you've created the disk groups, validate them by looking at the views that give you information about disks and disk groups:
select * from v$asm_disks;
select name, state from v$asm_diskgroups; NAME STATE ---------------------- -------------------DGEXT1 MOUNTED DGNORM1 MOUNTED
3. Adding disks to the disk groups can be done as needed to be able to grow space for the databases:
alter DISKGROUP DGNORM1 add DISK '/dev/rdsk/disk5' name disk5, '/dev/rdsk/disk6' name disk6;
4. After ASM is started and disk groups are created it is as simple as saying CREATE TABLESPACE ts_data1, or the disk group name can be used in place of the data file name as used in a non-ASM database:
Create tablespace DATATBS1 datafile '+DGNORM1' size 1024M;
This project walked through how to create and alter disk groups. After the creation of the disk groups, steps were taken to verify the disk groups were created or altered as expected.