Migrate Oracle Database To ASM Using ASMCMD

Comments 0

Share to social media

Introduction

Oracle Database 10g Release 1 introduced Automatic Storage Management (ASM), a new framework for managing Oracle database files. ASM provides a foundation for highly efficient storage management with direct I/O, redundancy, striping and load balancing. Files stored on ASM are evenly distributed across disks in a disk group and mirrored according to the policies defined in the disk group. Since ASM provides an easy and highly efficient way to manage storage, it is the recommended file system for storing database files for RAC as well as single instance databases.

The following types of database files can be stored in ASM diskgroups:

  • Control files
  • Datafiles, temporary datafiles, and datafile copies
  • SPFILEs
  • Online redo logs, archive logs, and Flashback logs
  • RMAN backups
  • Disaster recovery configurations
  • Change tracking bitmaps
  • Data Pump dumpsets

To take advantage of ASM with an existing database using non-ASM storage, all or part of the database needs to be migrated into ASM. Native operating system commands such as Linux cp or Windows COPY cannot write or read files in ASM storage. Oracle provides the following means to access and manipulate ASM files:

  • Oracle Recovery Manager (RMAN): The preferred method for backup and recovery of databases contained in ASM. RMAN can also be used to migrate existing non-ASM databases into ASM.
  • ASMCMD: ASM command-line interface is used to interrogate and manage ASM. It includes many UNIX-like commands that can be used to manage the files and directories in an ASM system.
  • XML DB: ASM files and directories can be accessed through a virtual folder in the XML DB repository. XML DB provides a means to access and manipulate the ASM files and directories with programmatic APIs, such as the DBMS_XDB package, and with XML DB protocol services such as FTP and HTTP/WebDAV.
  • DBMS_FILE_TRANSFER: The DBMS_FILE_TRANSFER package provides procedures to:
    • Copy ASM files within a database
    • Transfer binary files in either direction between a local ASM instance and a remote database file
    • Transfer all combinations involving ASM and/or local file system, namely:
      • Local file system to local file system
      • Local file system to ASM
      • ASM to local file system
      • ASM to ASM

In this article, I will describe the necessary steps to migrate an existing Oracle database stored on the local file system to ASM using ASMCMD. This will include all datafiles, tempfiles, online redo log files, control files and the SPfile.

Current Setup:

Oracle database version: 11.2.0.3
Name of database : orcl
Type of storage: Local file system

Demonstration:

  • Determine the file names of the control files, datafiles, and online redo logs as they exist on the local file system for the orcl database. All of the files listed will be relocated from the local file system to ASM:

  • Set the CONTROL_FILES parameter in SPfile to the alias names of control files in the directory +DATA/orcl/oradata in DATA diskgroup. We will copy control files there later.

  • Perform a consistent shutdown of the database.

  • Copy control files, datafiles, and online redo logs from local file system into the directory +DATA/orcl/oradata in DATA diskgroup using ASMCMD.

  • Bring the database to the mount stage and verify that control files have been read from their new location in DATA disk group:

  • Rename data files and online redo log files to point to their new location in DATA diskgroup:

  • Open the database and verify that the data files and online redo log files have been read from their new location in DATA diskgroup:

We have successfully migrated all the datafiles, online redo log files and control files from local file system to ASM.

Now, let’s migrate tempfile also to ASM.

  • Find out name of the temporary tablespace and the tempfile associated with it.

  • In order to migrate the tempfile to ASM, add another tempfile on ASM diskgroup DATA and drop the earlier one.

Now, let’s migrate SPfile to ASM.

  • Find out name and location of the SPfile on local file system.

  • Create a copy of the SPFILE in the ASM disk group DATA and find out the name of the created file.

  • In $ORACLE_HOME/dbs create pfile initorcl.ora with an entry pointing to the new location of SPfile in ASM.

  • Rename the earlier SPfile on local filesystem. This step is not mandatory.

  • Restart the database and verify that SPfile has been read from its new location in ASM diskgroup DATA.

Thus we have successfully migrated all the datafiles, tempfiles, online redo log files, control files and SPfile for the database orcl from local file system to ASM using ASMCMD.

Load comments

About the author