Skip to main content
Enterprise applications

Oracle database host data copy

Contributors jfsinmsp

As with database-level migration, migration at the host layer provides a storage vendor–independent approach.

In other words, sometime "just copy the files" is the best option.

Although this low-tech approach might seem too basic, it does offer significant benefits because no special software is required and the original data remains safely untouched during the process. The primary limitation is the fact that a file-copy data migration is a disruptive process, because the database must be shut down before the copy operation begins. There is no good way to synchronize changes within a file, so the files must be completely quiesced before copying begins.

If the shutdown required by a copy operation is not desirable, the next best host-based option is leveraging a logical volume manager (LVM). Many LVM options exist, including Oracle ASM, all with similar capabilities, but also with some limitations that must be taken into account. In most cases, the migration can be accomplished without downtime and disruption.

Filesystem to filesystem copying

The usefulness of a simple copy operation should not be underestimated. This operation requires downtime during the copy process, but it is a highly reliable process and requires no special expertise with operating systems, databases, or storage systems. Furthermore, it is very safe because it does not affect the original data. Typically, a system administrator changes the source file systems to be mounted as read-only and then reboots a server to guarantee that nothing can damage the current data. The copy process can be scripted to make sure that it runs as quickly as possible without risk of user error. Because the type of I/O is a simple sequential transfer of data, it is highly bandwidth efficient.

The following example demonstrates one option for a safe and rapid migration.

Environment

The environment to be migrated is as follows:

  • Current file systems

    ontap-nfs1:/host1_oradata       52428800  16196928  36231872  31% /oradata
    ontap-nfs1:/host1_logs          49807360    548032  49259328   2% /logs
  • New file systems

    ontap-nfs1:/host1_logs_new      49807360       128  49807232   1% /new/logs
    ontap-nfs1:/host1_oradata_new   49807360       128  49807232   1% /new/oradata

Overview

The database can be migrated by a DBA by simply shutting down the database and copying the files, but the process is easily scripted if many databases must be migrated or minimizing downtime is critical. The use of scripts also reduces the chance for user error.

The example scripts shown automate the following operations:

  • Shutting down the database

  • Converting the existing file systems to a read-only state

  • Copying all data from the source to target file systems, which preserves all file permissions

  • Unmounting the old and new file systems

  • Remounting the new file systems at the same paths as the prior file systems

Procedure

  1. Shut down the database.

    [root@host1 current]# ./dbshut.pl NTAP
    ORACLE_SID = [oracle] ? The Oracle base has been set to /orabin
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 15:58:48 2015
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
    SQL> Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
    NTAP shut down
  2. Convert the file systems to read-only. This can be done more quickly by using a script, as shown in Convert File System to Read Only.

    [root@host1 current]# ./mk.fs.readonly.pl /oradata
    /oradata unmounted
    /oradata mounted read-only
    [root@host1 current]# ./mk.fs.readonly.pl /logs
    /logs unmounted
    /logs mounted read-only
  3. Confirm that the file systems are now read-only.

    ontap-nfs1:/host1_oradata on /oradata type nfs (ro,bg,vers=3,rsize=65536,wsize=65536,addr=172.20.101.10)
    ontap-nfs1:/host1_logs on /logs type nfs (ro,bg,vers=3,rsize=65536,wsize=65536,addr=172.20.101.10)
  4. Synchronize file system contents with the rsync command.

    [root@host1 current]# rsync -rlpogt --stats --progress --exclude=.snapshot /oradata/ /new/oradata/
    sending incremental file list
    ./
    NTAP/
    NTAP/IOPS.dbf
     10737426432 100%  153.50MB/s    0:01:06 (xfer#1, to-check=10/13)
    NTAP/iops.dbf.zip
        22823573 100%   12.09MB/s    0:00:01 (xfer#2, to-check=9/13)
    ...
    NTAP/undotbs02.dbf
      1073750016 100%  131.60MB/s    0:00:07 (xfer#10, to-check=1/13)
    NTAP/users01.dbf
         5251072 100%    3.95MB/s    0:00:01 (xfer#11, to-check=0/13)
    Number of files: 13
    Number of files transferred: 11
    Total file size: 18570092218 bytes
    Total transferred file size: 18570092218 bytes
    Literal data: 18570092218 bytes
    Matched data: 0 bytes
    File list size: 277
    File list generation time: 0.001 seconds
    File list transfer time: 0.000 seconds
    Total bytes sent: 18572359828
    Total bytes received: 228
    sent 18572359828 bytes  received 228 bytes  162204017.96 bytes/sec
    total size is 18570092218  speedup is 1.00
    [root@host1 current]# rsync -rlpogt --stats --progress --exclude=.snapshot /logs/ /new/logs/
    sending incremental file list
    ./
    NTAP/
    NTAP/1_22_897068759.dbf
        45523968 100%   95.98MB/s    0:00:00 (xfer#1, to-check=15/18)
    NTAP/1_23_897068759.dbf
        40601088 100%   49.45MB/s    0:00:00 (xfer#2, to-check=14/18)
    ...
    NTAP/redo/redo02.log
        52429312 100%   44.68MB/s    0:00:01 (xfer#12, to-check=1/18)
    NTAP/redo/redo03.log
        52429312 100%   68.03MB/s    0:00:00 (xfer#13, to-check=0/18)
    Number of files: 18
    Number of files transferred: 13
    Total file size: 527032832 bytes
    Total transferred file size: 527032832 bytes
    Literal data: 527032832 bytes
    Matched data: 0 bytes
    File list size: 413
    File list generation time: 0.001 seconds
    File list transfer time: 0.000 seconds
    Total bytes sent: 527098156
    Total bytes received: 278
    sent 527098156 bytes  received 278 bytes  95836078.91 bytes/sec
    total size is 527032832  speedup is 1.00
  5. Unmount the old file systems and relocate the copied data. This can be done more quickly by using a script, as shown in Replace File System.

    [root@host1 current]# ./swap.fs.pl /logs,/new/logs
    /new/logs unmounted
    /logs unmounted
    Updated /logs mounted
    [root@host1 current]# ./swap.fs.pl /oradata,/new/oradata
    /new/oradata unmounted
    /oradata unmounted
    Updated /oradata mounted
  6. Confirm that the new file systems are in position.

    ontap-nfs1:/host1_logs_new on /logs type nfs (rw,bg,vers=3,rsize=65536,wsize=65536,addr=172.20.101.10)
    ontap-nfs1:/host1_oradata_new on /oradata type nfs (rw,bg,vers=3,rsize=65536,wsize=65536,addr=172.20.101.10)
  7. Start the database.

    [root@host1 current]# ./dbstart.pl NTAP
    ORACLE_SID = [oracle] ? The Oracle base has been set to /orabin
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 16:10:07 2015
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    Connected to an idle instance.
    SQL> ORACLE instance started.
    Total System Global Area  805306368 bytes
    Fixed Size                  2929552 bytes
    Variable Size             390073456 bytes
    Database Buffers          406847488 bytes
    Redo Buffers                5455872 bytes
    Database mounted.
    Database opened.
    SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
    NTAP started

Fully automated cutover

This sample script accepts arguments of the database SID followed by common-delimited pairs of file systems. For the example shown above, the command is issued as follows:

[root@host1 current]# ./migrate.oracle.fs.pl NTAP /logs,/new/logs /oradata,/new/oradata

When executed, the example script attempts to perform the following sequence. It terminates if it encounters an error in any step:

  1. Shut down the database.

  2. Convert the current file systems to read-only status.

  3. Use each comma-delimited pair of file system arguments and synchronize the first file system to the second.

  4. Dismount the prior file systems.

  5. Update the /etc/fstab file as follows:

    1. Create a backup at /etc/fstab.bak.

    2. Comment out the prior entries for the prior and new file systems.

    3. Create a new entry for the new file system that uses the old mountpoint.

  6. Mount the file systems.

  7. Start the database.

The following text provides an execution example for this script:

[root@host1 current]# ./migrate.oracle.fs.pl NTAP /logs,/new/logs /oradata,/new/oradata
ORACLE_SID = [oracle] ? The Oracle base has been set to /orabin
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 17:05:50 2015
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
NTAP shut down
sending incremental file list
./
NTAP/
NTAP/1_22_897068759.dbf
    45523968 100%  185.40MB/s    0:00:00 (xfer#1, to-check=15/18)
NTAP/1_23_897068759.dbf
    40601088 100%   81.34MB/s    0:00:00 (xfer#2, to-check=14/18)
...
NTAP/redo/redo02.log
    52429312 100%   70.42MB/s    0:00:00 (xfer#12, to-check=1/18)
NTAP/redo/redo03.log
    52429312 100%   47.08MB/s    0:00:01 (xfer#13, to-check=0/18)
Number of files: 18
Number of files transferred: 13
Total file size: 527032832 bytes
Total transferred file size: 527032832 bytes
Literal data: 527032832 bytes
Matched data: 0 bytes
File list size: 413
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 527098156
Total bytes received: 278
sent 527098156 bytes  received 278 bytes  150599552.57 bytes/sec
total size is 527032832  speedup is 1.00
Succesfully replicated filesystem /logs to /new/logs
sending incremental file list
./
NTAP/
NTAP/IOPS.dbf
 10737426432 100%  176.55MB/s    0:00:58 (xfer#1, to-check=10/13)
NTAP/iops.dbf.zip
    22823573 100%    9.48MB/s    0:00:02 (xfer#2, to-check=9/13)
... NTAP/undotbs01.dbf
   309338112 100%   70.76MB/s    0:00:04 (xfer#9, to-check=2/13)
NTAP/undotbs02.dbf
  1073750016 100%  187.65MB/s    0:00:05 (xfer#10, to-check=1/13)
NTAP/users01.dbf
     5251072 100%    5.09MB/s    0:00:00 (xfer#11, to-check=0/13)
Number of files: 13
Number of files transferred: 11
Total file size: 18570092218 bytes
Total transferred file size: 18570092218 bytes
Literal data: 18570092218 bytes
Matched data: 0 bytes
File list size: 277
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 18572359828
Total bytes received: 228
sent 18572359828 bytes  received 228 bytes  177725933.55 bytes/sec
total size is 18570092218  speedup is 1.00
Succesfully replicated filesystem /oradata to /new/oradata
swap 0 /logs /new/logs
/new/logs unmounted
/logs unmounted
Mounted updated /logs
Swapped filesystem /logs for /new/logs
swap 1 /oradata /new/oradata
/new/oradata unmounted
/oradata unmounted
Mounted updated /oradata
Swapped filesystem /oradata for /new/oradata
ORACLE_SID = [oracle] ? The Oracle base has been set to /orabin
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 17:08:59 2015
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area  805306368 bytes
Fixed Size                  2929552 bytes
Variable Size             390073456 bytes
Database Buffers          406847488 bytes
Redo Buffers                5455872 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
NTAP started
[root@host1 current]#

Oracle ASM spfile and passwd migration

One difficulty in completing migration involving ASM is the ASM-specific spfile and the password file. By default, these critical metadata files are created on the first ASM disk group defined. If a particular ASM disk group must be evacuated and removed, the spfile and password file that govern that ASM instance must be relocated.

Another use case in which these files might need to be relocated is during a deployment of database management software such as SnapManager for Oracle or the SnapCenter Oracle plug- in. One of the features of these products is to rapidly restore a database by reverting the state of the ASM LUNs hosting the data files. Doing so requires taking the ASM disk group offline before performing a restore. This is not a problem as long as a given database's data files are isolated in a dedicated ASM disk group.

When that disk group also contains the ASM spfile/passwd file, the only way the disk group can be brought offline is to shut down the entire ASM instance. This is a disruptive process, which means that the spfile/passwd file would need to be relocated.

Environment

  1. Database SID = TOAST

  2. Current data files on +DATA

  3. Current logfiles and controlfiles on +LOGS

  4. New ASM disk groups established as +NEWDATA and +NEWLOGS

ASM spfile/passwd file locations

Relocating these files can be done nondisruptively. However, for safety, NetApp recommends shutting down the database environment so that you can be certain that the files have been relocated and the configuration is properly updated. This procedure must be repeated if multiple ASM instances are present on a server.

Identify ASM instances

Identify the ASM instances based on the data recorded in the oratab file. The ASM instances are denoted by a + symbol.

-bash-4.1$ cat /etc/oratab | grep '^+'
+ASM:/orabin/grid:N             # line added by Agent

There is one ASM instance called +ASM on this server.

Make sure all databases are shut down

The only smon process visible should be the smon for the ASM instance in use. The presence of another smon process indicates that a database is still running.

-bash-4.1$ ps -ef | grep smon
oracle     857     1  0 18:26 ?        00:00:00 asm_smon_+ASM

The only smon process is the ASM instance itself. This means that no other databases are running, and it is safe to proceed without risk of disrupting database operations.

Locate files

Identify the current location of the ASM spfile and password file by using the spget and pwget commands.

bash-4.1$ asmcmd
ASMCMD> spget
+DATA/spfile.ora
ASMCMD> pwget --asm
+DATA/orapwasm

The files are both located at the base of the +DATA disk group.

Copy files

Copy the files to the new ASM disk group with the spcopy and pwcopy commands. If the new disk group was recently created and is currently empty, it might need to be mounted first.

ASMCMD> mount NEWDATA
ASMCMD> spcopy +DATA/spfile.ora +NEWDATA/spfile.ora
copying +DATA/spfile.ora -> +NEWDATA/spfilea.ora
ASMCMD> pwcopy +DATA/orapwasm +NEWDATA/orapwasm
copying +DATA/orapwasm -> +NEWDATA/orapwasm

The files have now been copied from +DATA to +NEWDATA.

Update ASM instance

The ASM instance must now be updated to reflect the change in location. The spset and pwset commands update the ASM metadata required for starting the ASM disk group.

ASMCMD> spset +NEWDATA/spfile.ora
ASMCMD> pwset --asm +NEWDATA/orapwasm

Activate ASM using updated files

At this point, the ASM instance still uses the prior locations of these files. The instance must be restarted to force a reread of the files from their new locations and to release locks on the prior files.

-bash-4.1$ sqlplus / as sysasm
SQL> shutdown immediate;
ASM diskgroups volume disabled
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started
Total System Global Area 1140850688 bytes
Fixed Size                  2933400 bytes
Variable Size            1112751464 bytes
ASM Cache                  25165824 bytes
ORA-15032: not all alterations performed
ORA-15017: diskgroup "NEWDATA" cannot be mounted
ORA-15013: diskgroup "NEWDATA" is already mounted

Remove old spfile and password files

If the procedure has been performed successfully, the prior files are no longer locked and can now be removed.

-bash-4.1$ asmcmd
ASMCMD> rm +DATA/spfile.ora
ASMCMD> rm +DATA/orapwasm

Oracle ASM to ASM copy

Oracle ASM is essentially a lightweight combined volume manager and file system. Because the file system is not readily visible, RMAN must be used to perform copy operations. Although a copy-based migration process is safe and simple, it results in some disruption. The disruption can be minimized, but not fully eliminated.

If you want nondisruptive migration of an ASM-based database, the best option is to leverage ASM's capability to rebalance ASM extents to new LUNs while dropping the old LUNs. Doing so is generally safe and nondisruptive to operations, but it offers no back- out path. If functional or performance problems are encountered, the only option is to migrate the data back to the source.

This risk can be avoided by copying the database to the new location rather than moving data, so that the original data is untouched. The database can be fully tested in its new location before going live, and the original database is available as a fall- back option if problems are found.

This procedure is one of many options involving RMAN. It is designed to allow a two-step process in which the initial backup is created and then later synchronized through log replay. This process is desirable to minimize downtime because it allows the database to remain operational and serving data during the initial baseline copy.

Copy database

Oracle RMAN creates a level 0 (complete) copy of the source database currently located on the ASM disk group +DATA to the new location on +NEWDATA.

-bash-4.1$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sun Dec 6 17:40:03 2015
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
connected to target database: TOAST (DBID=2084313411)
RMAN> backup as copy incremental level 0 database format '+NEWDATA' tag 'ONTAP_MIGRATION';
Starting backup at 06-DEC-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=302 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/TOAST/DATAFILE/system.262.897683141
...
input datafile file number=00004 name=+DATA/TOAST/DATAFILE/users.264.897683151
output file name=+NEWDATA/TOAST/DATAFILE/users.258.897759623 tag=ONTAP_MIGRATION RECID=5 STAMP=897759622
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 06-DEC-15
channel ORA_DISK_1: finished piece 1 at 06-DEC-15
piece handle=+NEWDATA/TOAST/BACKUPSET/2015_12_06/nnsnn0_ontap_migration_0.262.897759623 tag=ONTAP_MIGRATION comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-DEC-15

Force archive log switch

You must force an archive log switch to make sure that the archive logs contain all data required to make the copy fully consistent. Without this command, key data might still be present in the redo logs.

RMAN> sql 'alter system archive log current';
sql statement: alter system archive log current

Shut down source database

Disruption begins in this step because the database is shut down and placed in a limited-access, read-only mode. To shut down the source database, run the following commands:

RMAN> shutdown immediate;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> startup mount;
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area     805306368 bytes
Fixed Size                     2929552 bytes
Variable Size                390073456 bytes
Database Buffers             406847488 bytes
Redo Buffers                   5455872 bytes

Controlfile backup

You must back up the controlfile in case you must abort the migration and revert to the original storage location. A copy of the backup controlfile isn't 100% required, but it does make the process of resetting the database file locations back to the original location easier.

RMAN> backup as copy current controlfile format '/tmp/TOAST.ctrl';
Starting backup at 06-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=358 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/tmp/TOAST.ctrl tag=TAG20151206T174753 RECID=6 STAMP=897760073
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 06-DEC-15

Parameter updates

The current spfile contains references to the controlfiles on their current locations within the old ASM disk group. It must be edited, which is easily done by editing an intermediate pfile version.

RMAN> create pfile='/tmp/pfile' from spfile;
Statement processed

Update pfile

Update any parameters referring to old ASM disk groups to reflect the new ASM disk group names. Then save the updated pfile. Make sure that the db_create parameters are present.

In the example below, the references to +DATA that were changed to +NEWDATA are highlighted in yellow. Two key parameters are the db_create parameters that create any new files at the correct location.

*.compatible='12.1.0.2.0'
*.control_files='+NEWLOGS/TOAST/CONTROLFILE/current.258.897683139'
*.db_block_size=8192
*. db_create_file_dest='+NEWDATA'
*. db_create_online_log_dest_1='+NEWLOGS'
*.db_domain=''
*.db_name='TOAST'
*.diagnostic_dest='/orabin'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=TOASTXDB)'
*.log_archive_dest_1='LOCATION=+NEWLOGS'
*.log_archive_format='%t_%s_%r.dbf'

Update init.ora file

Most ASM-based databases use an init.ora file located in the $ORACLE_HOME/dbs directory, which is a point to the spfile on the ASM disk group. This file must be redirected to a location on the new ASM disk group.

-bash-4.1$ cd $ORACLE_HOME/dbs
-bash-4.1$ cat initTOAST.ora
SPFILE='+DATA/TOAST/spfileTOAST.ora'

Change this file as follows:

SPFILE=+NEWLOGS/TOAST/spfileTOAST.ora

Parameter file recreation

The spfile is now ready to be populated by the data in the edited pfile.

RMAN> create spfile from pfile='/tmp/pfile';
Statement processed

Start database to start using new spfile

Start the database to make sure that it now uses the newly created spfile and that any further changes to system parameters are correctly recorded.

RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area     805306368 bytes
Fixed Size                     2929552 bytes
Variable Size                373296240 bytes
Database Buffers             423624704 bytes
Redo Buffers                   5455872 bytes

Restore controlfile

The backup controlfile created by RMAN can also be restored by RMAN directly to the location specified in the new spfile.

RMAN> restore controlfile from '+DATA/TOAST/CONTROLFILE/current.258.897683139';
Starting restore at 06-DEC-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=417 device type=DISK
channel ORA_DISK_1: copied control file copy
output file name=+NEWLOGS/TOAST/CONTROLFILE/current.273.897761061
Finished restore at 06-DEC-15

Mount the database and verify the use of the new controlfile.

RMAN> alter database mount;
using target database control file instead of recovery catalog
Statement processed
SQL> show parameter control_files;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      +NEWLOGS/TOAST/CONTROLFILE/cur
                                                 rent.273.897761061

Log replay

The database currently uses the data files in the old location. Before the copy can be used, they must be synchronized. Time has passed during the initial copy process, and the changes have been logged primarily in the archive logs. These changes are replicated as follows:

  1. Perform an RMAN incremental backup, which contains the archive logs.

    RMAN> backup incremental level 1 format '+NEWLOGS' for recover of copy with tag 'ONTAP_MIGRATION' database;
    Starting backup at 06-DEC-15
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=62 device type=DISK
    channel ORA_DISK_1: starting incremental level 1 datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=+DATA/TOAST/DATAFILE/system.262.897683141
    input datafile file number=00002 name=+DATA/TOAST/DATAFILE/sysaux.260.897683143
    input datafile file number=00003 name=+DATA/TOAST/DATAFILE/undotbs1.257.897683145
    input datafile file number=00004 name=+DATA/TOAST/DATAFILE/users.264.897683151
    channel ORA_DISK_1: starting piece 1 at 06-DEC-15
    channel ORA_DISK_1: finished piece 1 at 06-DEC-15
    piece handle=+NEWLOGS/TOAST/BACKUPSET/2015_12_06/nnndn1_ontap_migration_0.268.897762693 tag=ONTAP_MIGRATION comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    channel ORA_DISK_1: starting incremental level 1 datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 06-DEC-15
    channel ORA_DISK_1: finished piece 1 at 06-DEC-15
    piece handle=+NEWLOGS/TOAST/BACKUPSET/2015_12_06/ncsnn1_ontap_migration_0.267.897762697 tag=ONTAP_MIGRATION comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-DEC-15
  2. Replay the log.

    RMAN> recover copy of database with tag 'ONTAP_MIGRATION';
    Starting recover at 06-DEC-15
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile copies to recover
    recovering datafile copy file number=00001 name=+NEWDATA/TOAST/DATAFILE/system.259.897759609
    recovering datafile copy file number=00002 name=+NEWDATA/TOAST/DATAFILE/sysaux.263.897759615
    recovering datafile copy file number=00003 name=+NEWDATA/TOAST/DATAFILE/undotbs1.264.897759619
    recovering datafile copy file number=00004 name=+NEWDATA/TOAST/DATAFILE/users.258.897759623
    channel ORA_DISK_1: reading from backup piece +NEWLOGS/TOAST/BACKUPSET/2015_12_06/nnndn1_ontap_migration_0.268.897762693
    channel ORA_DISK_1: piece handle=+NEWLOGS/TOAST/BACKUPSET/2015_12_06/nnndn1_ontap_migration_0.268.897762693 tag=ONTAP_MIGRATION
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    Finished recover at 06-DEC-15

Activation

The controlfile that was restored still references the data files at the original location, and it also contains the path information for the copied data files.

  1. To change the active data files, run the switch database to copy command.

    RMAN> switch database to copy;
    datafile 1 switched to datafile copy "+NEWDATA/TOAST/DATAFILE/system.259.897759609"
    datafile 2 switched to datafile copy "+NEWDATA/TOAST/DATAFILE/sysaux.263.897759615"
    datafile 3 switched to datafile copy "+NEWDATA/TOAST/DATAFILE/undotbs1.264.897759619"
    datafile 4 switched to datafile copy "+NEWDATA/TOAST/DATAFILE/users.258.897759623"

    The active data files are now the copied data files, but there still might be changes contained within the final redo logs.

  2. To replay all of the remaining logs, run the recover database command. If the message media recovery complete appears, the process was successful.

    RMAN> recover database;
    Starting recover at 06-DEC-15
    using channel ORA_DISK_1
    starting media recovery
    media recovery complete, elapsed time: 00:00:01
    Finished recover at 06-DEC-15

    This process only changed the location of the normal data files. The temporary data files must be renamed, but they do not need to be copied because they are only temporary. The database is currently down, so there is no active data in the temporary data files.

  3. To relocate the temporary data files, first identify their location.

    RMAN> select file#||' '||name from v$tempfile;
    FILE#||''||NAME
    --------------------------------------------------------------------------------
    1 +DATA/TOAST/TEMPFILE/temp.263.897683145
  4. Relocate temporary data files by using an RMAN command that sets the new name for each data file. With Oracle Managed Files (OMF), the complete name is not necessary; the ASM disk group is sufficient. When the database is opened, OMF links to the appropriate location on the ASM disk group. To relocate files, run the following commands:

    run {
    set newname for tempfile 1 to '+NEWDATA';
    switch tempfile all;
    }
    RMAN> run {
    2> set newname for tempfile 1 to '+NEWDATA';
    3> switch tempfile all;
    4> }
    executing command: SET NEWNAME
    renamed tempfile 1 to +NEWDATA in control file

Redo log migration

The migration process is nearly complete, but the redo logs are still located on the original ASM disk group. Redo logs cannot be directly relocated. Instead, a new set of redo logs is created and added to the configuration, followed by a drop of the old logs.

  1. Identify the number of redo log groups and their respective group numbers.

    RMAN> select group#||' '||member from v$logfile;
    GROUP#||''||MEMBER
    --------------------------------------------------------------------------------
    1 +DATA/TOAST/ONLINELOG/group_1.261.897683139
    2 +DATA/TOAST/ONLINELOG/group_2.259.897683139
    3 +DATA/TOAST/ONLINELOG/group_3.256.897683139
  2. Enter the size of the redo logs.

    RMAN> select group#||' '||bytes from v$log;
    GROUP#||''||BYTES
    --------------------------------------------------------------------------------
    1 52428800
    2 52428800
    3 52428800
  3. For each redo log, create a new group with a matching configuration. If you are not using OMF, you must specify the full path. This is also an example that uses the db_create_online_log parameters. As was shown previously, this parameter was set to +NEWLOGS. This configuration allows you to use the following commands to create new online logs without the need to specify a file location or even a specific ASM disk group.

    RMAN> alter database add logfile size 52428800;
    Statement processed
    RMAN> alter database add logfile size 52428800;
    Statement processed
    RMAN> alter database add logfile size 52428800;
    Statement processed
  4. Open the database.

    SQL> alter database open;
    Database altered.
  5. Drop the old logs.

    RMAN> alter database drop logfile group 1;
    Statement processed
  6. If you encounter an error that prevents you from dropping an active log, force a switch to the next log to release the lock and force a global checkpoint. An example is shown below. The attempt to drop logfile group 3, which was located on the old location, was denied because there was still active data in this logfile. A log archiving following a checkpoint allows you to delete the logfile.

    RMAN> alter database drop logfile group 3;
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of sql statement command at 12/08/2015 20:23:51
    ORA-01623: log 3 is current log for instance TOAST (thread 4) - cannot drop
    ORA-00312: online log 3 thread 1: '+LOGS/TOAST/ONLINELOG/group_3.259.897563549'
    RMAN> alter system switch logfile;
    Statement processed
    RMAN> alter system checkpoint;
    Statement processed
    RMAN> alter database drop logfile group 3;
    Statement processed
  7. Review the environment to make sure that all location-based parameters are updated.

    SQL> select name from v$datafile;
    SQL> select member from v$logfile;
    SQL> select name from v$tempfile;
    SQL> show parameter spfile;
    SQL> select name, value from v$parameter where value is not null;
  8. The following script demonstrates how to simplify this process:

    [root@host1 current]# ./checkdbdata.pl TOAST
    TOAST datafiles:
    +NEWDATA/TOAST/DATAFILE/system.259.897759609
    +NEWDATA/TOAST/DATAFILE/sysaux.263.897759615
    +NEWDATA/TOAST/DATAFILE/undotbs1.264.897759619
    +NEWDATA/TOAST/DATAFILE/users.258.897759623
    TOAST redo logs:
    +NEWLOGS/TOAST/ONLINELOG/group_4.266.897763123
    +NEWLOGS/TOAST/ONLINELOG/group_5.265.897763125
    +NEWLOGS/TOAST/ONLINELOG/group_6.264.897763125
    TOAST temp datafiles:
    +NEWDATA/TOAST/TEMPFILE/temp.260.897763165
    TOAST spfile
    spfile                               string      +NEWDATA/spfiletoast.ora
    TOAST key parameters
    control_files +NEWLOGS/TOAST/CONTROLFILE/current.273.897761061
    log_archive_dest_1 LOCATION=+NEWLOGS
    db_create_file_dest +NEWDATA
    db_create_online_log_dest_1 +NEWLOGS
  9. If the ASM disk groups were completely evacuated, they can now be unmounted with asmcmd. However, in many cases the files belonging to other databases or the ASM spfile/passwd file might still be present.

    -bash-4.1$ . oraenv
    ORACLE_SID = [TOAST] ? +ASM
    The Oracle base remains unchanged with value /orabin
    -bash-4.1$ asmcmd
    ASMCMD> umount DATA
    ASMCMD>

Oracle ASM to file system copy

The Oracle ASM to file system copy procedure is very similar to the ASM to ASM copy procedure, with similar benefits and restrictions. The primary difference is the syntax of the various commands and configuration parameters when using a visible file system as opposed to an ASM disk group.

Copy database

Oracle RMAN is used to create a level 0 (complete) copy of the source database currently located on the ASM disk group +DATA to the new location on /oradata.

RMAN> backup as copy incremental level 0 database format '/oradata/TOAST/%U' tag 'ONTAP_MIGRATION';
Starting backup at 13-MAY-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=377 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+ASM0/TOAST/system01.dbf
output file name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSTEM_FNO-1_01r5fhjg tag=ONTAP_MIGRATION RECID=1 STAMP=911722099
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+ASM0/TOAST/sysaux01.dbf
output file name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSAUX_FNO-2_02r5fhjo tag=ONTAP_MIGRATION RECID=2 STAMP=911722106
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+ASM0/TOAST/undotbs101.dbf
output file name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-UNDOTBS1_FNO-3_03r5fhjt tag=ONTAP_MIGRATION RECID=3 STAMP=911722113
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/oradata/TOAST/cf_D-TOAST_id-2098173325_04r5fhk5 tag=ONTAP_MIGRATION RECID=4 STAMP=911722118
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+ASM0/TOAST/users01.dbf
output file name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-USERS_FNO-4_05r5fhk6 tag=ONTAP_MIGRATION RECID=5 STAMP=911722118
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 13-MAY-16
channel ORA_DISK_1: finished piece 1 at 13-MAY-16
piece handle=/oradata/TOAST/06r5fhk7_1_1 tag=ONTAP_MIGRATION comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-MAY-16

Force archive log switch

Forcing the archive log switch is required to make sure that the archive logs contain all of the data required to make the copy fully consistent. Without this command, key data might still be present in the redo logs. To force an archive log switch, run the following command:

RMAN> sql 'alter system archive log current';
sql statement: alter system archive log current

Shut down source database

Disruption begins in this step because the database is shut down and placed in a limited-access read-only mode. To shut down the source database, run the following commands:

RMAN> shutdown immediate;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> startup mount;
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area     805306368 bytes
Fixed Size                  2929552 bytes
Variable Size             331353200 bytes
Database Buffers          465567744 bytes
Redo Buffers                5455872 bytes

Controlfile backup

Back up controlfiles in case you must abort the migration and revert to the original storage location. A copy of the backup controlfile isn't 100% required, but it does make the process of resetting the database file locations back to the original location easier.

RMAN> backup as copy current controlfile format '/tmp/TOAST.ctrl';
Starting backup at 08-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/tmp/TOAST.ctrl tag=TAG20151208T194540 RECID=30 STAMP=897939940
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-DEC-15

Parameter updates

RMAN> create pfile='/tmp/pfile' from spfile;
Statement processed

Update pfile

Any parameters referring to old ASM disk groups should be updated and, in some cases, deleted when they are no longer relevant. Update them to reflect the new file system paths and save the updated pfile. Make sure that the complete target path is listed. To update these parameters, run the following commands:

*.audit_file_dest='/orabin/admin/TOAST/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/logs/TOAST/arch/control01.ctl','/logs/TOAST/redo/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='TOAST'
*.diagnostic_dest='/orabin'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=TOASTXDB)'
*.log_archive_dest_1='LOCATION=/logs/TOAST/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=256m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=768m
*.undo_tablespace='UNDOTBS1'

Disable the original init.ora file

This file is located in the $ORACLE_HOME/dbs directory and is usually in a pfile that serves as a pointer to the spfile on the ASM disk group. To make sure that the original spfile is no longer used, rename it. Do not delete it, however, because this file is needed if the migration must be aborted.

[oracle@jfsc1 ~]$ cd $ORACLE_HOME/dbs
[oracle@jfsc1 dbs]$ cat initTOAST.ora
SPFILE='+ASM0/TOAST/spfileTOAST.ora'
[oracle@jfsc1 dbs]$ mv initTOAST.ora initTOAST.ora.prev
[oracle@jfsc1 dbs]$

Parameter file recreation

This is the final step in spfile relocation. The original spfile is no longer used and the database is currently started (but not mounted) using the intermediate file. The contents of this file can be written out to the new spfile location as follows:

RMAN> create spfile from pfile='/tmp/pfile';
Statement processed

Start database to start using new spfile

You must start the database to release the locks on the intermediate file and start the database by using only the new spfile file. Starting the database also proves that the new spfile location is correct and its data is valid.

RMAN> shutdown immediate;
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area     805306368 bytes
Fixed Size                     2929552 bytes
Variable Size                331353200 bytes
Database Buffers             465567744 bytes
Redo Buffers                   5455872 bytes

Restore controlfile

A backup controlfile was created at the path /tmp/TOAST.ctrl earlier in the procedure. The new spfile defines the controlfile locations as /logfs/TOAST/ctrl/ctrlfile1.ctrl and /logfs/TOAST/redo/ctrlfile2.ctrl. However, those files do not yet exist.

  1. This command restores the controlfile data to the paths defined in the spfile.

    RMAN> restore controlfile from '/tmp/TOAST.ctrl';
    Starting restore at 13-MAY-16
    using channel ORA_DISK_1
    channel ORA_DISK_1: copied control file copy
    output file name=/logs/TOAST/arch/control01.ctl
    output file name=/logs/TOAST/redo/control02.ctl
    Finished restore at 13-MAY-16
  2. Issue the mount command so that the controlfiles are discovered correctly and contain valid data.

    RMAN> alter database mount;
    Statement processed
    released channel: ORA_DISK_1

    To validate the control_files parameter, run the following command:

    SQL> show parameter control_files;
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    control_files                        string      /logs/TOAST/arch/control01.ctl
                                                     , /logs/TOAST/redo/control02.c
                                                     tl

Log replay

The database is currently using the data files in the old location. Before the copy can be used, the data files must be synchronized. Time has passed during the initial copy process, and changes were logged primarily in the archive logs. These changes are replicated in the following two steps.

  1. Perform an RMAN incremental backup, which contains the archive logs.

    RMAN>  backup incremental level 1 format '/logs/TOAST/arch/%U' for recover of copy with tag 'ONTAP_MIGRATION' database;
    Starting backup at 13-MAY-16
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=124 device type=DISK
    channel ORA_DISK_1: starting incremental level 1 datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=+ASM0/TOAST/system01.dbf
    input datafile file number=00002 name=+ASM0/TOAST/sysaux01.dbf
    input datafile file number=00003 name=+ASM0/TOAST/undotbs101.dbf
    input datafile file number=00004 name=+ASM0/TOAST/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 13-MAY-16
    channel ORA_DISK_1: finished piece 1 at 13-MAY-16
    piece handle=/logs/TOAST/arch/09r5fj8i_1_1 tag=ONTAP_MIGRATION comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 13-MAY-16
    RMAN-06497: WARNING: control file is not current, control file AUTOBACKUP skipped
  2. Replay the logs.

    RMAN> recover copy of database with tag 'ONTAP_MIGRATION';
    Starting recover at 13-MAY-16
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile copies to recover
    recovering datafile copy file number=00001 name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSTEM_FNO-1_01r5fhjg
    recovering datafile copy file number=00002 name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSAUX_FNO-2_02r5fhjo
    recovering datafile copy file number=00003 name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-UNDOTBS1_FNO-3_03r5fhjt
    recovering datafile copy file number=00004 name=/oradata/TOAST/data_D-TOAST_I-2098173325_TS-USERS_FNO-4_05r5fhk6
    channel ORA_DISK_1: reading from backup piece /logs/TOAST/arch/09r5fj8i_1_1
    channel ORA_DISK_1: piece handle=/logs/TOAST/arch/09r5fj8i_1_1 tag=ONTAP_MIGRATION
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    Finished recover at 13-MAY-16
    RMAN-06497: WARNING: control file is not current, control file AUTOBACKUP skipped

Activation

The controlfile that was restored still references the data files at the original location, and it also contains the path information for the copied data files.

  1. To change the active data files, run the switch database to copy command:

    RMAN> switch database to copy;
    datafile 1 switched to datafile copy "/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSTEM_FNO-1_01r5fhjg"
    datafile 2 switched to datafile copy "/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSAUX_FNO-2_02r5fhjo"
    datafile 3 switched to datafile copy "/oradata/TOAST/data_D-TOAST_I-2098173325_TS-UNDOTBS1_FNO-3_03r5fhjt"
    datafile 4 switched to datafile copy "/oradata/TOAST/data_D-TOAST_I-2098173325_TS-USERS_FNO-4_05r5fhk6"
  2. Although the data files should be fully consistent, one final step is required to replay the remaining changes recorded in the online redo logs. Use the recover database command to replay these changes and make the copy 100% identical to the original. The copy is not yet open, however.

    RMAN> recover database;
    Starting recover at 13-MAY-16
    using channel ORA_DISK_1
    starting media recovery
    archived log for thread 1 with sequence 28 is already on disk as file +ASM0/TOAST/redo01.log
    archived log file name=+ASM0/TOAST/redo01.log thread=1 sequence=28
    media recovery complete, elapsed time: 00:00:00
    Finished recover at 13-MAY-16

Relocate Temporary Data Files

  1. Identify the location of temporary data files still in use on the original disk group.

    RMAN> select file#||' '||name from v$tempfile;
    FILE#||''||NAME
    --------------------------------------------------------------------------------
    1 +ASM0/TOAST/temp01.dbf
  2. To relocate the data files, run the following commands. If there are many tempfiles, use a text editor to create the RMAN command and then cut and paste it.

    RMAN> run {
    2> set newname for tempfile 1 to '/oradata/TOAST/temp01.dbf';
    3> switch tempfile all;
    4> }
    executing command: SET NEWNAME
    renamed tempfile 1 to /oradata/TOAST/temp01.dbf in control file

Redo log migration

The migration process is nearly complete, but the redo logs are still located on the original ASM disk group. Redo logs cannot be directly relocated. Instead, a new set of redo logs is created and added to the configuration, following by a drop of the old logs.

  1. Identify the number of redo log groups and their respective group numbers.

    RMAN> select group#||' '||member from v$logfile;
    GROUP#||''||MEMBER
    --------------------------------------------------------------------------------
    1 +ASM0/TOAST/redo01.log
    2 +ASM0/TOAST/redo02.log
    3 +ASM0/TOAST/redo03.log
  2. Enter the size of the redo logs.

    RMAN> select group#||' '||bytes from v$log;
    GROUP#||''||BYTES
    --------------------------------------------------------------------------------
    1 52428800
    2 52428800
    3 52428800
  3. For each redo log, create a new group by using the same size as the current redo log group using the new file system location.

    RMAN> alter database add logfile '/logs/TOAST/redo/log00.rdo' size 52428800;
    Statement processed
    RMAN> alter database add logfile '/logs/TOAST/redo/log01.rdo' size 52428800;
    Statement processed
    RMAN> alter database add logfile '/logs/TOAST/redo/log02.rdo' size 52428800;
    Statement processed
  4. Remove the old logfile groups that are still located on the prior storage.

    RMAN> alter database drop logfile group 4;
    Statement processed
    RMAN> alter database drop logfile group 5;
    Statement processed
    RMAN> alter database drop logfile group 6;
    Statement processed
  5. If an error is encountered that blocks dropping an active log, force a switch to the next log to release the lock and force a global checkpoint. An example is shown below. The attempt to drop logfile group 3, which was located on the old location, was denied because there was still active data in this logfile. A log archiving followed by a checkpoint enables logfile deletion.

    RMAN> alter database drop logfile group 4;
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of sql statement command at 12/08/2015 20:23:51
    ORA-01623: log 4 is current log for instance TOAST (thread 4) - cannot drop
    ORA-00312: online log 4 thread 1: '+NEWLOGS/TOAST/ONLINELOG/group_4.266.897763123'
    RMAN> alter system switch logfile;
    Statement processed
    RMAN> alter system checkpoint;
    Statement processed
    RMAN> alter database drop logfile group 4;
    Statement processed
  6. Review the environment to make sure that all location-based parameters are updated.

    SQL> select name from v$datafile;
    SQL> select member from v$logfile;
    SQL> select name from v$tempfile;
    SQL> show parameter spfile;
    SQL> select name, value from v$parameter where value is not null;
  7. The following script demonstrates how to make this process easier.

    [root@jfsc1 current]# ./checkdbdata.pl TOAST
    TOAST datafiles:
    /oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSTEM_FNO-1_01r5fhjg
    /oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSAUX_FNO-2_02r5fhjo
    /oradata/TOAST/data_D-TOAST_I-2098173325_TS-UNDOTBS1_FNO-3_03r5fhjt
    /oradata/TOAST/data_D-TOAST_I-2098173325_TS-USERS_FNO-4_05r5fhk6
    TOAST redo logs:
    /logs/TOAST/redo/log00.rdo
    /logs/TOAST/redo/log01.rdo
    /logs/TOAST/redo/log02.rdo
    TOAST temp datafiles:
    /oradata/TOAST/temp01.dbf
    TOAST spfile
    spfile                               string      /orabin/product/12.1.0/dbhome_
                                                     1/dbs/spfileTOAST.ora
    TOAST key parameters
    control_files /logs/TOAST/arch/control01.ctl, /logs/TOAST/redo/control02.ctl
    log_archive_dest_1 LOCATION=/logs/TOAST/arch
  8. If the ASM disk groups were completely evacuated, they can now be unmounted with asmcmd. In many cases, files belonging to other databases or the ASM spfile/passwd file can still be present.

    -bash-4.1$ . oraenv
    ORACLE_SID = [TOAST] ? +ASM
    The Oracle base remains unchanged with value /orabin
    -bash-4.1$ asmcmd
    ASMCMD> umount DATA
    ASMCMD>

Data file cleanup procedure

The migration process might result in data files with long or cryptic syntax, depending on how Oracle RMAN was used. In the example shown here, the backup was performed with the file format of /oradata/TOAST/%U. %U indicates that RMAN should create a default unique name for each data file. The result is similar to what is shown in the following text. The traditional names for the data files are embedded within the names. This can be cleaned up by using the scripted approach shown in ASM Migration Cleanup.

[root@jfsc1 current]# ./fixuniquenames.pl TOAST
#sqlplus Commands
shutdown immediate;
startup mount;
host mv /oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSTEM_FNO-1_01r5fhjg /oradata/TOAST/system.dbf
host mv /oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSAUX_FNO-2_02r5fhjo /oradata/TOAST/sysaux.dbf
host mv /oradata/TOAST/data_D-TOAST_I-2098173325_TS-UNDOTBS1_FNO-3_03r5fhjt /oradata/TOAST/undotbs1.dbf
host mv /oradata/TOAST/data_D-TOAST_I-2098173325_TS-USERS_FNO-4_05r5fhk6 /oradata/TOAST/users.dbf
alter database rename file '/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSTEM_FNO-1_01r5fhjg' to '/oradata/TOAST/system.dbf';
alter database rename file '/oradata/TOAST/data_D-TOAST_I-2098173325_TS-SYSAUX_FNO-2_02r5fhjo' to '/oradata/TOAST/sysaux.dbf';
alter database rename file '/oradata/TOAST/data_D-TOAST_I-2098173325_TS-UNDOTBS1_FNO-3_03r5fhjt' to '/oradata/TOAST/undotbs1.dbf';
alter database rename file '/oradata/TOAST/data_D-TOAST_I-2098173325_TS-USERS_FNO-4_05r5fhk6' to '/oradata/TOAST/users.dbf';
alter database open;

Oracle ASM rebalance

As discussed previously, an Oracle ASM disk group can be transparently migrated to a new storage system by using the rebalancing process. In summary, the rebalancing process requires the addition of equal-sized LUNs to the existing group of LUNs followed by a drop operation of the prior LUN. Oracle ASM automatically relocates the underlying data to new storage in an optimal layout and then releases the old LUNs when complete.

The migration process uses efficient sequential I/O and does not generally cause any performance disruption, but the migration rate can be throttled when needed.

Identify data to be migrated

SQL> select name||' '||group_number||' '||total_mb||' '||path||' '||header_status from v$asm_disk;
NEWDATA_0003 1 10240 /dev/mapper/3600a098038303537762b47594c315864 MEMBER
NEWDATA_0002 1 10240 /dev/mapper/3600a098038303537762b47594c315863 MEMBER
NEWDATA_0000 1 10240 /dev/mapper/3600a098038303537762b47594c315861 MEMBER
NEWDATA_0001 1 10240 /dev/mapper/3600a098038303537762b47594c315862 MEMBER
SQL> select group_number||' '||name from v$asm_diskgroup;
1 NEWDATA

Create new LUNs

Create new LUNs of the same size, and set user and group membership as required. The LUNs should appear as CANDIDATE disks.

SQL> select name||' '||group_number||' '||total_mb||' '||path||' '||header_status from v$asm_disk;
 0 0 /dev/mapper/3600a098038303537762b47594c31586b CANDIDATE
 0 0 /dev/mapper/3600a098038303537762b47594c315869 CANDIDATE
 0 0 /dev/mapper/3600a098038303537762b47594c315858 CANDIDATE
 0 0 /dev/mapper/3600a098038303537762b47594c31586a CANDIDATE
NEWDATA_0003 1 10240 /dev/mapper/3600a098038303537762b47594c315864 MEMBER
NEWDATA_0002 1 10240 /dev/mapper/3600a098038303537762b47594c315863 MEMBER
NEWDATA_0000 1 10240 /dev/mapper/3600a098038303537762b47594c315861 MEMBER
NEWDATA_0001 1 10240 /dev/mapper/3600a098038303537762b47594c315862 MEMBER

Add new LUNS

While the add and drop operations can be performed together, it is generally easier to add new LUNs in two steps. First, add the new LUNs to the disk group. This step results in half of the extents being migrated from the current ASM LUNs to the new LUNs.

The rebalance power indicates the rate at which data is being transferred. The higher the number, the higher the parallelism of the data transfer. The migration is performed with efficient sequential I/O operations that are unlikely to cause performance problems. However, if desired, the rebalance power of an ongoing migration can be adjusted with the alter diskgroup [name] rebalance power [level] command. Typical migrations use a value of 5.

SQL> alter diskgroup NEWDATA add disk '/dev/mapper/3600a098038303537762b47594c31586b' rebalance power 5;
Diskgroup altered.
SQL> alter diskgroup NEWDATA add disk '/dev/mapper/3600a098038303537762b47594c315869' rebalance power 5;
Diskgroup altered.
SQL> alter diskgroup NEWDATA add disk '/dev/mapper/3600a098038303537762b47594c315858' rebalance power 5;
Diskgroup altered.
SQL> alter diskgroup NEWDATA add disk '/dev/mapper/3600a098038303537762b47594c31586a' rebalance power 5;
Diskgroup altered.

Monitor operation

A rebalancing operation can be monitored and managed in multiple ways. We used the following command for this example.

SQL> select group_number,operation,state from v$asm_operation;
GROUP_NUMBER OPERA STAT
------------ ----- ----
           1 REBAL RUN
           1 REBAL WAIT

When migration is complete, no rebalancing operations are reported.

SQL> select group_number,operation,state from v$asm_operation;
no rows selected

Drop old LUNs

The migration is now halfway complete. It might be desirable to perform some basic performance tests to make sure that the environment is healthy. After confirmation, the remaining data can be relocated by dropping the old LUNs. Note that this does not result in immediate release of the LUNs. The drop operation signals Oracle ASM to relocate the extents first and then release the LUN.

sqlplus / as sysasm
SQL> alter diskgroup NEWDATA drop disk NEWDATA_0000 rebalance power 5;
Diskgroup altered.
SQL> alter diskgroup NEWDATA drop disk NEWDATA_0001 rebalance power 5;
Diskgroup altered.
SQL> alter diskgroup newdata drop disk NEWDATA_0002 rebalance power 5;
Diskgroup altered.
SQL> alter diskgroup newdata drop disk NEWDATA_0003 rebalance power 5;
Diskgroup altered.

Monitor operation

The rebalancing operation can be monitored and managed in multiple ways. We used the following command for this example:

SQL> select group_number,operation,state from v$asm_operation;
GROUP_NUMBER OPERA STAT
------------ ----- ----
           1 REBAL RUN
           1 REBAL WAIT

When migration is complete, no rebalancing operations are reported.

SQL> select group_number,operation,state from v$asm_operation;
no rows selected

Remove old LUNs

Before you remove the old LUNs from the disk group, you should perform one final check on the header status. After a LUN is released from ASM, it no longer has a name listed and the header status is listed as FORMER. This indicates that these LUNs can safely be removed from the system.

SQL> select name||' '||group_number||' '||total_mb||' '||path||' '||header_status from v$asm_disk;
NAME||''||GROUP_NUMBER||''||TOTAL_MB||''||PATH||''||HEADER_STATUS
--------------------------------------------------------------------------------
 0 0 /dev/mapper/3600a098038303537762b47594c315863 FORMER
 0 0 /dev/mapper/3600a098038303537762b47594c315864 FORMER
 0 0 /dev/mapper/3600a098038303537762b47594c315861 FORMER
 0 0 /dev/mapper/3600a098038303537762b47594c315862 FORMER
NEWDATA_0005 1 10240 /dev/mapper/3600a098038303537762b47594c315869 MEMBER
NEWDATA_0007 1 10240 /dev/mapper/3600a098038303537762b47594c31586a MEMBER
NEWDATA_0004 1 10240 /dev/mapper/3600a098038303537762b47594c31586b MEMBER
NEWDATA_0006 1 10240 /dev/mapper/3600a098038303537762b47594c315858 MEMBER
8 rows selected.

LVM migration

The procedure presented here shows the principles of an LVM-based migration of a volume group called datavg. The examples are drawn from the Linux LVM, but the principles apply equally to AIX, HP-UX, and VxVM. The precise commands might vary.

  1. Identify the LUNs currently in the datavg volume group.

    [root@host1 ~]# pvdisplay -C | grep datavg
      /dev/mapper/3600a098038303537762b47594c31582f datavg lvm2 a--  10.00g 10.00g
      /dev/mapper/3600a098038303537762b47594c31585a datavg lvm2 a--  10.00g 10.00g
      /dev/mapper/3600a098038303537762b47594c315859 datavg lvm2 a--  10.00g 10.00g
      /dev/mapper/3600a098038303537762b47594c31586c datavg lvm2 a--  10.00g 10.00g
  2. Create new LUNs of the same or slightly larger physical size and define them as physical volumes.

    [root@host1 ~]# pvcreate /dev/mapper/3600a098038303537762b47594c315864
      Physical volume "/dev/mapper/3600a098038303537762b47594c315864" successfully created
    [root@host1 ~]# pvcreate /dev/mapper/3600a098038303537762b47594c315863
      Physical volume "/dev/mapper/3600a098038303537762b47594c315863" successfully created
    [root@host1 ~]# pvcreate /dev/mapper/3600a098038303537762b47594c315862
      Physical volume "/dev/mapper/3600a098038303537762b47594c315862" successfully created
    [root@host1 ~]# pvcreate /dev/mapper/3600a098038303537762b47594c315861
      Physical volume "/dev/mapper/3600a098038303537762b47594c315861" successfully created
  3. Add the new volumes to the volume group.

    [root@host1 tmp]# vgextend datavg /dev/mapper/3600a098038303537762b47594c315864
      Volume group "datavg" successfully extended
    [root@host1 tmp]# vgextend datavg /dev/mapper/3600a098038303537762b47594c315863
      Volume group "datavg" successfully extended
    [root@host1 tmp]# vgextend datavg /dev/mapper/3600a098038303537762b47594c315862
      Volume group "datavg" successfully extended
    [root@host1 tmp]# vgextend datavg /dev/mapper/3600a098038303537762b47594c315861
      Volume group "datavg" successfully extended
  4. Issue the pvmove command to relocate the extents of each current LUN to the new LUN. The - i [seconds] argument monitors the progress of the operation.

    [root@host1 tmp]# pvmove -i 10 /dev/mapper/3600a098038303537762b47594c31582f /dev/mapper/3600a098038303537762b47594c315864
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 0.0%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 14.2%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 28.4%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 42.5%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 57.1%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 72.3%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 87.3%
      /dev/mapper/3600a098038303537762b47594c31582f: Moved: 100.0%
    [root@host1 tmp]# pvmove -i 10 /dev/mapper/3600a098038303537762b47594c31585a /dev/mapper/3600a098038303537762b47594c315863
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 0.0%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 14.9%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 29.9%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 44.8%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 60.1%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 75.8%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 90.9%
      /dev/mapper/3600a098038303537762b47594c31585a: Moved: 100.0%
    [root@host1 tmp]# pvmove -i 10 /dev/mapper/3600a098038303537762b47594c315859 /dev/mapper/3600a098038303537762b47594c315862
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 0.0%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 14.8%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 29.8%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 45.5%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 61.1%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 76.6%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 91.7%
      /dev/mapper/3600a098038303537762b47594c315859: Moved: 100.0%
    [root@host1 tmp]# pvmove -i 10 /dev/mapper/3600a098038303537762b47594c31586c /dev/mapper/3600a098038303537762b47594c315861
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 0.0%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 15.0%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 30.4%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 46.0%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 61.4%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 77.2%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 92.3%
      /dev/mapper/3600a098038303537762b47594c31586c: Moved: 100.0%
  5. When this process is complete, drop the old LUNs from the volume group by using the vgreduce command. If successful, the LUN can now be safely removed from the system.

    [root@host1 tmp]# vgreduce datavg /dev/mapper/3600a098038303537762b47594c31582f
    Removed "/dev/mapper/3600a098038303537762b47594c31582f" from volume group "datavg"
    [root@host1 tmp]# vgreduce datavg /dev/mapper/3600a098038303537762b47594c31585a
      Removed "/dev/mapper/3600a098038303537762b47594c31585a" from volume group "datavg"
    [root@host1 tmp]# vgreduce datavg /dev/mapper/3600a098038303537762b47594c315859
      Removed "/dev/mapper/3600a098038303537762b47594c315859" from volume group "datavg"
    [root@host1 tmp]# vgreduce datavg /dev/mapper/3600a098038303537762b47594c31586c
      Removed "/dev/mapper/3600a098038303537762b47594c31586c" from volume group "datavg"